code
stringlengths
73
34.1k
label
stringclasses
1 value
protected boolean checkPackageLocators(String classPackageName) { if (packageLocators != null && !disablePackageLocatorsScanning && classPackageName.length() > 0 && (packageLocatorsBasePackage == null || classPackageName.startsWith(packageLocatorsBasePackage))) { for (String packageLocator : packageLocators) {...
java
private static List<Segment> parseSegments(String origPathStr) { String pathStr = origPathStr; if (!pathStr.startsWith("/")) { pathStr = pathStr + "/"; } List<Segment> result = new ArrayList<>(); for (String segmentStr : PATH_SPLITTER.split(pathStr)) { Ma...
java
okhttp3.Response get(String url, Map<String, Object> params) throws RequestException, LocalOperationException { String fullUrl = getFullUrl(url); okhttp3.Request request = new okhttp3.Request.Builder() .url(addUrlParams(fullUrl, toPayload(params))) .addHeader...
java
okhttp3.Response delete(String url, Map<String, Object> params) throws RequestException, LocalOperationException { okhttp3.Request request = new okhttp3.Request.Builder() .url(getFullUrl(url)) .delete(getBody(toPayload(params), null)) .addHeader("Trans...
java
private String getFullUrl(String url) { return url.startsWith("https://") || url.startsWith("http://") ? url : transloadit.getHostUrl() + url; }
java
private Map<String, String> toPayload(Map<String, Object> data) throws LocalOperationException { Map<String, Object> dataClone = new HashMap<String, Object>(data); dataClone.put("auth", getAuthData()); Map<String, String> payload = new HashMap<String, String>(); payload.put("params", js...
java
private String jsonifyData(Map<String, ? extends Object> data) { JSONObject jsonData = new JSONObject(data); return jsonData.toString(); }
java
private static String convertISO88591toUTF8(String value) { try { return new String(value.getBytes(CharEncoding.ISO_8859_1), CharEncoding.UTF_8); } catch (UnsupportedEncodingException ex) { // ignore and fallback to original encoding return value; } }
java
@Override public Result getResult() throws Exception { Result returnResult = result; // If we've chained to other Actions, we need to find the last result while (returnResult instanceof ActionChainResult) { ActionProxy aProxy = ((ActionChainResult) returnResult).getProxy(); if (aProxy != null) { Resu...
java
private void executeResult() throws Exception { result = createResult(); String timerKey = "executeResult: " + getResultCode(); try { UtilTimerStack.push(timerKey); if (result != null) { result.execute(this); } else if (resultCode != null && !Action.NONE.equals(resultCode)) { throw new Configura...
java
protected <C> C convert(Object object, Class<C> targetClass) { return this.mapper.convertValue(object, targetClass); }
java
protected final void sendObjectToSocket(Object objectToSend, WriteCallback cb) { Session sess = this.getSession(); if (sess != null) { String json; try { json = this.mapper.writeValueAsString(objectToSend); } catch (JsonProcessingException e) { ...
java
public List<String> deviceTypes() { Integer count = json().size(DEVICE_FAMILIES); List<String> deviceTypes = new ArrayList<String>(count); for(int i = 0 ; i < count ; i++) { String familyNumber = json().stringValue(DEVICE_FAMILIES, i); if(familyNumber.equals("1")) deviceT...
java
public static boolean hasAnnotation(Method method, Class<? extends Annotation> annotation) { return !searchForAnnotation(method, annotation).isEmpty(); }
java
public static <T extends Annotation> List<T> searchForAnnotation(Method method, Class<T> annotation) { if (method == null) { return Lists.newArrayList(); } return searchClasses(method, annotation, method.getDeclaringClass()); }
java
public void addStep(String name, String robot, Map<String, Object> options){ steps.addStep(name, robot, options); }
java
void merge(Archetype flatParent, Archetype specialized) { expandAttributeNodes(specialized.getDefinition()); flattenCObject(RmPath.ROOT, null, flatParent.getDefinition(), specialized.getDefinition()); mergeOntologies(flatParent.getTerminology(), specialized.getTerminology()); if (flat...
java
public static void addTTLIndex(DBCollection collection, String field, int ttl) { if (ttl <= 0) { throw new IllegalArgumentException("TTL must be positive"); } collection.createIndex(new BasicDBObject(field, 1), new BasicDBObject("expireAfterSeconds", ttl)); }
java
public static void addIndex(DBCollection collection, String field, boolean asc, boolean background) { int dir = (asc) ? 1 : -1; collection.createIndex(new BasicDBObject(field, dir), new BasicDBObject("background", background)); }
java
void checkRmModelConformance() { final AmVisitor<AmObject, AmConstraintContext> visitor = AmVisitors.preorder(new ConformanceVisitor()); ArchetypeWalker.walkConstraints(visitor, archetype, new AmConstraintContext()); }
java
public static ResourceKey key(Enum<?> value) { return new ResourceKey(value.getClass().getName(), value.name()); }
java
public static ResourceKey key(Class<?> clazz, String id) { return new ResourceKey(clazz.getName(), id); }
java
public static ResourceKey key(Class<?> clazz, Enum<?> value) { return new ResourceKey(clazz.getName(), value.name()); }
java
public static ResourceKey key(Enum<?> enumValue, String key) { return new ResourceKey(enumValue.getClass().getName(), enumValue.name()).child(key); }
java
public void set(int i, double value) { switch (i) { case 0: { x = value; break; } case 1: { y = value; break; } case 2: { z = value; break; } ...
java
public void set(Vector3d v1) { x = v1.x; y = v1.y; z = v1.z; }
java
public void add(Vector3d v1, Vector3d v2) { x = v1.x + v2.x; y = v1.y + v2.y; z = v1.z + v2.z; }
java
public void add(Vector3d v1) { x += v1.x; y += v1.y; z += v1.z; }
java
public void sub(Vector3d v1, Vector3d v2) { x = v1.x - v2.x; y = v1.y - v2.y; z = v1.z - v2.z; }
java
public void sub(Vector3d v1) { x -= v1.x; y -= v1.y; z -= v1.z; }
java
public double distance(Vector3d v) { double dx = x - v.x; double dy = y - v.y; double dz = z - v.z; return Math.sqrt(dx * dx + dy * dy + dz * dz); }
java
public double distanceSquared(Vector3d v) { double dx = x - v.x; double dy = y - v.y; double dz = z - v.z; return dx * dx + dy * dy + dz * dz; }
java
public double dot(Vector3d v1) { return x * v1.x + y * v1.y + z * v1.z; }
java
public void normalize() { double lenSqr = x * x + y * y + z * z; double err = lenSqr - 1; if (err > (2 * DOUBLE_PREC) || err < -(2 * DOUBLE_PREC)) { double len = Math.sqrt(lenSqr); x /= len; y /= len; z /= len; } }
java
public void cross(Vector3d v1, Vector3d v2) { double tmpx = v1.y * v2.z - v1.z * v2.y; double tmpy = v1.z * v2.x - v1.x * v2.z; double tmpz = v1.x * v2.y - v1.y * v2.x; x = tmpx; y = tmpy; z = tmpz; }
java
protected void setRandom(double lower, double upper, Random generator) { double range = upper - lower; x = generator.nextDouble() * range + lower; y = generator.nextDouble() * range + lower; z = generator.nextDouble() * range + lower; }
java
public LuaScriptBlock endBlockReturn(LuaValue value) { add(new LuaAstReturnStatement(argument(value))); return new LuaScriptBlock(script); }
java
public static LuaCondition isNull(LuaValue value) { LuaAstExpression expression; if (value instanceof LuaLocal) { expression = new LuaAstLocal(((LuaLocal) value).getName()); } else { throw new IllegalArgumentException("Unexpected value type: " + value.getClass().getName()...
java
public String getVertexString() { if (tail() != null) { return "" + tail().index + "-" + head().index; } else { return "?-" + head().index; } }
java
public static Face createTriangle(Vertex v0, Vertex v1, Vertex v2, double minArea) { Face face = new Face(); HalfEdge he0 = new HalfEdge(v0, face); HalfEdge he1 = new HalfEdge(v1, face); HalfEdge he2 = new HalfEdge(v2, face); he0.prev = he2; he0.next = he1; he1.p...
java
public double distanceToPlane(Point3d p) { return normal.x * p.x + normal.y * p.y + normal.z * p.z - planeOffset; }
java
public HalfEdge getEdge(int i) { HalfEdge he = he0; while (i > 0) { he = he.next; i--; } while (i < 0) { he = he.prev; i++; } return he; }
java
public double areaSquared(HalfEdge hedge0, HalfEdge hedge1) { Point3d p0 = hedge0.tail().pnt; Point3d p1 = hedge0.head().pnt; Point3d p2 = hedge1.head().pnt; double dx1 = p1.x - p0.x; double dy1 = p1.y - p0.y; double dz1 = p1.z - p0.z; double dx2 = p2.x - p0.x; ...
java
protected <T> T fromJsonString(String json, Class<T> clazz) { return _gsonParser.fromJson(json, clazz); }
java
public LuaScript endScript(LuaScriptConfig config) { if (!endsWithReturnStatement()) { add(new LuaAstReturnStatement()); } String scriptText = buildScriptText(); return new BasicLuaScript(scriptText, config); }
java
public LuaScript endScriptReturn(LuaValue value, LuaScriptConfig config) { add(new LuaAstReturnStatement(argument(value))); String scriptText = buildScriptText(); return new BasicLuaScript(scriptText, config); }
java
public LuaPreparedScript endPreparedScript(LuaScriptConfig config) { if (!endsWithReturnStatement()) { add(new LuaAstReturnStatement()); } String scriptText = buildScriptText(); ArrayList<LuaKeyArgument> keyList = new ArrayList<>(keyArg2AstArg.keySet()); ArrayList<Lua...
java
public LuaPreparedScript endPreparedScriptReturn(LuaValue value, LuaScriptConfig config) { add(new LuaAstReturnStatement(argument(value))); return endPreparedScript(config); }
java
private synchronized static Cluster getCluster(URI baseUrl, String[] personalities) throws IOException { final Entry<URI, Set<String>> key = Maps.immutableEntry(baseUrl, (Set<String>)ImmutableSet.copyOf(personalities)); Cluster result = CLUSTERS.get(key); if (result != null) { r...
java
public ImmutableMap<String, String> getConfigurationTweak(String dbModuleName) { final DbInfo db = cluster.getNextDb(); return ImmutableMap.of("ness.db." + dbModuleName + ".uri", getJdbcUri(db), "ness.db." + dbModuleName + ".ds.user", db.user); }
java
public long remove(final String... fields) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.hdel(getKey(), fields); } }); }
java
public Double score(final String member) { return doWithJedis(new JedisCallable<Double>() { @Override public Double call(Jedis jedis) { return jedis.zscore(getKey(), member); } }); }
java
public boolean add(final String member, final double score) { return doWithJedis(new JedisCallable<Boolean>() { @Override public Boolean call(Jedis jedis) { return jedis.zadd(getKey(), score, member) > 0; } }); }
java
public long addAll(final Map<String, Double> scoredMember) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.zadd(getKey(), scoredMember); } }); }
java
public Set<String> rangeByRank(final long start, final long end) { return doWithJedis(new JedisCallable<Set<String>>() { @Override public Set<String> call(Jedis jedis) { return jedis.zrange(getKey(), start, end); } }); }
java
public Set<String> rangeByRankReverse(final long start, final long end) { return doWithJedis(new JedisCallable<Set<String>>() { @Override public Set<String> call(Jedis jedis) { return jedis.zrevrange(getKey(), start, end); } }); }
java
public long countByLex(final LexRange lexRange) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.zlexcount(getKey(), lexRange.from(), lexRange.to()); } }); }
java
public Set<String> rangeByLex(final LexRange lexRange) { return doWithJedis(new JedisCallable<Set<String>>() { @Override public Set<String> call(Jedis jedis) { if (lexRange.hasLimit()) { return jedis.zrangeByLex(getKey(), lexRange.from(), lexRange.to()...
java
public Set<String> rangeByLexReverse(final LexRange lexRange) { return doWithJedis(new JedisCallable<Set<String>>() { @Override public Set<String> call(Jedis jedis) { if (lexRange.hasLimit()) { return jedis.zrevrangeByLex(getKey(), lexRange.fromReverse...
java
public long removeRangeByLex(final LexRange lexRange) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.zremrangeByLex(getKey(), lexRange.from(), lexRange.to()); } }); }
java
public Set<String> rangeByScoreReverse(final ScoreRange scoreRange) { return doWithJedis(new JedisCallable<Set<String>>() { @Override public Set<String> call(Jedis jedis) { if (scoreRange.hasLimit()) { return jedis.zrevrangeByScore(getKey(), scoreRange...
java
public long removeRangeByScore(final ScoreRange scoreRange) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.zremrangeByScore(getKey(), scoreRange.from(), scoreRange.to()); } }); }
java
public void build(double[] coords, int nump) throws IllegalArgumentException { if (nump < 4) { throw new IllegalArgumentException("Less than four input points specified"); } if (coords.length / 3 < nump) { throw new IllegalArgumentException("Coordinate array too small for...
java
public void build(Point3d[] points, int nump) throws IllegalArgumentException { if (nump < 4) { throw new IllegalArgumentException("Less than four input points specified"); } if (points.length < nump) { throw new IllegalArgumentException("Point array too small for specifi...
java
public Point3d[] getVertices() { Point3d[] vtxs = new Point3d[numVertices]; for (int i = 0; i < numVertices; i++) { vtxs[i] = pointBuffer[vertexPointIndices[i]].pnt; } return vtxs; }
java
public int getVertices(double[] coords) { for (int i = 0; i < numVertices; i++) { Point3d pnt = pointBuffer[vertexPointIndices[i]].pnt; coords[i * 3 + 0] = pnt.x; coords[i * 3 + 1] = pnt.y; coords[i * 3 + 2] = pnt.z; } return numVertices; }
java
public int[] getVertexPointIndices() { int[] indices = new int[numVertices]; for (int i = 0; i < numVertices; i++) { indices[i] = vertexPointIndices[i]; } return indices; }
java
public long addAll(final String... members) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.sadd(getKey(), members); } }); }
java
public long removeAll(final String... members) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.srem(getKey(), members); } }); }
java
public String pop() { return doWithJedis(new JedisCallable<String>() { @Override public String call(Jedis jedis) { return jedis.spop(getKey()); } }); }
java
protected Object[] idsOf(final List<?> idsOrValues) { // convert list to array that we can mutate final Object[] ids = idsOrValues.toArray(); // mutate array to contain only non-empty ids int length = 0; for (int i = 0; i < ids.length;) { final Object p = ids[i++]; ...
java
public long indexOf(final String element) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return doIndexOf(jedis, element); } }); }
java
public String get(final long index) { return doWithJedis(new JedisCallable<String>() { @Override public String call(Jedis jedis) { return jedis.lindex(getKey(), index); } }); }
java
public List<String> subList(final long fromIndex, final long toIndex) { return doWithJedis(new JedisCallable<List<String>>() { @Override public List<String> call(Jedis jedis) { return jedis.lrange(getKey(), fromIndex, toIndex); } }); }
java
private void ensureNext() { // Check if the current scan result has more keys (i.e. the index did not reach the end of the result list) if (resultIndex < scanResult.getResult().size()) { return; } // Since the current scan result was fully iterated, // if there is ano...
java
public void addAll(Vertex vtx) { if (head == null) { head = vtx; } else { tail.next = vtx; } vtx.prev = tail; while (vtx.next != null) { vtx = vtx.next; } tail = vtx; }
java
public void delete(Vertex vtx) { if (vtx.prev == null) { head = vtx.next; } else { vtx.prev.next = vtx.next; } if (vtx.next == null) { tail = vtx.prev; } else { vtx.next.prev = vtx.prev; } }
java
public void delete(Vertex vtx1, Vertex vtx2) { if (vtx1.prev == null) { head = vtx2.next; } else { vtx1.prev.next = vtx2.next; } if (vtx2.next == null) { tail = vtx1.prev; } else { vtx2.next.prev = vtx1.prev; } }
java
public void insertBefore(Vertex vtx, Vertex next) { vtx.prev = next.prev; if (next.prev == null) { head = vtx; } else { next.prev.next = vtx; } vtx.next = next; next.prev = vtx; }
java
private static void freeTempLOB(ClobWrapper clob, BlobWrapper blob) { try { if (clob != null) { // If the CLOB is open, close it if (clob.isOpen()) { clob.close(); } // Free the memory used by this CLOB clob.freeTemporary(); } if (blob != null) { ...
java
public void check(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException { ensureElementClassRef(collDef, checkLevel); checkInheritedForeignkey(collDef, checkLevel); ensureCollectionClass(collDef, checkLevel); checkProxyPrefetchingLimit(collDef, checkLeve...
java
private void ensureElementClassRef(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException { if (CHECKLEVEL_NONE.equals(checkLevel)) { return; } String arrayElementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ARRAY_ELEMENT_CLA...
java
private void ensureCollectionClass(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException { if (CHECKLEVEL_NONE.equals(checkLevel)) { return; } if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_ARRAY_ELEMENT_CLASS_REF)) { ...
java
private void checkOrderby(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException { if (CHECKLEVEL_NONE.equals(checkLevel)) { return; } String orderbySpec = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ORDERBY); if ((orderbySpe...
java
private void checkQueryCustomizer(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException { if (!CHECKLEVEL_STRICT.equals(checkLevel)) { return; } String queryCustomizerName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_QUERY_CU...
java
public static Class getClass(String className, boolean initialize) throws ClassNotFoundException { return Class.forName(className, initialize, getClassLoader()); }
java
public static Object newInstance(Class target, Class[] types, Object[] args) throws InstantiationException, IllegalAccessException, IllegalArg...
java
public static Field getField(Class clazz, String fieldName) { try { return clazz.getField(fieldName); } catch (Exception ignored) {} return null; }
java
public static Object newInstance(String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return newInstance(getClass(className)); }
java
public static Object newInstance(String className, Class[] types, Object[] args) throws InstantiationException, IllegalAccessException, ...
java
public static Object newInstance(Class target, Class type, Object arg) throws InstantiationException, IllegalAccessException, IllegalArgumentException, ...
java
public static Object newInstance(String className, Class type, Object arg) throws InstantiationException, IllegalAccessException, IllegalArgumentE...
java
public static Object buildNewObjectInstance(ClassDescriptor cld) { Object result = null; // If either the factory class and/or factory method is null, // just follow the normal code path and create via constructor if ((cld.getFactoryClass() == null) || (cld.getFactoryMethod() ...
java
private GraphicsDocument createFeatureDocument(StringWriter writer) throws RenderException { if (TileMetadata.PARAM_SVG_RENDERER.equalsIgnoreCase(renderer)) { DefaultSvgDocument document = new DefaultSvgDocument(writer, false); document.setMaximumFractionDigits(MAXIMUM_FRACTION_DIGITS); document.registerWrit...
java
private GraphicsDocument createLabelDocument(StringWriter writer, LabelStyleInfo labelStyleInfo) throws RenderException { if (TileMetadata.PARAM_SVG_RENDERER.equalsIgnoreCase(renderer)) { DefaultSvgDocument document = new DefaultSvgDocument(writer, false); document.setMaximumFractionDigits(MAXIMUM_FRACTION_...
java
private GeometryCoordinateSequenceTransformer getTransformer() { if (unitToPixel == null) { unitToPixel = new GeometryCoordinateSequenceTransformer(); unitToPixel.setMathTransform(ProjectiveTransform.create(new AffineTransform(scale, 0, 0, -scale, -scale * panOrigin.x, scale * panOrigin.y))); } return ...
java
private void doExecute(Connection conn) throws SQLException { PreparedStatement stmt; int size; size = _methods.size(); if ( size == 0 ) { return; } stmt = conn.prepareStatement(_sql); try { m_platform.afte...
java
public Object getBeliefValue(String agent_name, final String belief_name, Connector connector) { ((IExternalAccess) connector.getAgentsExternalAccess(agent_name)) .scheduleStep(new IComponentStep<Integer>() { public IFuture<Integer> execute(IInternalAccess ia) {...
java
public void setBeliefValue(String agent_name, final String belief_name, final Object new_value, Connector connector) { ((IExternalAccess) connector.getAgentsExternalAccess(agent_name)) .scheduleStep(new IComponentStep<Integer>() { public IFuture<Integer> execute...
java
public IPlan[] getAgentPlans(final String agent_name, Connector connector) { ((IExternalAccess) connector.getAgentsExternalAccess(agent_name)) .scheduleStep(new IComponentStep<Plan>() { public IFuture<Plan> execute(IInternalAccess ia) { IBDIInternalA...
java