code
stringlengths
73
34.1k
label
stringclasses
1 value
public static <G, B> Bad<G, B> of(B value) { return new Bad<>(value); }
java
public LREnvelope sign(LREnvelope envelope) throws LRException { // Bencode the document String bencodedMessage = bencode(envelope.getSignableData()); // Clear sign the bencoded document String clearSignedMessage = signEnvelopeData(bencodedMessage); envelope.addSigningData(...
java
private List<Object> normalizeList(List<Object> list) { List<Object> result = new ArrayList<Object>(); for (Object o : list) { if (o == null) { result.add(nullLiteral); } else if (o instanceof Boolean) { result.add(((Boolean) o).toString()); } else if (o instanceof List<?>) { ...
java
private String signEnvelopeData(String message) throws LRException { // Throw an exception if any of the required fields are null if (passPhrase == null || publicKeyLocation == null || privateKey == null) { throw new LRException(LRException.NULL_FIELD); } // Get ...
java
private PGPSecretKey readSecretKey(InputStream input) throws LRException { PGPSecretKeyRingCollection pgpSec; try { pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(input)); } catch (Exception e) { throw new LRException(LRExcep...
java
private InputStream getPrivateKeyStream(String privateKey) throws LRException { try { // If the private key matches the form of a private key string, treat it as such if (privateKey.matches(pgpRegex)) { return new ByteArrayInputStream(privateKey.ge...
java
@Override public void include(Readable in, String source) throws IOException { if (cursor != end) { release(); } if (includeStack == null) { includeStack = new ArrayDeque<>(); } includeStack.push(includeLevel); i...
java
private static Set<Type> getChildTypes(final Type _type) throws CacheReloadException { final Set<Type> ret = new HashSet<Type>(); ret.add(_type); for (final Type child : _type.getChildTypes()) { ret.addAll(getChildTypes(child)); } return ret; }
java
public Criteria addCriteria(final int _idx, final List<String> _sqlColNames, final Comparison _comparison, final Set<String> _values, final boolean _escape, final Connection _connection) { final Criteria criteria = new Criteria() .tableIndex(_idx) ...
java
protected void appendSQL(final String _tablePrefix, final StringBuilder _cmd) { if (sections.size() > 0) { if (isStarted()) { new SQLSelectPart(SQLPart.AND).appendSQL(_cmd); new SQLSelectPart(SQLPart.SPACE).appendSQL(_cmd); ...
java
public static InetAddress getInetAddress(Config config, String path) { try { return InetAddress.getByName(config.getString(path)); } catch (UnknownHostException e) { throw badValue(e, config, path); } }
java
public static NetworkInterface getNetworkInterface(Config config, String path) { NetworkInterface value = getNetworkInterfaceByName(config, path); if (value == null) value = getNetworkInterfaceByInetAddress(config, path); if (value == null) throw badValue("No network int...
java
public static int getPort(Config config, String path) { try { return new InetSocketAddress(config.getInt(path)).getPort(); } catch (IllegalArgumentException e) { throw badValue(e, config, path); } }
java
public List<ChatMessageStatus> adaptEvents(List<DbOrphanedEvent> dbOrphanedEvents) { List<ChatMessageStatus> statuses = new ArrayList<>(); Parser parser = new Parser(); for (DbOrphanedEvent event : dbOrphanedEvents) { OrphanedEvent orphanedEvent = parser.parse(event.event(), Orphan...
java
public List<ChatMessage> adaptMessages(List<MessageReceived> messagesReceived) { List<ChatMessage> chatMessages = new ArrayList<>(); if (messagesReceived != null) { for (MessageReceived msg : messagesReceived) { ChatMessage adaptedMessage = ChatMessage.builder().populate(m...
java
public List<ChatMessageStatus> adaptStatuses(String conversationId, String messageId, Map<String, MessageReceived.Status> statuses) { List<ChatMessageStatus> adapted = new ArrayList<>(); for (String key : statuses.keySet()) { MessageReceived.Status status = statuses.get(key); ada...
java
public List<ChatParticipant> adapt(List<Participant> participants) { List<ChatParticipant> result = new ArrayList<>(); if (participants != null && !participants.isEmpty()) { for (Participant p : participants) { result.add(ChatParticipant.builder().populate(p).build()); ...
java
private final void setColor(ColorSet colorSet) { int[] rgb = ColorSet.getRGB(colorSet); this.red = rgb[0] / 255.0; this.green = rgb[1] / 255.0; this.blue = rgb[2] / 255.0; }
java
public static void shutDown() { if (Quartz.QUARTZ != null && Quartz.QUARTZ.scheduler != null) { try { Quartz.QUARTZ.scheduler.shutdown(); } catch (final SchedulerException e) { Quartz.LOG.error("Problems on shutdown of QuartsSheduler", e); ...
java
public static GenClassCompiler compile(TypeElement superClass, ProcessingEnvironment env) throws IOException { GenClassCompiler compiler; GrammarDef grammarDef = superClass.getAnnotation(GrammarDef.class); if (grammarDef != null) { compiler = new ParserCompiler(supe...
java
private synchronized boolean refreshAuthToken(final AuthHandler handler, final boolean forceRefresh) { if (handler == null) { return false; } AuthToken token = authToken.get(); if (!forceRefresh && token != null && token.is...
java
public PropertyDescriptor getPropertyDescriptor(String propertyName) { final PropertyDescriptor propertyDescriptor = findPropertyDescriptor(propertyName); if (propertyDescriptor == null) { throw new PropertyNotFoundException(beanClass, propertyName); } return propertyDe...
java
public PropertyDescriptor findPropertyDescriptor(String propertyName) { for (PropertyDescriptor property : propertyDescriptors) { if (property.getName().equals(propertyName)) { return property; } } return null; }
java
public boolean isAssigendTo(final Company _company) throws CacheReloadException { final boolean ret; if (isRoot()) { ret = this.companies.isEmpty() ? true : this.companies.contains(_company); } else { ret = getParentClassification().isAssigendTo(_company); ...
java
private void overrideAbstractMethods() throws IOException { for (final ExecutableElement method : El.getEffectiveMethods(superClass)) { if (method.getModifiers().contains(Modifier.ABSTRACT)) { if ( method.getAnnotation(Terminal.c...
java
private void init() { this.container = InfinispanCache.findCacheContainer(); if (this.container == null) { try { this.container = new DefaultCacheManager(this.getClass().getResourceAsStream( "/org/efaps/util/cache/infinispan-config.xml")); ...
java
private void terminate() { if (this.container != null) { final Cache<String, Integer> cache = this.container .<String, Integer>getCache(InfinispanCache.COUNTERCACHE); Integer count = cache.get(InfinispanCache.COUNTERCACHE); if (count == null ||...
java
public <K, V> AdvancedCache<K, V> getIgnReCache(final String _cacheName) { return this.container.<K, V>getCache(_cacheName, true).getAdvancedCache() .withFlags(Flag.IGNORE_RETURN_VALUES, Flag.SKIP_REMOTE_LOOKUP, Flag.SKIP_CACHE_LOAD); }
java
public <K, V> Cache<K, V> initCache(final String _cacheName) { if (!exists(_cacheName) && ((EmbeddedCacheManager) getContainer()).getCacheConfiguration(_cacheName) == null) { ((EmbeddedCacheManager) getContainer()).defineConfiguration(_cacheName, "eFaps-Default", ...
java
public static FacetsConfig getFacetsConfig() { final FacetsConfig ret = new FacetsConfig(); ret.setHierarchical(Indexer.Dimension.DIMCREATED.name(), true); return ret; }
java
public static Analyzer getAnalyzer() throws EFapsException { IAnalyzerProvider provider = null; if (EFapsSystemConfiguration.get().containsAttributeValue(KernelSettings.INDEXANALYZERPROVCLASS)) { final String clazzname = EFapsSystemConfiguration.get().getAttributeValue( ...
java
@CallMethod(pattern = "install/version/script") public void addScript(@CallParam(pattern = "install/version/script") final String _code, @CallParam(pattern = "install/version/script", attributeName = "type") final String _type, @CallParam(pattern = "install/versio...
java
@CallMethod(pattern = "install/version/description") public void appendDescription(@CallParam(pattern = "install/version/description") final String _desc) { if (_desc != null) { this.description.append(_desc.trim()).append("\n"); } }
java
@CallMethod(pattern = "install/version/lifecyle/ignore") public void addIgnoredStep(@CallParam(pattern = "install/version/lifecyle/ignore", attributeName = "step") final String _step) { this.ignoredSteps.add(UpdateLifecycle.valueOf(_step.toUpperCase())); }
java
@Override protected void freeResource() throws EFapsException { try { if (!getConnection().isClosed()) { getConnection().close(); } } catch (final SQLException e) { throw new EFapsException("Could not close", e); } }
java
public static <K, V> Configuration newMutable(TimeUnit expiryTimeUnit, long expiryDurationAmount) { return new MutableConfiguration<K, V>().setExpiryPolicyFactory(factoryOf(new Duration(expiryTimeUnit, expiryDurationAmount))); }
java
public boolean next() throws EFapsException { initialize(false); boolean stepForward = true; boolean ret = true; while (stepForward && ret) { ret = step(this.selection.getAllSelects()); stepForward = !this.access.hasAccess(inst()); } re...
java
private boolean step(final Collection<Select> _selects) { boolean ret = !CollectionUtils.isEmpty(_selects); for (final Select select : _selects) { ret = ret && select.next(); } return ret; }
java
private void evalAccess() throws EFapsException { final List<Instance> instances = new ArrayList<>(); while (step(this.selection.getInstSelects().values())) { for (final Entry<String, Select> entry : this.selection.getInstSelects().entrySet()) { final Object objec...
java
public DataList getDataList() throws EFapsException { final DataList ret = new DataList(); while (next()) { final ObjectData data = new ObjectData(); int idx = 1; for (final Select select : this.selection.getSelects()) { final String key = ...
java
protected String makeInfo() { final StringBuilder str = new StringBuilder(); if (this.className != null) { str.append("Thrown within class ").append(this.className.getName()).append('\n'); } if (this.id != null) { str.append("Id of Exception is ").append(thi...
java
private static String getValueFromDB(final String _key, final String _language) { String ret = null; try { boolean closeContext = false; if (!Context.isThreadActive()) { Context.begin(); closeContext = t...
java
private static void cacheOnStart() { try { boolean closeContext = false; if (!Context.isThreadActive()) { Context.begin(); closeContext = true; } Context.getThreadContext(); final Connection con = Context.getConnecti...
java
public static void initialize() { if (InfinispanCache.get().exists(DBProperties.CACHENAME)) { InfinispanCache.get().<String, String>getCache(DBProperties.CACHENAME).clear(); } else { InfinispanCache.get().<String, String>getCache(DBProperties.CACHENAME) ...
java
public static int getReadCount(final Long _userId) { int ret = 0; if (MessageStatusHolder.CACHE.userID2Read.containsKey(_userId)) { ret = MessageStatusHolder.CACHE.userID2Read.get(_userId); } return ret; }
java
public static int getUnReadCount(final Long _userId) { int ret = 0; if (MessageStatusHolder.CACHE.userID2UnRead.containsKey(_userId)) { ret = MessageStatusHolder.CACHE.userID2UnRead.get(_userId); } return ret; }
java
public void setNode(int number, Vector3D v) { setNode(number, v.getX(), v.getY(), v.getZ()); }
java
public void setAnchorColor(int index, Color color) { if (index <= 0) { if (startColor == null) { startColor = new RGBColor(0.0, 0.0, 0.0); } setGradation(true); this.startColor = color; } else if (index >= 1) { if (endColor == n...
java
public final double getWidth(int line) { if (strArray.length == 0) return 0.0; try { return textRenderer.getBounds(strArray[line]).getWidth(); } catch (GLException e) { reset = true; } return 0.0; }
java
public final void setFont(Font font) { this.font = font; textRenderer = new TextRenderer(font.getAWTFont(), true, true); }
java
public static PermissionSet getPermissionSet(final Instance _instance) throws EFapsException { Evaluation.LOG.debug("Evaluation PermissionSet for {}", _instance); final Key accessKey = Key.get4Instance(_instance); final PermissionSet ret = AccessCache.getPermissionCache().get(accessK...
java
public static PermissionSet getPermissionSet(final Instance _instance, final boolean _evaluate) throws EFapsException { Evaluation.LOG.debug("Retrieving PermissionSet for {}", _instance); final Key accessKey = Key.get4Instance(_instance); ...
java
public static Status getStatus(final Instance _instance) throws EFapsException { Evaluation.LOG.debug("Retrieving Status for {}", _instance); long statusId = 0; if (_instance.getType().isCheckStatus()) { final Cache<String, Long> cache = AccessCache.getStatusCache(); ...
java
public static void evalStatus(final Collection<Instance> _instances) throws EFapsException { Evaluation.LOG.debug("Evaluating Status for {}", _instances); if (CollectionUtils.isNotEmpty(_instances)) { final Cache<String, Long> cache = AccessCache.getStatusCache(); fin...
java
public static String addZerosBefore(String orderNo, int count) { if (orderNo == null) { return "";// orderNo = ""; } if (orderNo.length() > count) { orderNo = "?" + orderNo.substring(orderNo.length() - count - 1, orderNo.length() - 1); } else { ...
java
public Map<String, Set<DataPoint>> getSeries() { return new HashMap<String, Set<DataPoint>>(store); }
java
public void addDataPoint(String series, DataPoint dataPoint) { DataSet set = store.get(series); if (set == null) { set = new DataSet(); store.put(series, set); } set.add(dataPoint); }
java
public void addDataPointSet(String series, Set<DataPoint> dataPoints) { DataSet set = store.get(series); if (set == null) { set = new DataSet(dataPoints); store.put(series, set); } else { set.addAll(dataPoints); } }
java
public JSONObject serialize(Map<String, Object> out) { JSONObject json = new JSONObject(); json.put("device_id", deviceId); json.put("project_id", projectId); out.put("device_id", deviceId); out.put("project_id", projectId); JSONArray sourcesArr = new JSONArray(); ...
java
public Vector3D getVertex(int index) { tmpV.setX(cornerX.get(index)); tmpV.setY(cornerY.get(index)); tmpV.setZ(cornerZ.get(index)); calcG(); return tmpV; }
java
public void removeVertex(int index) { this.cornerX.remove(index); this.cornerY.remove(index); this.cornerZ.remove(index); if (isGradation() == true) this.cornerColor.remove(index); setNumberOfCorner(this.cornerX.size()); calcG(); }
java
public void setVertex(int i, double x, double y, double z) { this.cornerX.set(i, x); this.cornerY.set(i, y); this.cornerZ.set(i, z); calcG(); }
java
public void setCornerColor(int index, Color color) { if (cornerColor == null) { for (int i = 0; i < cornerX.size(); i++) { cornerColor.add(new RGBColor(this.fillColor.getRed(), this.fillColor.getGreen(), this.fillColor.getBlue(), this.fillColor.getAlpha())); ...
java
public static List<DataPoint> parse(int[] values, long ts) { List<DataPoint> ret = new ArrayList<DataPoint>(values.length); for (int v : values) { ret.add(new DataPoint(ts, v)); } return ret; }
java
@SuppressWarnings("unchecked") @SafeVarargs public static <G, ERR> Or<G, Every<ERR>> when(Or<? extends G, ? extends Every<? extends ERR>> or, Function<? super G, ? extends Validation<ERR>>... validations) { return when(or, Stream.of(validations)); }
java
public static <A, B, ERR, RESULT> Or<RESULT, Every<ERR>> withGood( Or<? extends A, ? extends Every<? extends ERR>> a, Or<? extends B, ? extends Every<? extends ERR>> b, BiFunction<? super A, ? super B, ? extends RESULT> function) { if (allGood(a, b)) return Good.of(function.apply(a.get(), b.get())...
java
public Vector3D getVertex(int i) { tmpV.setX(x.get(i)); tmpV.setY(y.get(i)); tmpV.setZ(z.get(i)); calcG(); return tmpV; }
java
public void removeVertex(int i) { this.x.remove(i); this.y.remove(i); this.z.remove(i); this.colors.remove(i); calcG(); }
java
public void setVertex(int i, double x, double y) { this.x.set(i, x); this.y.set(i, y); this.z.set(i, 0d); calcG(); }
java
public void setStartCornerColor(Color color) { if (startColor == null) { startColor = new RGBColor(0.0, 0.0, 0.0); } setGradation(true); this.startColor = color; }
java
public void setEndCornerColor(Color color) { if (endColor == null) { endColor = new RGBColor(0.0, 0.0, 0.0); } setGradation(true); this.endColor = color; }
java
public void setCornerColor(int index, Color color) { if (!cornerGradation) { cornerGradation = true; } colors.set(index, color); }
java
public boolean hasTransitionTo(CharRange condition, NFAState<T> state) { Set<Transition<NFAState<T>>> set = transitions.get(condition); if (set != null) { for (Transition<NFAState<T>> tr : set) { if (state.equals(tr.getTo())) { ...
java
public RangeSet getConditionsTo(NFAState<T> state) { RangeSet rs = new RangeSet(); for (CharRange range : transitions.keySet()) { if (range != null) { Set<Transition<NFAState<T>>> set2 = transitions.get(range); for (Transition<N...
java
public static boolean isSingleEpsilonOnly(Set<Transition<NFAState>> set) { if (set.size() != 1) { return false; } for (Transition<NFAState> tr : set) { if (tr.isEpsilon()) { return true; } } ...
java
boolean isDeadEnd(Set<NFAState<T>> nfaSet) { for (Set<Transition<NFAState<T>>> set : transitions.values()) { for (Transition<NFAState<T>> t : set) { if (!nfaSet.contains(t.getTo())) { return false; }...
java
public DFAState<T> constructDFA(Scope<DFAState<T>> dfaScope) { Map<Set<NFAState<T>>,DFAState<T>> all = new HashMap<>(); Deque<DFAState<T>> unmarked = new ArrayDeque<>(); Set<NFAState<T>> startSet = epsilonClosure(dfaScope); DFAState<T> startDfa = new DFAState<>(dfaScope, startSe...
java
RangeSet getConditions() { RangeSet is = new RangeSet(); for (CharRange ic : transitions.keySet()) { if (ic != null) { is.add(ic); } } return is; }
java
private Set<NFAState<T>> epsilonTransitions(StateVisitSet<NFAState<T>> marked) { marked.add(this); Set<NFAState<T>> set = new HashSet<>(); for (NFAState<T> nfa : epsilonTransit()) { if (!marked.contains(nfa)) { set.add(nfa); ...
java
public Set<NFAState<T>> epsilonClosure(Scope<DFAState<T>> scope) { Set<NFAState<T>> set = new HashSet<>(); set.add(this); return epsilonClosure(scope, set); }
java
public void addTransition(RangeSet rs, NFAState<T> to) { for (CharRange c : rs) { addTransition(c, to); } edges.add(to); to.inStates.add(this); }
java
public Transition<NFAState<T>> addTransition(CharRange condition, NFAState<T> to) { Transition<NFAState<T>> t = new Transition<>(condition, this, to); Set<Transition<NFAState<T>>> set = transitions.get(t.getCondition()); if (set == null) { set = new HashSet<>(); ...
java
public void addEpsilon(NFAState<T> to) { Transition<NFAState<T>> t = new Transition<>(this, to); Set<Transition<NFAState<T>>> set = transitions.get(null); if (set == null) { set = new HashSet<>(); transitions.put(null, set); } set.add(...
java
public void addChildValueSelect(final AbstractValueSelect _valueSelect) throws EFapsException { if (this.child == null) { this.child = _valueSelect; _valueSelect.setParentValueSelect(this); } else { this.child.addChildValueSelect(_valueSelect); } ...
java
public Object getValue(final List<Object> _objectList) throws EFapsException { final List<Object> ret = new ArrayList<Object>(); for (final Object object : _objectList) { ret.add(getValue(object)); } return _objectList.size() > 0 ? (ret.size() > 1 ? ret : ret.get(...
java
private void preparePrint(final AbstractPrint _print) throws EFapsException { for (final Select select : _print.getSelection().getAllSelects()) { for (final AbstractElement<?> element : select.getElements()) { if (element instanceof AbstractDataElement) { ((Abstra...
java
private void addTypeCriteria(final QueryPrint _print) { final MultiValuedMap<TableIdx, TypeCriteria> typeCriterias = MultiMapUtils.newListValuedHashMap(); final List<Type> types = _print.getTypes().stream() .sorted((type1, type2) -> Long.compare(type1.getId(), type2.getId()))...
java
private void executeUpdates() throws EFapsException { ConnectionResource con = null; try { con = Context.getThreadContext().getConnectionResource(); for (final Entry<SQLTable, AbstractSQLInsertUpdate<?>> entry : updatemap.entrySet()) { ((SQLUpdate) ent...
java
@SuppressWarnings("unchecked") protected boolean executeSQLStmt(final ISelectionProvider _sqlProvider, final String _complStmt) throws EFapsException { SQLRunner.LOG.debug("SQL-Statement: {}", _complStmt); boolean ret = false; List<Object[]> rows = new ArrayList<>(); bo...
java
void processTedQueue() { int totalProcessing = context.taskManager.calcWaitingTaskCountInAllChannels(); if (totalProcessing >= TaskManager.LIMIT_TOTAL_WAIT_TASKS) { logger.warn("Total size of waiting tasks ({}) already exceeded limit ({}), skip this iteration (2)", totalProcessing, TaskManager.LIMIT_TOTAL_WAIT_T...
java
private void processEventQueue(final TaskRec head) { final TedResult headResult = processEvent(head); TaskConfig tc = context.registry.getTaskConfig(head.name); if (tc == null) { context.taskManager.handleUnknownTasks(asList(head)); return; } TaskRec lastUnsavedEvent = null; TedResult lastUnsavedResu...
java
static public String[] getAllProperties() { java.util.Properties prop = System.getProperties(); java.util.ArrayList<String> list = new java.util.ArrayList<String>(); java.util.Enumeration<?> enumeration = prop.propertyNames(); while (enumeration.hasMoreElements()) { list.add(...
java
public void set(double fov, double aspect, double zNear, double zFar) { this.fov = fov; this.aspect = aspect; this.zNear = zNear; this.zFar = zFar; }
java
public static List<CharRange> removeOverlap(CharRange r1, CharRange r2) { assert r1.intersect(r2); List<CharRange> list = new ArrayList<CharRange>(); Set<Integer> set = new TreeSet<Integer>(); set.add(r1.getFrom()); set.add(r1.getTo()); set.add(r2.getFrom()); ...
java
public String getHrefResolved() { if (Atom10Parser.isAbsoluteURI(href)) { return href; } else if (baseURI != null && collectionElement != null) { final int lastslash = baseURI.lastIndexOf("/"); return Atom10Parser.resolveURI(baseURI.substring(0, lastslash), collection...
java
public String getHrefResolved(final String relativeUri) { if (Atom10Parser.isAbsoluteURI(relativeUri)) { return relativeUri; } else if (baseURI != null && collectionElement != null) { final int lastslash = baseURI.lastIndexOf("/"); return Atom10Parser.resolveURI(baseU...
java
public boolean accepts(final String ct) { for (final Object element : accepts) { final String accept = (String) element; if (accept != null && accept.trim().equals("*/*")) { return true; } final String entryType = "application/atom+xml"; ...
java
public Element collectionToElement() { final Collection collection = this; final Element element = new Element("collection", AtomService.ATOM_PROTOCOL); element.setAttribute("href", collection.getHref()); final Element titleElem = new Element("title", AtomService.ATOM_FORMAT); t...
java
public void rotate(double angle) { double s = Math.sin(angle); double c = Math.cos(angle); double temp1 = m00; double temp2 = m01; m00 = c * temp1 + s * temp2; m01 = -s * temp1 + c * temp2; temp1 = m10; temp2 = m11; m10 = c * temp1 + s * temp2; ...
java
public Vector3D mult(Vector3D source) { Vector3D result = new Vector3D(); result.setX(m00 * source.getX() + m01 * source.getY() + m02); result.setY(m10 * source.getX() + m11 * source.getY() + m12); return result; }
java