code
stringlengths
73
34.1k
label
stringclasses
1 value
public static void bind(final Context _ctx, final String _nameStr, final Object _object) throws NamingException { final Name names = _ctx.getNameParser("").parse(_nameStr); if (names.size() > 0) { Context subCtx = _ctx; ...
java
protected Session getSession() throws EFapsException { if (this.session == null) { try { String username = getProperties().get(JCRStoreResource.PROPERTY_USERNAME); if (username == null) { username = Context.getThreadContext().getPerson(...
java
protected Node getFolderNode() throws EFapsException, RepositoryException { Node ret = getSession().getRootNode(); if (getProperties().containsKey(JCRStoreResource.PROPERTY_BASEFOLDER)) { if (ret.hasNode(getProperties().get(JCRStoreResource.PROPERTY_BASEFOLDER))) { ...
java
protected Binary getBinary(final InputStream _in) throws EFapsException { Binary ret = null; try { ret = SerialValueFactory.getInstance().createBinary(_in); } catch (final RepositoryException e) { throw new EFapsException("RepositoryException", e); } ...
java
protected void setIdentifer(final String _identifier) throws EFapsException { if (!_identifier.equals(this.identifier)) { ConnectionResource res = null; try { res = Context.getThreadContext().getConnectionResource(); final StringBuffer cmd = ...
java
@Override public void rollback(final Xid _xid) throws XAException { try { getSession().logout(); } catch (final EFapsException e) { throw new XAException("EFapsException"); } }
java
@Override public final void initialize(final Subject _subject, final CallbackHandler _callbackHandler, final Map < String, ? > _sharedState, final Map < String, ? > _options) { XMLUserLoginModule.LOG.debug...
java
@SuppressWarnings("unchecked") private void readPersons(final String _fileName) { try { final File file = new File(_fileName); final Digester digester = new Digester(); digester.setValidating(false); digester.addObjectCreate("persons", ArrayList.class); ...
java
private static boolean getAccessSetFromDB(final String _sql, final Object _criteria) throws CacheReloadException { boolean ret = false; Connection con = null; try { AccessSet accessSet = null; con = Context.getConn...
java
public Table cloneTable() { Table ret = null; try { ret = (Table) super.clone(); } catch (final CloneNotSupportedException e) { e.printStackTrace(); } return ret; }
java
@Override public void setIndex(boolean b) { if (b) { assert safe == null; safe = type; type = Typ.Int; } else { assert type.getKind() == TypeKind.INT; assert safe != null; type = safe; ...
java
public boolean hasEntries() { return (getCache4Id() != null && !getCache4Id().isEmpty()) || (getCache4Name() != null && !getCache4Name().isEmpty()) || (getCache4UUID() != null && !getCache4UUID().isEmpty()); }
java
public void initialize(final Class<?> _initializer) { this.initializer = _initializer.getName(); synchronized (this) { try { readCache(); } catch (final CacheReloadException e) { AbstractCache.LOG.error("Unexpected error while initializing Cach...
java
public void clear() { if (getCache4Id() != null) { getCache4Id().clear(); } if (getCache4Name() != null) { getCache4Name().clear(); } if (getCache4UUID() != null) { getCache4UUID().clear(); } }
java
public static void clearCaches() { synchronized (AbstractCache.CACHES) { for (final AbstractCache<?> cache : AbstractCache.CACHES) { cache.getCache4Id().clear(); cache.getCache4Name().clear(); cache.getCache4UUID().clear(); } } ...
java
@Override public void registerPropertyMatcher(PropertyMatcher<?> propertyMatcher) { if (propertyMatcher.getPathProvider() == null) { propertyMatcher.setPathProvider(this); } propertyMatcherList.add(propertyMatcher); }
java
@Deprecated public Add add(long projectId, String deviceId, String deviceName, String deviceType, Date created) { return add(projectId, new Device.Spec(deviceId, deviceName, deviceType), created); }
java
public final boolean abort() { boolean ret = false; if (UserLoginModule.LOG.isDebugEnabled()) { UserLoginModule.LOG.debug("Abort of " + this.principal); } // If our authentication was successful, just return false if (this.principal != null) { // Cl...
java
@Override public void readXML(final List<String> _tags, final Map<String, String> _attributes, final String _text) throws SAXException, EFapsException { if (_tags.size() == 1) { final String value = _tags.get(0); if ("uuid"....
java
protected void registerRevision(final String _application, final InstallFile _installFile, final Instance _objInst) throws InstallationException { try { if (CIAdminCommon.Application.getType() != null ...
java
public static BlogConnection getBlogConnection(final String type, final String url, final String username, final String password) throws BlogClientException { BlogConnection blogConnection = null; if (type == null || type.equals("metaweblog")) { blogConnection = createBlogConnect...
java
@SuppressWarnings("unchecked") public <G> OrFuture<G, BAD> future(CheckedFunction0<? extends Or<? extends G, ? extends BAD>> task) { OrFutureImpl<G, BAD> future = new OrFutureImpl<>(this); executor.execute(() -> { try { future.complete((Or<G, BAD>) task.apply()); } catch (Throwable t) { ...
java
@SafeVarargs public final <G, ERR> OrFuture<G, Every<ERR>> when(OrFuture<? extends G, ? extends Every<? extends ERR>> or, Function<? super G, ? extends Validation<ERR>>... validations) { OrPromise<G, Every<ERR>> promise = promise(); or.onComplete(o -> promise.complete(Accumulation.when(o, validation...
java
public <A, B, ERR, RESULT> OrFuture<RESULT, Every<ERR>> withGood(OrFuture<? extends A, ? extends Every<? extends ERR>> fa, OrFuture<? extends B, ? extends Every<? extends ERR>> fb, BiFunction<? super A, ? super B, ? extends RESULT> function) { return withPromise(this, promise -> fa.on...
java
public <G, ERR> OrFuture<G, ERR> firstCompletedOf(Iterable<? extends OrFuture<? extends G, ? extends ERR>> input) { OrPromise<G, ERR> promise = promise(); input.forEach(future -> future.onComplete(promise::tryComplete)); return promise.future(); }
java
public <A, B, ERR> OrFuture<Tuple2<A, B>, Every<ERR>> zip(OrFuture<? extends A, ? extends Every<? extends ERR>> a, OrFuture<? extends B, ? extends Every<? extends ERR>> b) { return withGood(a, b, Tuple::of); }
java
public <A, B, C, ERR> OrFuture<Tuple3<A, B, C>, Every<ERR>> zip3(OrFuture<? extends A, ? extends Every<? extends ERR>> a, OrFuture<? extends B, ? extends Every<? extends ERR>> b, OrFuture<? extends C, ? extends Every<? extends ERR>> c) { return withGood(a, b, c, Tuple::of); }
java
@Override public long getNewId(final ConnectionResource _con, final String _table, final String _column) throws SQLException { throw new SQLException("The database driver uses auto generated keys and " + "a new id c...
java
public void execute(final OutputStream _out) throws EFapsException { final boolean hasAccess = super.getInstance().getType().hasAccess(super.getInstance(), AccessTypeEnums.CHECKOUT.getAccessType()); if (!hasAccess) { ...
java
public void executeWithoutTrigger(final OutputStream _out) throws EFapsException { Resource storeRsrc = null; try { storeRsrc = Context.getThreadContext().getStoreResource(getInstance(), Resource.StoreEvent.READ); storeRsrc.read(_out); this.fileLength = st...
java
public static Timestamp getCurrentTimeFromDB() throws EFapsException { Timestamp now = null; final ConnectionResource rsrc = Context.getThreadContext().getConnectionResource(); final Statement stmt; try { stmt = rsrc.createStatement(); final ResultSet resultse...
java
void start(long currentTime) { this.readyTime = currentTime; this.startTime = this.readyTime + this.delayTime; this.endTime = this.startTime + getDuration(); this.status = TweenAnimationStatus.RUNNING; }
java
final void render(long currentTime) { if (this.getStatus() != TweenAnimationStatus.RUNNING) { return; } if (currentTime >= endTime && this.getStatus() != TweenAnimationStatus.WAIT) { this.status = TweenAnimationStatus.WAIT; return; } value = ...
java
@Override public BlogEntry next() { try { final ClientEntry entry = iterator.next(); if (entry instanceof ClientMediaEntry) { return new AtomResource(collection, (ClientMediaEntry) entry); } else { return new AtomEntry(collection, entry); ...
java
public String getPhraseValue(final Instance _instance) throws EFapsException { final StringBuilder buf = new StringBuilder(); boolean added = false; for (final Token token : this.valueList.getTokens()) { switch (token.getType()) { case EXPRESSION: ...
java
public static void index() throws EFapsException { final List<IndexDefinition> defs = IndexDefinition.get(); for (final IndexDefinition def : defs) { final QueryBuilder queryBldr = new QueryBuilder(def.getUUID()); final InstanceQuery query = queryBldr.getQuery(); ...
java
public static boolean VerifyStrings(String signature, String message, String publicKey) throws LRException { // Check that none of the inputs are null if (signature == null || message == null || publicKey == null) { throw new LRException(LRException.NULL_FIELD); } // Convert all inputs into input stream...
java
private static boolean Verify(InputStream isSignature, InputStream isMessage, InputStream isPublicKey) throws LRException { // Get the public key ring collection from the public key input stream PGPPublicKeyRingCollection pgpRings = null; try { pgpRings = new PGPPublicKeyRingCollection(PGPUtil.getDec...
java
public void setGlobalScopes(Iterable<GlobalScope> globalScopes) { this.globalScopes = Lists.newArrayList(Iterables.concat(globalScopes, serviceGlobalScopes)); }
java
public void render(String path, Map<String, Object> parameters, Writer out, GlobalScope... extraGlobalScopes) throws IOException, ParseException { render(load(path), parameters, out); }
java
public void renderInline(String text, Map<String, Object> parameters, Writer out, GlobalScope... extraGlobalScopes) throws IOException, ParseException { render(loadInline(text), parameters, out, extraGlobalScopes); }
java
public void render(Template template, Map<String, Object> parameters, Writer out, GlobalScope... extraGlobalScopes) throws IOException { newInterpreter(extraGlobalScopes).declare(parameters).process((TemplateImpl) template, out); }
java
public void render(Template template, Writer out, GlobalScope... extraGlobalScopes) throws IOException { newInterpreter(extraGlobalScopes).process((TemplateImpl) template, out); }
java
public String render(Template template, Map<String, Object> parameters, GlobalScope... extraGlobalScopes) throws IOException { StringWriter out = new StringWriter(); render(template, parameters, out, extraGlobalScopes); return out.toString(); }
java
public String render(String path, GlobalScope... extraGlobalScopes) throws IOException, ParseException { return render(load(path), extraGlobalScopes); }
java
public String renderInline(String text, GlobalScope... extraGlobalScopes) throws IOException, ParseException { return render(loadInline(text), extraGlobalScopes); }
java
public String render(Template template, GlobalScope... extraGlobalScopes) throws IOException { StringWriter out = new StringWriter(); render(template, out, extraGlobalScopes); return out.toString(); }
java
public Template loadInline(String text) throws IOException, ParseException { try(InlineTemplateSource templateSource = new InlineTemplateSource(text)) { return load("inline", templateSource); } }
java
public Template load(String path) throws IOException, ParseException { try(TemplateSource source = sourceLoader.find(path)) { if (source != null) { return load(path, source); } } return null; }
java
public boolean next() throws EFapsException { boolean ret = false; if (this.iterator == null) { this.iterator = this.instances.iterator(); } if (this.iterator.hasNext()) { this.current = this.iterator.next(); ret = true; } i...
java
protected Object executeEvents(final EventType _eventType, final TargetMode _targetMode) throws EFapsException { Object ret = null; if (this.fieldId > 0 && getField().hasEvents(_eventType)) { final List<EventDefinition> events = getField().getE...
java
public void setPosition(double x, double y, double z) { this.x = x; this.y = y; this.z = z; }
java
public void setPosition(Vector3D v) { this.x = v.getX(); this.y = v.getY(); this.z = v.getZ(); }
java
public void setRotation(double angle, double x, double y, double z) { this.rotateX = angle * x; this.rotateY = angle * y; this.rotate = angle * z; }
java
public void setScale(double scaleX, double scaleY, double scaleZ) { this.scaleX = scaleX; this.scaleY = scaleY; this.scaleZ = scaleZ; }
java
public void addMouseEventCallback(MouseEventCallback callback) { if (mouseEventCallbacks == null) { mouseEventCallbacks = new ArrayList<MouseEventCallback>(); } mouseEventCallbacks.add(callback); }
java
@SuppressWarnings("unchecked") protected Result<JsonNode> writeDataWithResult(final ObjectNode message, final ObjectMapper objectMapper) { Result<JsonNode> result; byte[] binaryResultMessage = null; String textResultMessage = null; // convert json into map try { ...
java
public void addSyntheticRule(ExecutableElement reducer, String nonterminal, String... rhs) { addRule(reducer, nonterminal, "", true, Arrays.asList(rhs)); }
java
public void addAnonymousTerminal(String expression, Option... options) { addTerminal(null, "'"+expression+"'", expression, "", 0, 10, options); }
java
public LALRKParserGenerator getParserGenerator(ParseMethod parseMethod) { Grammar g = new Grammar(parseMethod.start(), this, parseMethod.eof(), parseMethod.whiteSpace()); try { return g.createParserGenerator(parseMethod.start(), ParserFeature.get(parseMethod)); } ...
java
public void add(CharRange cond) { if (set.isEmpty()) { set.add(cond); } else { List<CharRange> remlist = new ArrayList<CharRange>(); List<CharRange> addlist = new ArrayList<CharRange>(); boolean is = false; ...
java
public static RangeSet split(Collection<RangeSet> rangeSets) { RangeSet result = new RangeSet(); SortedSet<Integer> ss = new TreeSet<Integer>(); for (RangeSet rs : rangeSets) { for (CharRange r : rs) { ss.add(r.getFrom()); ...
java
public boolean isIntersecting(Collection<RangeSet> rangeSets) { for (RangeSet rs : rangeSets) { for (CharRange r1 : rs) { for (CharRange r2 : this) { if (r1.intersect(r2)) { ...
java
public static RangeSet merge(RangeSet rs) { RangeSet result = new RangeSet(); int from = -1; int to = -1; for (CharRange r : rs) { if (from == -1) // first { from = r.getFrom(); to = r.getTo(); } ...
java
public RangeSet complement() { SortedSet<CharRange> nset = new TreeSet<CharRange>(); int from = 0; for (CharRange r : set) { int to = r.getFrom(); if (from < to) { nset.add(new CharRange(from, to)); } ...
java
public TableIdx getTableIdx(final String _tableName, final String... _keys) { TableIdx ret = null; final String key = _tableName + "-" + StringUtils.join(_keys, "-"); final Optional<TableIdx> val = this.tableidxs.stream().filter(t -> t.getKey().equals(key)).fi...
java
public static void compileAll(final List<String> _classPathElements) throws EFapsException { new JasperReportCompiler(_classPathElements).compile(); new CSSCompiler().compile(); new JavaScriptCompiler().compile(); new WikiCompiler().compile(); }
java
protected Map<String, String> readCompiledSources() throws EFapsException { final Map<String, String> ret = new HashMap<>(); final QueryBuilder queryBldr = new QueryBuilder(getClassName4TypeCompiled()); final MultiPrintQuery multi = queryBldr.getPrint(); multi.addAttribute(CI...
java
protected List<T> readSources() throws EFapsException { final List<T> ret = new ArrayList<>(); final QueryBuilder queryBldr = new QueryBuilder(getClassName4Type()); final MultiPrintQuery multi = queryBldr.getPrint(); multi.addAttribute(CIAdminProgram.Abstract.Name); m...
java
protected List<Instance> getSuper(final Instance _instance) throws EFapsException { final List<Instance> ret = new ArrayList<>(); final QueryBuilder queryBldr = new QueryBuilder(getClassName4Type2Type()); queryBldr.addWhereAttrEqValue(CIAdminProgram.Program2Program.From, _instance.ge...
java
public static String getSourceByClass(Class<?> koanClass) { File file = new File(getKoanFileLocation(koanClass)); StringBuilder contents = new StringBuilder(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String text = null; while ((t...
java
public static FileInputStream getInputStreamByClass(Class<?> koanClass) { FileInputStream in = null; try { in = new FileInputStream(getKoanFileLocation(koanClass)); } catch (FileNotFoundException e) { e.printStackTrace(); } return in; }
java
public static String getSolutionFromFile(Class<?> koanClass, String methodName){ return getSourceFromFile(koanClass, methodName, SOLUTION_EXTENSION); }
java
public static String getProblemFromFile(Class<?> koanClass, String methodName) { return getSourceFromFile(koanClass, methodName, PROBLEM_EXTENSION); }
java
public Instance updateInDB(final Instance _instance, final String _typeName) { Instance ret = null; try { final long typeID = _instance.getId(); final long progID = getProgID(_typeName); final QueryBuilder queryBldr = new QueryBuild...
java
private long getProgID(final String _typeName) throws EFapsException { long id = 0; final QueryBuilder queryBldr = new QueryBuilder(CIAdminProgram.Java); queryBldr.addWhereAttrEqValue(CIAdminProgram.Java.Name, this.program); final InstanceQuery query = queryBldr.getQuery(); ...
java
public void addPropertiesOverwrite(final String _sytemConfig, final String _attribute) { this.properties.put(Overwrite.SYSTEMCONFIG.value(), _sytemConfig); this.properties.put(Overwrite.ATTRIBUTE.value(), _attribute); }
java
public String getMessage() { if (code == NO_DATA) return "A document cannot be added without resource data."; else if (code == NO_LOCATOR) return "A document cannot be added without a resource locator."; else if (code == INVALID_JSON) return "The provided ...
java
public void resetDatabase() { String dropOrphanedEvents = "DROP TABLE IF EXISTS " + DbOrphanedEvent.TABLE_NAME; SQLiteDatabase writable = dbHelper.getWritableDatabase(); writable.beginTransaction(); try { writable.execSQL(dropOrphanedEvents); writable.execSQL...
java
@SuppressWarnings("unchecked") private <T> List<WatcherRegistration<T>> getWatcherRegistrations(Id<T> id) { return (List<WatcherRegistration<T>>)((Container)watcherRegistry).getAll(id.type()); }
java
public Integer getIndex4SqlTable(final SQLTable _sqlTable) { final Integer ret; if (this.sqlTable2Index.containsKey(_sqlTable)) { ret = this.sqlTable2Index.get(_sqlTable); } else { Integer max = 0; for (final Integer index : this.sqlTable2Index.values()) {...
java
public boolean next() { if (this.iter == null) { this.iter = new ArrayList<>(this.values).iterator(); } final boolean ret = this.iter.hasNext(); if (ret) { this.current = this.iter.next(); } return ret; }
java
@Override public URL findResource(final String _name) { URL ret = null; final String name = _name.replaceAll(System.getProperty("file.separator"), ".").replaceAll(".class", ""); final byte[] data = loadClassData(name); if (data != null && data.length > 0) { final File...
java
protected byte[] loadClassData(final String _resourceName) { EFapsClassLoader.LOG.debug("Loading Class '{}' from Database.", _resourceName); final byte[] x = read(_resourceName); return x; }
java
void sendTaskListToChannels(List<TaskRec> tasks) { // group by type // Map<String, List<TaskRec>> grouped = new HashMap<String, List<TaskRec>>(); for (TaskRec taskRec : tasks) { List<TaskRec> tlist = grouped.get(taskRec.name); if (tlist == null) { tlist = new ArrayList<TaskRec>(); grouped.put(task...
java
void handleUnknownTasks(List<TaskRec> taskRecList) { long nowMs = System.currentTimeMillis(); for (TaskRec taskRec : taskRecList) { if (taskRec.createTs.getTime() < nowMs - UNKNOWN_TASK_CANCEL_AFTER_MS) { logger.warn("Task is unknown and was not processed during 24 hours, mark as error: {}", taskRec); ch...
java
private void calcChannelsStats(List<TaskRec> tasks) { for (ChannelWorkContext wc : channelContextMap.values()) { wc.lastGotCount = 0; } for (TaskRec taskRec : tasks) { ChannelWorkContext wc = channelContextMap.get(taskRec.channel); if (wc == null) { wc = new ChannelWorkContext(taskRec.channel); c...
java
@Koan public void makeTheProductOfIAndJ(){ int i = 10; int j = 5; int product = 0; /* (@_@) */ product = i * j; /* (^_^) */ assertThat(product, is(50)); }
java
@Koan @Vex public void provideTheStartingProblemForCalculatingAFibonacciNumberUsingALoop(){ int seventhFibonacciNumber = 0; /* (@_@) */ int previous1 = 1; int previous2 = 1; int currentFibonacci = 1; for(int i= 3; i<= 7; i++){ } seventhFibonacciN...
java
@Action() public SomeNotAuditedObject updateNameAndNumber( @ParameterLayout(named = "Name") final String name, @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "Number") final Integer number) { setName(name); setNumbe...
java
public void setCorner(int index, double x, double y) { if (index <= 0) { this.x1 = x; this.y1 = y; } else if (index == 1) { this.x2 = x; this.y2 = y; } else if (index == 2) { this.x3 = x; this.y3 = y; } else if (inde...
java
public void setConer(int index, Vector3D v) { if (index <= 0) { this.x1 = v.getX(); this.y1 = v.getY(); } else if (index == 1) { this.x2 = v.getX(); this.y2 = v.getY(); } else if (index == 2) { this.x3 = v.getX(); this.y3 = ...
java
public Vector3D getConer(int index) { Vector3D v = new Vector3D(0, 0, 0); if (index <= 0) { v.set(this.x1, this.y1); } else if (index == 1) { v.set(this.x2, this.y2); } else if (index == 2) { v.set(this.x3, this.y3); } else if (3 <= index) { ...
java
public void setCornerColor(int index, Color color) { if (!isGradation()) { for (int i = 0; i < 4; i++) { cornerColor[i] = new RGBColor(0.0, 0.0, 0.0); cornerColor[i] = this.fillColor; } setGradation(true); } cornerColor[index] =...
java
private AbstractQValue getValue(final Object _value) throws EFapsException { AbstractQValue ret = null; if (_value == null) { ret = new QNullValue(); } else if (_value instanceof Number) { ret = new QNumberValue((Number) _value); } else if (_value inst...
java
public AttributeQuery getAttributeQuery(final String _attributeName) { if (this.query == null) { try { final String attribute = getAttr4Select(_attributeName); this.query = new AttributeQuery(this.typeUUID, attribute.isEmpty() ? _attributeName : attribute) ...
java
protected AttributeQuery getAttributeQuery() throws EFapsException { AttributeQuery ret = this.getAttributeQuery(getSelectAttributeName()); // check if in the linkto chain is one before this one if (!this.attrQueryBldrs.isEmpty()) { final QueryBuilder queryBldr = this.att...
java
private void prepareQuery() throws EFapsException { for (final QueryBuilder queryBldr : this.attrQueryBldrs.values()) { final AttributeQuery attrQuery = queryBldr.getAttributeQuery(); this.addWhereAttrInQuery(queryBldr.getLinkAttributeName(), attrQuery); } if...
java
public CachedMultiPrintQuery getCachedPrint(final String _key) throws EFapsException { return new CachedMultiPrintQuery(getCachedQuery(_key).execute(), _key); }
java
public static AbstractQPart getQPart(final AbstractWhere _where) throws EFapsException { AbstractQPart ret = null; if (_where instanceof SelectWhere) { switch (_where.getComparison()) { case EQUAL: final QueryBuilder queryBldr = new QueryBuilde...
java