code
stringlengths
73
34.1k
label
stringclasses
1 value
ComapiConfig buildComapiConfig() { return new ComapiConfig() .apiSpaceId(apiSpaceId) .authenticator(authenticator) .logConfig(logConfig) .apiConfiguration(apiConfig) .logSizeLimitKilobytes(logSizeLimit) .pushMessageL...
java
int matchLength(List<CharRange> prefix) { DFAState<T> state = this; int len = 0; for (CharRange range : prefix) { state = state.transit(range); if (state == null) { break; } len++; } ...
java
public int getTransitionSelectivity() { int count = 0; for (Transition<DFAState<T>> t : transitions.values()) { CharRange range = t.getCondition(); count += range.getTo()-range.getFrom(); } return count/transitions.size(); }
java
public boolean hasBoundaryMatches() { for (Transition<DFAState<T>> t : transitions.values()) { CharRange range = t.getCondition(); if (range.getFrom() < 0) { return true; } } return false; }
java
void optimizeTransitions() { HashMap<DFAState<T>,RangeSet> hml = new HashMap<>(); for (Transition<DFAState<T>> t : transitions.values()) { RangeSet rs = hml.get(t.getTo()); if (rs == null) { rs = new RangeSet(); hml...
java
RangeSet possibleMoves() { List<RangeSet> list = new ArrayList<>(); for (NFAState<T> nfa : nfaSet) { list.add(nfa.getConditions()); } return RangeSet.split(list); }
java
void removeDeadEndTransitions() { Iterator<CharRange> it = transitions.keySet().iterator(); while (it.hasNext()) { CharRange r = it.next(); if (transitions.get(r).getTo().isDeadEnd()) { it.remove(); } } }
java
boolean isDeadEnd() { if (isAccepting()) { return false; } for (Transition<DFAState<T>> next : transitions.values()) { if (next.getTo() != this) { return false; } } return true; ...
java
Set<NFAState<T>> nfaTransitsFor(CharRange condition) { Set<NFAState<T>> nset = new NumSet<>(); for (NFAState<T> nfa : nfaSet) { nset.addAll(nfa.transit(condition)); } return nset; }
java
void addTransition(CharRange condition, DFAState<T> to) { Transition<DFAState<T>> t = new Transition<>(condition, this, to); t = transitions.put(t.getCondition(), t); assert t == null; edges.add(to); to.inStates.add(this); }
java
private void load() throws EFapsException { final QueryBuilder queryBldr = new QueryBuilder(CIAdminCommon.MsgPhraseConfigAbstract); queryBldr.addWhereAttrEqValue(CIAdminCommon.MsgPhraseConfigAbstract.AbstractLink, getId()); final MultiPrintQuery multi = queryBldr.getPrint(); ...
java
void processBatchWaitTasks() { Channel channel = context.registry.getChannelOrSystem(Model.CHANNEL_BATCH); // channel TedBW or TedSS int maxTask = context.taskManager.calcChannelBufferFree(channel); Map<String, Integer> channelSizes = new HashMap<String, Integer>(); channelSizes.put(Model.CHANNEL_BATCH, maxTask...
java
public boolean send(Whisper<?> whisper) { if (isShutdown.get()) return false; // Internal Queue (Local Thread) for INPLACE multiple recursive calls final ArrayDeque<Whisper<?>> localQueue = ref.get(); if (!localQueue.isEmpty()) { localQueue.addLast(whisper); return true; } localQueue.addLast(whispe...
java
public void shutdown() { singleton = null; log.info("Shuting down GossipMonger"); isShutdown.set(true); threadPool.shutdown(); // Disable new tasks from being submitted // TODO: Wait for messages to end processing shutdownAndAwaitTermination(threadPool); // Clean ThreadLocal ref.remove(); }
java
public RegexMatcher addExpression(String expr, T attach, Option... options) { if (nfa == null) { nfa = parser.createNFA(nfaScope, expr, attach, options); } else { NFA<T> nfa2 = parser.createNFA(nfaScope, expr, attach, options); nfa...
java
public T match(CharSequence text, boolean matchPrefix) { if (root == null) { throw new IllegalStateException("not compiled"); } int length = text.length(); for (int ii=0;ii<length;ii++) { switch (match(text.charAt(ii))) { ...
java
public T match(OfInt text) { if (root == null) { throw new IllegalStateException("not compiled"); } while (text.hasNext()) { switch (match(text.nextInt())) { case Error: return null; ...
java
public static Stream<CharSequence> split(CharSequence seq, String regex, Option... options) { return StreamSupport.stream(new SpliteratorImpl(seq, regex, options), false); }
java
public boolean checkAndIncrease() { long newTimestamp = System.currentTimeMillis(); if (isShutdown) { if (newTimestamp > shutdownEndTime) { isShutdown = false; largeLimitCalls = 0; smallLimitCalls = 0; } else { ret...
java
public static Method findMethod(String name, Class<?> cls) { for(Method method : cls.getDeclaredMethods()) { if(method.getName().equals(name)) { return method; } } throw new ExecutionException("invalid auto-function: no '" + name + "' method declared", null); }
java
public static Object exec(Method method, String[] paramNames, Map<String,?> params, Object instance) throws Throwable { Object[] paramValues = new Object[paramNames.length]; for(int c=0; c < paramNames.length; ++c) { paramValues[c] = params.get(paramNames[c]); } try { return metho...
java
protected void setLinkProperty(final UUID _linkTypeUUID, final long _toId, final UUID _toTypeUUID, final String _toName) throws EFapsException { setDirty(); }
java
public void addEvent(final EventType _eventtype, final EventDefinition _eventdef) throws CacheReloadException { List<EventDefinition> evenList = this.events.get(_eventtype); if (evenList == null) { evenList = new ArrayList<>(); this.events.put...
java
public List<EventDefinition> getEvents(final EventType _eventType) { if (!this.eventChecked) { this.eventChecked = true; try { EventDefinition.addEvents(this); } catch (final EFapsException e) { AbstractAdminObject.LOG.error("Could not read...
java
public boolean hasEvents(final EventType _eventtype) { if (!this.eventChecked) { this.eventChecked = true; try { EventDefinition.addEvents(this); } catch (final EFapsException e) { AbstractAdminObject.LOG.error("Could not read events for Na...
java
public Object call(Map<String, ?> params) throws Throwable { return AnnotatedExtensions.exec(getCallMethod(), getParameterNames(), params, this); }
java
private Long getLanguageId(final String _language) { Long ret = null; try { final QueryBuilder queryBldr = new QueryBuilder(CIAdmin.Language); queryBldr.addWhereAttrEqValue(CIAdmin.Language.Language, _language); final InstanceQuery query = queryBldr.getQuery(); ...
java
private long insertNewLanguage(final String _language) { Long ret = null; try { final Insert insert = new Insert(CIAdmin.Language); insert.add(CIAdmin.Language.Language, _language); insert.executeWithoutAccessCheck(); ret = insert.getId(); ...
java
private Instance insertNewBundle() { Instance ret = null; try { final Insert insert = new Insert(DBPropertiesUpdate.TYPE_PROPERTIES_BUNDLE); insert.add("Name", this.bundlename); insert.add("UUID", this.bundeluuid); insert.add("Sequence", this.bundleseq...
java
private void importFromProperties(final URL _url) { try { final InputStream propInFile = _url.openStream(); final Properties props = new Properties(); props.load(propInFile); final Iterator<Entry<Object, Object>> iter = props.entrySet().iterator(); ...
java
private Instance getExistingLocale(final long _propertyid, final String _language) { Instance ret = null; try { final QueryBuilder queryBldr = new QueryBuilder(Type.get(DBPropertiesUpdate.TYPE_PROPERTIES_LOCAL)); queryBldr.addWhereAttrEq...
java
private void insertNewLocal(final long _propertyid, final String _value, final String _language) { try { final Insert insert = new Insert(DBPropertiesUpdate.TYPE_PROPERTIES_LOCAL); insert.add("Value", _value); ...
java
private void updateLocale(final Instance _localeInst, final String _value) { try { final Update update = new Update(_localeInst); update.add("Value", _value); update.execute(); } catch (final EFapsException e) { DBProperti...
java
private Instance getExistingKey(final String _key) { Instance ret = null; try { final QueryBuilder queryBldr = new QueryBuilder(Type.get(DBPropertiesUpdate.TYPE_PROPERTIES)); queryBldr.addWhereAttrEqValue("Key", _key); queryBldr.addWhereAttrEqValue("BundleID", thi...
java
private void updateDefault(final Instance _inst, final String _value) { try { final Update update = new Update(_inst); update.add("Default", _value); update.execute(); } catch (final EFapsException e) { DBPropertiesUpdate...
java
private Instance insertNewProp(final String _key, final String _value) { Instance ret = null; try { final Insert insert = new Insert(DBPropertiesUpdate.TYPE_PROPERTIES); insert.add("BundleID", this.bundleInstance); insert.add("Key"...
java
private Instance getExistingBundle(final String _uuid) { Instance ret = null; try { final QueryBuilder queryBldr = new QueryBuilder(Type.get(DBPropertiesUpdate.TYPE_PROPERTIES_BUNDLE)); queryBldr.addWhereAttrEqValue("UUID", _uuid); final InstanceQuery query = quer...
java
public boolean setPassword(final String _name, final String _newpasswd, final String _oldpasswd) throws LoginException { boolean ret = false; final LoginContext login = new LoginContext( this.application, ...
java
@Action(invokeOn = InvokeOn.OBJECT_AND_COLLECTION) @ActionLayout( describedAs = "Toggle, for testing (direct) bulk actions" ) public void toggleForBulkActions() { boolean flag = getFlag() != null? getFlag(): false; setFlag(!flag); }
java
public boolean addMeasureToVerb(Map<String, Object> properties) { String[] pathKeys = {"verb"}; return addChild("measure", properties, pathKeys); }
java
public boolean addMeasureToVerb(String measureType, Number value, Number scaleMin, Number scaleMax, Number sampleSize) { Map<String, Object> container = new HashMap<String, Object>(); if (measureType != null) { container.put("measureType", measureType); } ...
java
public boolean addContextToVerb(String objectType, String id, String description) { Map<String, Object> container = new HashMap<String, Object>(); if (objectType != null) { container.put("objectType", objectType); } if (id != null) { c...
java
public boolean addVerb(String action, Date dateStart, Date dateEnd, String[] description, String comment) { Map<String, Object> container = new HashMap<String, Object>(); if (action != null) { container.put("action", action); } else { ...
java
public boolean addActor(String objectType, String displayName, String url, String[] description) { Map<String, Object> container = new HashMap<String, Object>(); if (objectType != null) { container.put("objectType", objectType); } else { r...
java
public boolean addObject(String objectType, String id, String content) { Map<String, Object> container = new HashMap<String, Object>(); if (objectType != null) { container.put("objectType", objectType); } if (id != null) { container.pu...
java
public boolean addRelatedObject(String objectType, String id, String content) { Map<String, Object> container = new HashMap<String, Object>(); if (objectType != null) { container.put("objectType", objectType); } else { return false; ...
java
private Map<String, Object> getMap(String[] pathKeys) { if (pathKeys == null) { return (Map<String, Object>)resourceData; } Map<String, Object> selected = (Map<String, Object>)resourceData; for(int i = 0; i < pathKeys.length; i++) { ...
java
private boolean addChild(String name, Object value, String[] pathKeys) { Map<String, Object> selected = (Map<String, Object>)resourceData; if (pathKeys != null) { selected = getMap(pathKeys); } if (selected != null && !selected.containsKey(name))...
java
public void process(TemplateImpl template, Writer out) throws IOException { Environment env = new Environment(template.getPath(), out); currentScope.declaringEnvironment = env; Environment prevEnv = switchEnvironment(env); TemplateContext tmpl = template.getContext(); HeaderContext hdr = ...
java
private TemplateImpl load(String path, ParserRuleContext errCtx) { path = Paths.resolvePath(currentEnvironment.path, path); try { return (TemplateImpl) engine.load(path); } catch (IOException | ParseException e) { throw new ExecutionException("error importing " + path, e, getLocation(err...
java
private Environment switchEnvironment(Environment env) { Environment prev = currentEnvironment; currentEnvironment = env; return prev; }
java
private Scope switchScope(Scope scope) { Scope prev = currentScope; currentScope = scope; return prev; }
java
private Map<String, Object> bindBlocks(PrepareSignatureContext sig, PrepareInvocationContext inv) { if(inv == null) { return Collections.emptyMap(); } BlockDeclContext allDecl = null; BlockDeclContext unnamedDecl = null; List<NamedOutputBlockContext> namedBlocks = new ArrayList<>(in...
java
private NamedOutputBlockContext findAndRemoveBlock(List<NamedOutputBlockContext> blocks, String name) { if(blocks == null) { return null; } Iterator<NamedOutputBlockContext> blockIter = blocks.iterator(); while (blockIter.hasNext()) { NamedOutputBlockContext block = blockIter.next(); ...
java
private ExpressionContext findAndRemoveValue(List<NamedValueContext> namedValues, String name) { Iterator<NamedValueContext> namedValueIter = namedValues.iterator(); while (namedValueIter.hasNext()) { NamedValueContext namedValue = namedValueIter.next(); if (name.equals(value(namedValue.name)))...
java
private Object eval(ExpressionContext expr) { Object res = expr; while(res instanceof ExpressionContext) res = ((ExpressionContext)res).accept(visitor); if(res instanceof LValue) res = ((LValue) res).get(expr); return res; }
java
private List<Object> eval(Iterable<ExpressionContext> expressions) { List<Object> results = new ArrayList<Object>(); for (ExpressionContext expression : expressions) { results.add(eval(expression)); } return results; }
java
private Object exec(StatementContext statement) { if (statement == null) return null; return statement.accept(visitor); }
java
ExecutionLocation getLocation(ParserRuleContext object) { Token start = object.getStart(); return new ExecutionLocation(currentScope.declaringEnvironment.path, start.getLine(), start.getCharPositionInLine() + 1); }
java
public T find(String text) { T match = matcher.match(text, true); if (match != null) { String name = match.name(); if (name.substring(0, Math.min(name.length(), text.length())).equalsIgnoreCase(text)) { return match; } ...
java
public static void stop() throws EFapsException { for (final QueueConnection queCon : JmsHandler.QUEUE2QUECONN.values()) { try { queCon.close(); } catch (final JMSException e) { throw new EFapsException("JMSException", e); } ...
java
public static String getTimeoutMessage(long timeout, TimeUnit unit) { return String.format("Timeout of %d %s reached", timeout, requireNonNull(unit, "unit")); }
java
protected void checkAccess() throws EFapsException { for (final Instance instance : getInstances()) { if (!instance.getType().hasAccess(instance, AccessTypeEnums.DELETE.getAccessType(), null)) { LOG.error("Delete not permitted for Person: {} on Instance: {}", Context.getT...
java
public void set(double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ) { this.eyeX = eyeX; this.eyeY = eyeY; this.eyeZ = eyeZ; this.centerX = centerX; this.centerY = centerY; ...
java
public void setEye(double eyeX, double eyeY, double eyeZ) { this.eyeX = eyeX; this.eyeY = eyeY; this.eyeZ = eyeZ; }
java
public void setCenter(double centerX, double centerY, double centerZ) { this.centerX = centerX; this.centerY = centerY; this.centerZ = centerZ; }
java
public void setOrientation(double upX, double upY, double upZ) { this.upX = upX; this.upY = upY; this.upZ = upZ; }
java
public double[] getCameraDirection() { double[] cameraDirection = new double[3]; double l = Math.sqrt(Math.pow(this.eyeX - this.centerX, 2.0) + Math.pow(this.eyeZ - this.centerZ, 2.0) + Math.pow(this.eyeZ - this.centerZ, 2.0)); cameraDirection[0] = (this.centerX - this.eyeX) / l; cameraD...
java
protected boolean hasAccess() throws EFapsException { //Admin_REST return Context.getThreadContext().getPerson().isAssigned(Role.get( UUID.fromString("2d142645-140d-46ad-af67-835161a8d732"))); }
java
protected String getJSONReply(final Object _jsonObject) { String ret = ""; final ObjectMapper mapper = new ObjectMapper(); if (LOG.isDebugEnabled()) { mapper.enable(SerializationFeature.INDENT_OUTPUT); } mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTA...
java
public static String login(final String _userName, final String _passwd, final String _applicationKey) throws EFapsException { String ret = null; if (JmsSession.checkLogin(_userName, _passwd, _applicationKey)) { final ...
java
void update(long index, int b) { if (size > 0) { assert index <= hi; if (index < lo) { throw new IllegalStateException("lookaheadLength() too small in ChecksumProvider implementation"); } hi = index; if...
java
public void execute() throws InstallationException { Instance instance = searchInstance(); if (instance == null) { instance = createInstance(); } updateDB(instance); }
java
protected Instance createInstance() throws InstallationException { final Insert insert; try { insert = new Insert(getCiType()); insert.add("Name", this.programName); if (getEFapsUUID() != null) { insert.add("UUID", getEFapsUUID().toString()...
java
public void updateDB(final Instance _instance) throws InstallationException { try { final InputStream is = newCodeInputStream(); final Checkin checkin = new Checkin(_instance); checkin.executeWithoutAccessCheck(getProgramName(), is, is.available()); } catc...
java
public static void startup(final String _classDBType, final String _classDSFactory, final String _propConnection, final String _classTM, final String _classTSR, fina...
java
protected static void configureEFapsProperties(final Context _compCtx, final Map<String, String> _eFapsProps) throws StartupException { try { Util.bind(_compCtx, "env/" + INamingBinds.RESOURCE_CONFIGPROPERTIES, _eFapsProps); } ca...
java
public static void shutdown() throws StartupException { final Context compCtx; try { final InitialContext context = new InitialContext(); compCtx = (javax.naming.Context) context.lookup("java:comp"); } catch (final NamingException e) { throw new St...
java
@SuppressWarnings("unchecked") public STMT columnWithCurrentTimestamp(final String _columnName) { this.columnWithSQLValues.add( new AbstractSQLInsertUpdate.ColumnWithSQLValue(_columnName, Context.getDbType().getCurrentTimeSta...
java
public static EQLInvoker getInvoker() { final EQLInvoker ret = new EQLInvoker() { @Override protected AbstractPrintStmt getPrint() { return new PrintStmt(); } @Override protected AbstractInsertStmt getInsert() ...
java
public void append2SQLSelect(final SQLSelect _sqlSelect) { if (iWhere != null) { final SQLWhere sqlWhere = _sqlSelect.getWhere(); for (final IWhereTerm<?> term : iWhere.getTerms()) { if (term instanceof IWhereElementTerm) { final IWhereElement elem...
java
void init() { if (! isEnabled()) { loggerConfig.info("Ted prime instance check is disabled"); return; } this.primeTaskId = context.tedDaoExt.findPrimeTaskId(); int periodMs = context.config.intervalDriverMs(); this.postponeSec = (int)Math.round((1.0 * periodMs * TICK_SKIP_COUNT + 500 + 500) / 1000); //...
java
@Override public TemplateSource find(String path) throws IOException { return new URLTemplateSource(new URL("file", null, path)); }
java
public static void initialize() throws CacheReloadException { if (InfinispanCache.get().exists(BundleMaker.NAMECACHE)) { InfinispanCache.get().<UUID, Type>getCache(BundleMaker.NAMECACHE).clear(); InfinispanCache.get().<UUID, Type>getCache(BundleMaker.CACHE4BUNDLE).clear(); ...
java
public static boolean containsKey(final String _key) { final Cache<String, BundleInterface> cache = InfinispanCache.get() .<String, BundleInterface>getIgnReCache(BundleMaker.CACHE4BUNDLE); return cache.containsKey(_key); }
java
private static String createNewKey(final List<String> _names, final Class<?> _bundleclass) throws EFapsException { final StringBuilder builder = new StringBuilder(); final List<String> oids = new ArrayList<>(); String ret = null; try { ...
java
public static void init(final String _runLevel) throws EFapsException { RunLevel.ALL_RUNLEVELS.clear(); RunLevel.RUNLEVEL = new RunLevel(_runLevel); }
java
private List<String> getAllInitializers() { final List<String> ret = new ArrayList<>(); for (final CacheMethod cacheMethod : this.cacheMethods) { ret.add(cacheMethod.className); } if (this.parent != null) { ret.addAll(this.parent.getAllInitializers()); ...
java
protected void initialize(final String _sql) throws EFapsException { Connection con = null; try { con = Context.getConnection(); Statement stmt = null; long parentId = 0; try { stmt = con.createStatement(); // r...
java
static Integer getInteger(Properties properties, String key, Integer defaultValue) { if (properties == null) return defaultValue; String value = properties.getProperty(key); if (value == null || value.isEmpty()) return defaultValue; int intVal; try { intVal = Integer.parseInt(value); } catch (Numbe...
java
public void execute(T target) throws Throwable { try { for (Invokation invokation : queue) { invokation.invoke(target); } } catch (InvocationTargetException ex) { throw ex.getCause(); } catch (Ref...
java
protected Map<String, Object> getSignableData() { final Map<String, Object> doc = getSendableData(); // remove node-specific data for (int i = 0; i < excludedFields.length; i++) { doc.remove(excludedFields[i]); } return doc; }
java
protected Map<String, Object> getSendableData() { Map<String, Object> doc = new LinkedHashMap<String, Object>(); MapUtil.put(doc, docTypeField, docType); MapUtil.put(doc, docVersionField, docVersion); MapUtil.put(doc, activeField, true); MapUtil.put(doc, resourceDataTypeFiel...
java
public void addSigningData(String signingMethod, String publicKeyLocation, String clearSignedMessage) { this.signingMethod = signingMethod; this.publicKeyLocation = publicKeyLocation; this.clearSignedMessage = clearSignedMessage; this.signed = true; }
java
public String getUrl(String email) { if (email == null) { throw new IllegalArgumentException("Email can't be null."); } String emailHash = DigestUtils.md5Hex(email.trim().toLowerCase()); boolean firstParameter = true; // StringBuilder standard capacity is 16 charact...
java
private void setProperties(final Instance _instance) throws EFapsException { final QueryBuilder queryBldr = new QueryBuilder(CIAdminCommon.Property); queryBldr.addWhereAttrEqValue(CIAdminCommon.Property.Abstract, _instance.getId()); final MultiPrintQuery multi = queryBldr.getPrint();...
java
private void checkProgramInstance() { try { if (EventDefinition.LOG.isDebugEnabled()) { EventDefinition.LOG.debug("checking Instance: {} - {}", this.resourceName, this.methodName); } if (!EFapsClassLoader.getInstance().isOffline()) { final ...
java
@Override public Return execute(final Parameter _parameter) throws EFapsException { Return ret = null; _parameter.put(ParameterValues.PROPERTIES, new HashMap<>(super.evalProperties())); try { EventDefinition.LOG.debug("Invoking method '{}' for Resource '{}'", this.met...
java
public String getOid() { String ret = null; if (isValid()) { ret = getType().getId() + "." + getId(); } return ret; }
java
public boolean checkEventId(String conversationId, long conversationEventId, MissingEventsListener missingEventsListener) { if (!idsPerConversation.containsKey(conversationId)) { TreeSet<Long> ids = new TreeSet<>(); boolean added = ids.add(conversationEventId); idsPerConvers...
java