id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
159,500
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/image/wms/WmsLayer.java
WmsLayer.supportsNativeRotation
@Override public boolean supportsNativeRotation() { return this.params.useNativeAngle && (this.params.serverType == WmsLayerParam.ServerType.MAPSERVER || this.params.serverType == WmsLayerParam.ServerType.GEOSERVER); }
java
@Override public boolean supportsNativeRotation() { return this.params.useNativeAngle && (this.params.serverType == WmsLayerParam.ServerType.MAPSERVER || this.params.serverType == WmsLayerParam.ServerType.GEOSERVER); }
[ "@", "Override", "public", "boolean", "supportsNativeRotation", "(", ")", "{", "return", "this", ".", "params", ".", "useNativeAngle", "&&", "(", "this", ".", "params", ".", "serverType", "==", "WmsLayerParam", ".", "ServerType", ".", "MAPSERVER", "||", "this", ".", "params", ".", "serverType", "==", "WmsLayerParam", ".", "ServerType", ".", "GEOSERVER", ")", ";", "}" ]
If supported by the WMS server, a parameter "angle" can be set on "customParams" or "mergeableParams". In this case the rotation will be done natively by the WMS.
[ "If", "supported", "by", "the", "WMS", "server", "a", "parameter", "angle", "can", "be", "set", "on", "customParams", "or", "mergeableParams", ".", "In", "this", "case", "the", "rotation", "will", "be", "done", "natively", "by", "the", "WMS", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/image/wms/WmsLayer.java#L72-L77
159,501
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/fileloader/AbstractFileConfigFileLoader.java
AbstractFileConfigFileLoader.platformIndependentUriToFile
protected static File platformIndependentUriToFile(final URI fileURI) { File file; try { file = new File(fileURI); } catch (IllegalArgumentException e) { if (fileURI.toString().startsWith("file://")) { file = new File(fileURI.toString().substring("file://".length())); } else { throw e; } } return file; }
java
protected static File platformIndependentUriToFile(final URI fileURI) { File file; try { file = new File(fileURI); } catch (IllegalArgumentException e) { if (fileURI.toString().startsWith("file://")) { file = new File(fileURI.toString().substring("file://".length())); } else { throw e; } } return file; }
[ "protected", "static", "File", "platformIndependentUriToFile", "(", "final", "URI", "fileURI", ")", "{", "File", "file", ";", "try", "{", "file", "=", "new", "File", "(", "fileURI", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "if", "(", "fileURI", ".", "toString", "(", ")", ".", "startsWith", "(", "\"file://\"", ")", ")", "{", "file", "=", "new", "File", "(", "fileURI", ".", "toString", "(", ")", ".", "substring", "(", "\"file://\"", ".", "length", "(", ")", ")", ")", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "return", "file", ";", "}" ]
Convert a url to a file object. No checks are made to see if file exists but there are some hacks that are needed to convert uris to files across platforms. @param fileURI the uri to convert
[ "Convert", "a", "url", "to", "a", "file", "object", ".", "No", "checks", "are", "made", "to", "see", "if", "file", "exists", "but", "there", "are", "some", "hacks", "that", "are", "needed", "to", "convert", "uris", "to", "files", "across", "platforms", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/fileloader/AbstractFileConfigFileLoader.java#L29-L41
159,502
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/multi/PMultiObject.java
PMultiObject.getContext
public static String getContext(final PObject[] objs) { StringBuilder result = new StringBuilder("("); boolean first = true; for (PObject obj: objs) { if (!first) { result.append('|'); } first = false; result.append(obj.getCurrentPath()); } result.append(')'); return result.toString(); }
java
public static String getContext(final PObject[] objs) { StringBuilder result = new StringBuilder("("); boolean first = true; for (PObject obj: objs) { if (!first) { result.append('|'); } first = false; result.append(obj.getCurrentPath()); } result.append(')'); return result.toString(); }
[ "public", "static", "String", "getContext", "(", "final", "PObject", "[", "]", "objs", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", "\"(\"", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "PObject", "obj", ":", "objs", ")", "{", "if", "(", "!", "first", ")", "{", "result", ".", "append", "(", "'", "'", ")", ";", "}", "first", "=", "false", ";", "result", ".", "append", "(", "obj", ".", "getCurrentPath", "(", ")", ")", ";", "}", "result", ".", "append", "(", "'", "'", ")", ";", "return", "result", ".", "toString", "(", ")", ";", "}" ]
Build the context name. @param objs the objects @return the global context name
[ "Build", "the", "context", "name", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/multi/PMultiObject.java#L36-L48
159,503
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.save
public final void save(final PrintJobStatusExtImpl entry) { getSession().merge(entry); getSession().flush(); getSession().evict(entry); }
java
public final void save(final PrintJobStatusExtImpl entry) { getSession().merge(entry); getSession().flush(); getSession().evict(entry); }
[ "public", "final", "void", "save", "(", "final", "PrintJobStatusExtImpl", "entry", ")", "{", "getSession", "(", ")", ".", "merge", "(", "entry", ")", ";", "getSession", "(", ")", ".", "flush", "(", ")", ";", "getSession", "(", ")", ".", "evict", "(", "entry", ")", ";", "}" ]
Save Job Record. @param entry the entry
[ "Save", "Job", "Record", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L49-L53
159,504
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.getValue
public final Object getValue(final String id, final String property) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<Object> criteria = builder.createQuery(Object.class); final Root<PrintJobStatusExtImpl> root = criteria.from(PrintJobStatusExtImpl.class); criteria.select(root.get(property)); criteria.where(builder.equal(root.get("referenceId"), id)); return getSession().createQuery(criteria).uniqueResult(); }
java
public final Object getValue(final String id, final String property) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<Object> criteria = builder.createQuery(Object.class); final Root<PrintJobStatusExtImpl> root = criteria.from(PrintJobStatusExtImpl.class); criteria.select(root.get(property)); criteria.where(builder.equal(root.get("referenceId"), id)); return getSession().createQuery(criteria).uniqueResult(); }
[ "public", "final", "Object", "getValue", "(", "final", "String", "id", ",", "final", "String", "property", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaQuery", "<", "Object", ">", "criteria", "=", "builder", ".", "createQuery", "(", "Object", ".", "class", ")", ";", "final", "Root", "<", "PrintJobStatusExtImpl", ">", "root", "=", "criteria", ".", "from", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "criteria", ".", "select", "(", "root", ".", "get", "(", "property", ")", ")", ";", "criteria", ".", "where", "(", "builder", ".", "equal", "(", "root", ".", "get", "(", "\"referenceId\"", ")", ",", "id", ")", ")", ";", "return", "getSession", "(", ")", ".", "createQuery", "(", "criteria", ")", ".", "uniqueResult", "(", ")", ";", "}" ]
get specific property value of job. @param id the id @param property the property name/path @return the property value
[ "get", "specific", "property", "value", "of", "job", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L104-L111
159,505
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.cancelOld
public final void cancelOld( final long starttimeThreshold, final long checkTimeThreshold, final String message) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaUpdate<PrintJobStatusExtImpl> update = builder.createCriteriaUpdate(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = update.from(PrintJobStatusExtImpl.class); update.where(builder.and( builder.equal(root.get("status"), PrintJobStatus.Status.WAITING), builder.or( builder.lessThan(root.get("entry").get("startTime"), starttimeThreshold), builder.and(builder.isNotNull(root.get("lastCheckTime")), builder.lessThan(root.get("lastCheckTime"), checkTimeThreshold)) ) )); update.set(root.get("status"), PrintJobStatus.Status.CANCELLED); update.set(root.get("error"), message); getSession().createQuery(update).executeUpdate(); }
java
public final void cancelOld( final long starttimeThreshold, final long checkTimeThreshold, final String message) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaUpdate<PrintJobStatusExtImpl> update = builder.createCriteriaUpdate(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = update.from(PrintJobStatusExtImpl.class); update.where(builder.and( builder.equal(root.get("status"), PrintJobStatus.Status.WAITING), builder.or( builder.lessThan(root.get("entry").get("startTime"), starttimeThreshold), builder.and(builder.isNotNull(root.get("lastCheckTime")), builder.lessThan(root.get("lastCheckTime"), checkTimeThreshold)) ) )); update.set(root.get("status"), PrintJobStatus.Status.CANCELLED); update.set(root.get("error"), message); getSession().createQuery(update).executeUpdate(); }
[ "public", "final", "void", "cancelOld", "(", "final", "long", "starttimeThreshold", ",", "final", "long", "checkTimeThreshold", ",", "final", "String", "message", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaUpdate", "<", "PrintJobStatusExtImpl", ">", "update", "=", "builder", ".", "createCriteriaUpdate", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "final", "Root", "<", "PrintJobStatusExtImpl", ">", "root", "=", "update", ".", "from", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "update", ".", "where", "(", "builder", ".", "and", "(", "builder", ".", "equal", "(", "root", ".", "get", "(", "\"status\"", ")", ",", "PrintJobStatus", ".", "Status", ".", "WAITING", ")", ",", "builder", ".", "or", "(", "builder", ".", "lessThan", "(", "root", ".", "get", "(", "\"entry\"", ")", ".", "get", "(", "\"startTime\"", ")", ",", "starttimeThreshold", ")", ",", "builder", ".", "and", "(", "builder", ".", "isNotNull", "(", "root", ".", "get", "(", "\"lastCheckTime\"", ")", ")", ",", "builder", ".", "lessThan", "(", "root", ".", "get", "(", "\"lastCheckTime\"", ")", ",", "checkTimeThreshold", ")", ")", ")", ")", ")", ";", "update", ".", "set", "(", "root", ".", "get", "(", "\"status\"", ")", ",", "PrintJobStatus", ".", "Status", ".", "CANCELLED", ")", ";", "update", ".", "set", "(", "root", ".", "get", "(", "\"error\"", ")", ",", "message", ")", ";", "getSession", "(", ")", ".", "createQuery", "(", "update", ")", ".", "executeUpdate", "(", ")", ";", "}" ]
Cancel old waiting jobs. @param starttimeThreshold threshold for start time @param checkTimeThreshold threshold for last check time @param message the error message
[ "Cancel", "old", "waiting", "jobs", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L164-L181
159,506
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.updateLastCheckTime
public final void updateLastCheckTime(final String id, final long lastCheckTime) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaUpdate<PrintJobStatusExtImpl> update = builder.createCriteriaUpdate(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = update.from(PrintJobStatusExtImpl.class); update.where(builder.equal(root.get("referenceId"), id)); update.set(root.get("lastCheckTime"), lastCheckTime); getSession().createQuery(update).executeUpdate(); }
java
public final void updateLastCheckTime(final String id, final long lastCheckTime) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaUpdate<PrintJobStatusExtImpl> update = builder.createCriteriaUpdate(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = update.from(PrintJobStatusExtImpl.class); update.where(builder.equal(root.get("referenceId"), id)); update.set(root.get("lastCheckTime"), lastCheckTime); getSession().createQuery(update).executeUpdate(); }
[ "public", "final", "void", "updateLastCheckTime", "(", "final", "String", "id", ",", "final", "long", "lastCheckTime", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaUpdate", "<", "PrintJobStatusExtImpl", ">", "update", "=", "builder", ".", "createCriteriaUpdate", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "final", "Root", "<", "PrintJobStatusExtImpl", ">", "root", "=", "update", ".", "from", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "update", ".", "where", "(", "builder", ".", "equal", "(", "root", ".", "get", "(", "\"referenceId\"", ")", ",", "id", ")", ")", ";", "update", ".", "set", "(", "root", ".", "get", "(", "\"lastCheckTime\"", ")", ",", "lastCheckTime", ")", ";", "getSession", "(", ")", ".", "createQuery", "(", "update", ")", ".", "executeUpdate", "(", ")", ";", "}" ]
Update the lastCheckTime of the given record. @param id the id @param lastCheckTime the new value
[ "Update", "the", "lastCheckTime", "of", "the", "given", "record", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L189-L197
159,507
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.deleteOld
public final int deleteOld(final long checkTimeThreshold) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaDelete<PrintJobStatusExtImpl> delete = builder.createCriteriaDelete(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = delete.from(PrintJobStatusExtImpl.class); delete.where(builder.and(builder.isNotNull(root.get("lastCheckTime")), builder.lessThan(root.get("lastCheckTime"), checkTimeThreshold))); return getSession().createQuery(delete).executeUpdate(); }
java
public final int deleteOld(final long checkTimeThreshold) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaDelete<PrintJobStatusExtImpl> delete = builder.createCriteriaDelete(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = delete.from(PrintJobStatusExtImpl.class); delete.where(builder.and(builder.isNotNull(root.get("lastCheckTime")), builder.lessThan(root.get("lastCheckTime"), checkTimeThreshold))); return getSession().createQuery(delete).executeUpdate(); }
[ "public", "final", "int", "deleteOld", "(", "final", "long", "checkTimeThreshold", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaDelete", "<", "PrintJobStatusExtImpl", ">", "delete", "=", "builder", ".", "createCriteriaDelete", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "final", "Root", "<", "PrintJobStatusExtImpl", ">", "root", "=", "delete", ".", "from", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "delete", ".", "where", "(", "builder", ".", "and", "(", "builder", ".", "isNotNull", "(", "root", ".", "get", "(", "\"lastCheckTime\"", ")", ")", ",", "builder", ".", "lessThan", "(", "root", ".", "get", "(", "\"lastCheckTime\"", ")", ",", "checkTimeThreshold", ")", ")", ")", ";", "return", "getSession", "(", ")", ".", "createQuery", "(", "delete", ")", ".", "executeUpdate", "(", ")", ";", "}" ]
Delete old jobs. @param checkTimeThreshold threshold for last check time @return the number of jobs deleted
[ "Delete", "old", "jobs", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L205-L213
159,508
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.poll
public final List<PrintJobStatusExtImpl> poll(final int size) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<PrintJobStatusExtImpl> criteria = builder.createQuery(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = criteria.from(PrintJobStatusExtImpl.class); root.alias("pj"); criteria.where(builder.equal(root.get("status"), PrintJobStatus.Status.WAITING)); criteria.orderBy(builder.asc(root.get("entry").get("startTime"))); final Query<PrintJobStatusExtImpl> query = getSession().createQuery(criteria); query.setMaxResults(size); // LOCK but don't wait for release (since this is run continuously // anyway, no wait prevents deadlock) query.setLockMode("pj", LockMode.UPGRADE_NOWAIT); try { return query.getResultList(); } catch (PessimisticLockException ex) { // Another process was polling at the same time. We can ignore this error return Collections.emptyList(); } }
java
public final List<PrintJobStatusExtImpl> poll(final int size) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<PrintJobStatusExtImpl> criteria = builder.createQuery(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = criteria.from(PrintJobStatusExtImpl.class); root.alias("pj"); criteria.where(builder.equal(root.get("status"), PrintJobStatus.Status.WAITING)); criteria.orderBy(builder.asc(root.get("entry").get("startTime"))); final Query<PrintJobStatusExtImpl> query = getSession().createQuery(criteria); query.setMaxResults(size); // LOCK but don't wait for release (since this is run continuously // anyway, no wait prevents deadlock) query.setLockMode("pj", LockMode.UPGRADE_NOWAIT); try { return query.getResultList(); } catch (PessimisticLockException ex) { // Another process was polling at the same time. We can ignore this error return Collections.emptyList(); } }
[ "public", "final", "List", "<", "PrintJobStatusExtImpl", ">", "poll", "(", "final", "int", "size", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaQuery", "<", "PrintJobStatusExtImpl", ">", "criteria", "=", "builder", ".", "createQuery", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "final", "Root", "<", "PrintJobStatusExtImpl", ">", "root", "=", "criteria", ".", "from", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "root", ".", "alias", "(", "\"pj\"", ")", ";", "criteria", ".", "where", "(", "builder", ".", "equal", "(", "root", ".", "get", "(", "\"status\"", ")", ",", "PrintJobStatus", ".", "Status", ".", "WAITING", ")", ")", ";", "criteria", ".", "orderBy", "(", "builder", ".", "asc", "(", "root", ".", "get", "(", "\"entry\"", ")", ".", "get", "(", "\"startTime\"", ")", ")", ")", ";", "final", "Query", "<", "PrintJobStatusExtImpl", ">", "query", "=", "getSession", "(", ")", ".", "createQuery", "(", "criteria", ")", ";", "query", ".", "setMaxResults", "(", "size", ")", ";", "// LOCK but don't wait for release (since this is run continuously", "// anyway, no wait prevents deadlock)", "query", ".", "setLockMode", "(", "\"pj\"", ",", "LockMode", ".", "UPGRADE_NOWAIT", ")", ";", "try", "{", "return", "query", ".", "getResultList", "(", ")", ";", "}", "catch", "(", "PessimisticLockException", "ex", ")", "{", "// Another process was polling at the same time. We can ignore this error", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "}" ]
Poll for the next N waiting jobs in line. @param size maximum amount of jobs to poll for @return up to "size" jobs
[ "Poll", "for", "the", "next", "N", "waiting", "jobs", "in", "line", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L221-L240
159,509
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.getResult
public final PrintJobResultExtImpl getResult(final URI reportURI) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<PrintJobResultExtImpl> criteria = builder.createQuery(PrintJobResultExtImpl.class); final Root<PrintJobResultExtImpl> root = criteria.from(PrintJobResultExtImpl.class); criteria.where(builder.equal(root.get("reportURI"), reportURI.toString())); return getSession().createQuery(criteria).uniqueResult(); }
java
public final PrintJobResultExtImpl getResult(final URI reportURI) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<PrintJobResultExtImpl> criteria = builder.createQuery(PrintJobResultExtImpl.class); final Root<PrintJobResultExtImpl> root = criteria.from(PrintJobResultExtImpl.class); criteria.where(builder.equal(root.get("reportURI"), reportURI.toString())); return getSession().createQuery(criteria).uniqueResult(); }
[ "public", "final", "PrintJobResultExtImpl", "getResult", "(", "final", "URI", "reportURI", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaQuery", "<", "PrintJobResultExtImpl", ">", "criteria", "=", "builder", ".", "createQuery", "(", "PrintJobResultExtImpl", ".", "class", ")", ";", "final", "Root", "<", "PrintJobResultExtImpl", ">", "root", "=", "criteria", ".", "from", "(", "PrintJobResultExtImpl", ".", "class", ")", ";", "criteria", ".", "where", "(", "builder", ".", "equal", "(", "root", ".", "get", "(", "\"reportURI\"", ")", ",", "reportURI", ".", "toString", "(", ")", ")", ")", ";", "return", "getSession", "(", ")", ".", "createQuery", "(", "criteria", ")", ".", "uniqueResult", "(", ")", ";", "}" ]
Get result report. @param reportURI the URI of the report @return the result report.
[ "Get", "result", "report", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L248-L255
159,510
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.delete
public void delete(final String referenceId) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaDelete<PrintJobStatusExtImpl> delete = builder.createCriteriaDelete(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = delete.from(PrintJobStatusExtImpl.class); delete.where(builder.equal(root.get("referenceId"), referenceId)); getSession().createQuery(delete).executeUpdate(); }
java
public void delete(final String referenceId) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaDelete<PrintJobStatusExtImpl> delete = builder.createCriteriaDelete(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = delete.from(PrintJobStatusExtImpl.class); delete.where(builder.equal(root.get("referenceId"), referenceId)); getSession().createQuery(delete).executeUpdate(); }
[ "public", "void", "delete", "(", "final", "String", "referenceId", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaDelete", "<", "PrintJobStatusExtImpl", ">", "delete", "=", "builder", ".", "createCriteriaDelete", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "final", "Root", "<", "PrintJobStatusExtImpl", ">", "root", "=", "delete", ".", "from", "(", "PrintJobStatusExtImpl", ".", "class", ")", ";", "delete", ".", "where", "(", "builder", ".", "equal", "(", "root", ".", "get", "(", "\"referenceId\"", ")", ",", "referenceId", ")", ")", ";", "getSession", "(", ")", ".", "createQuery", "(", "delete", ")", ".", "executeUpdate", "(", ")", ";", "}" ]
Delete a record. @param referenceId the reference ID.
[ "Delete", "a", "record", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L262-L269
159,511
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/PrintJobEntryImpl.java
PrintJobEntryImpl.configureAccess
public final void configureAccess(final Template template, final ApplicationContext context) { final Configuration configuration = template.getConfiguration(); AndAccessAssertion accessAssertion = context.getBean(AndAccessAssertion.class); accessAssertion.setPredicates(configuration.getAccessAssertion(), template.getAccessAssertion()); this.access = accessAssertion; }
java
public final void configureAccess(final Template template, final ApplicationContext context) { final Configuration configuration = template.getConfiguration(); AndAccessAssertion accessAssertion = context.getBean(AndAccessAssertion.class); accessAssertion.setPredicates(configuration.getAccessAssertion(), template.getAccessAssertion()); this.access = accessAssertion; }
[ "public", "final", "void", "configureAccess", "(", "final", "Template", "template", ",", "final", "ApplicationContext", "context", ")", "{", "final", "Configuration", "configuration", "=", "template", ".", "getConfiguration", "(", ")", ";", "AndAccessAssertion", "accessAssertion", "=", "context", ".", "getBean", "(", "AndAccessAssertion", ".", "class", ")", ";", "accessAssertion", ".", "setPredicates", "(", "configuration", ".", "getAccessAssertion", "(", ")", ",", "template", ".", "getAccessAssertion", "(", ")", ")", ";", "this", ".", "access", "=", "accessAssertion", ";", "}" ]
Configure the access permissions required to access this print job. @param template the containing print template which should have sufficient information to configure the access. @param context the application context
[ "Configure", "the", "access", "permissions", "required", "to", "access", "this", "print", "job", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/PrintJobEntryImpl.java#L144-L150
159,512
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/AbstractGridCoverageLayerPlugin.java
AbstractGridCoverageLayerPlugin.createStyleSupplier
protected final <T> StyleSupplier<T> createStyleSupplier( final Template template, final String styleRef) { return new StyleSupplier<T>() { @Override public Style load( final MfClientHttpRequestFactory requestFactory, final T featureSource) { final StyleParser parser = AbstractGridCoverageLayerPlugin.this.styleParser; return OptionalUtils.or( () -> template.getStyle(styleRef), () -> parser.loadStyle(template.getConfiguration(), requestFactory, styleRef)) .orElse(template.getConfiguration().getDefaultStyle(NAME)); } }; }
java
protected final <T> StyleSupplier<T> createStyleSupplier( final Template template, final String styleRef) { return new StyleSupplier<T>() { @Override public Style load( final MfClientHttpRequestFactory requestFactory, final T featureSource) { final StyleParser parser = AbstractGridCoverageLayerPlugin.this.styleParser; return OptionalUtils.or( () -> template.getStyle(styleRef), () -> parser.loadStyle(template.getConfiguration(), requestFactory, styleRef)) .orElse(template.getConfiguration().getDefaultStyle(NAME)); } }; }
[ "protected", "final", "<", "T", ">", "StyleSupplier", "<", "T", ">", "createStyleSupplier", "(", "final", "Template", "template", ",", "final", "String", "styleRef", ")", "{", "return", "new", "StyleSupplier", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "Style", "load", "(", "final", "MfClientHttpRequestFactory", "requestFactory", ",", "final", "T", "featureSource", ")", "{", "final", "StyleParser", "parser", "=", "AbstractGridCoverageLayerPlugin", ".", "this", ".", "styleParser", ";", "return", "OptionalUtils", ".", "or", "(", "(", ")", "->", "template", ".", "getStyle", "(", "styleRef", ")", ",", "(", ")", "->", "parser", ".", "loadStyle", "(", "template", ".", "getConfiguration", "(", ")", ",", "requestFactory", ",", "styleRef", ")", ")", ".", "orElse", "(", "template", ".", "getConfiguration", "(", ")", ".", "getDefaultStyle", "(", "NAME", ")", ")", ";", "}", "}", ";", "}" ]
Common method for creating styles. @param template the template that the map is part of @param styleRef the style ref identifying the style @param <T> the source type
[ "Common", "method", "for", "creating", "styles", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/AbstractGridCoverageLayerPlugin.java#L27-L42
159,513
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/RegistryJobQueue.java
RegistryJobQueue.store
private void store(final PrintJobStatus printJobStatus) throws JSONException { JSONObject metadata = new JSONObject(); metadata.put(JSON_REQUEST_DATA, printJobStatus.getEntry().getRequestData().getInternalObj()); metadata.put(JSON_STATUS, printJobStatus.getStatus().toString()); metadata.put(JSON_START_DATE, printJobStatus.getStartTime()); metadata.put(JSON_REQUEST_COUNT, printJobStatus.getRequestCount()); if (printJobStatus.getCompletionDate() != null) { metadata.put(JSON_COMPLETION_DATE, printJobStatus.getCompletionTime()); } metadata.put(JSON_ACCESS_ASSERTION, this.assertionPersister.marshal(printJobStatus.getAccess())); if (printJobStatus.getError() != null) { metadata.put(JSON_ERROR, printJobStatus.getError()); } if (printJobStatus.getResult() != null) { metadata.put(JSON_REPORT_URI, printJobStatus.getResult().getReportURIString()); metadata.put(JSON_FILENAME, printJobStatus.getResult().getFileName()); metadata.put(JSON_FILE_EXT, printJobStatus.getResult().getFileExtension()); metadata.put(JSON_MIME_TYPE, printJobStatus.getResult().getMimeType()); } this.registry.put(RESULT_METADATA + printJobStatus.getReferenceId(), metadata); }
java
private void store(final PrintJobStatus printJobStatus) throws JSONException { JSONObject metadata = new JSONObject(); metadata.put(JSON_REQUEST_DATA, printJobStatus.getEntry().getRequestData().getInternalObj()); metadata.put(JSON_STATUS, printJobStatus.getStatus().toString()); metadata.put(JSON_START_DATE, printJobStatus.getStartTime()); metadata.put(JSON_REQUEST_COUNT, printJobStatus.getRequestCount()); if (printJobStatus.getCompletionDate() != null) { metadata.put(JSON_COMPLETION_DATE, printJobStatus.getCompletionTime()); } metadata.put(JSON_ACCESS_ASSERTION, this.assertionPersister.marshal(printJobStatus.getAccess())); if (printJobStatus.getError() != null) { metadata.put(JSON_ERROR, printJobStatus.getError()); } if (printJobStatus.getResult() != null) { metadata.put(JSON_REPORT_URI, printJobStatus.getResult().getReportURIString()); metadata.put(JSON_FILENAME, printJobStatus.getResult().getFileName()); metadata.put(JSON_FILE_EXT, printJobStatus.getResult().getFileExtension()); metadata.put(JSON_MIME_TYPE, printJobStatus.getResult().getMimeType()); } this.registry.put(RESULT_METADATA + printJobStatus.getReferenceId(), metadata); }
[ "private", "void", "store", "(", "final", "PrintJobStatus", "printJobStatus", ")", "throws", "JSONException", "{", "JSONObject", "metadata", "=", "new", "JSONObject", "(", ")", ";", "metadata", ".", "put", "(", "JSON_REQUEST_DATA", ",", "printJobStatus", ".", "getEntry", "(", ")", ".", "getRequestData", "(", ")", ".", "getInternalObj", "(", ")", ")", ";", "metadata", ".", "put", "(", "JSON_STATUS", ",", "printJobStatus", ".", "getStatus", "(", ")", ".", "toString", "(", ")", ")", ";", "metadata", ".", "put", "(", "JSON_START_DATE", ",", "printJobStatus", ".", "getStartTime", "(", ")", ")", ";", "metadata", ".", "put", "(", "JSON_REQUEST_COUNT", ",", "printJobStatus", ".", "getRequestCount", "(", ")", ")", ";", "if", "(", "printJobStatus", ".", "getCompletionDate", "(", ")", "!=", "null", ")", "{", "metadata", ".", "put", "(", "JSON_COMPLETION_DATE", ",", "printJobStatus", ".", "getCompletionTime", "(", ")", ")", ";", "}", "metadata", ".", "put", "(", "JSON_ACCESS_ASSERTION", ",", "this", ".", "assertionPersister", ".", "marshal", "(", "printJobStatus", ".", "getAccess", "(", ")", ")", ")", ";", "if", "(", "printJobStatus", ".", "getError", "(", ")", "!=", "null", ")", "{", "metadata", ".", "put", "(", "JSON_ERROR", ",", "printJobStatus", ".", "getError", "(", ")", ")", ";", "}", "if", "(", "printJobStatus", ".", "getResult", "(", ")", "!=", "null", ")", "{", "metadata", ".", "put", "(", "JSON_REPORT_URI", ",", "printJobStatus", ".", "getResult", "(", ")", ".", "getReportURIString", "(", ")", ")", ";", "metadata", ".", "put", "(", "JSON_FILENAME", ",", "printJobStatus", ".", "getResult", "(", ")", ".", "getFileName", "(", ")", ")", ";", "metadata", ".", "put", "(", "JSON_FILE_EXT", ",", "printJobStatus", ".", "getResult", "(", ")", ".", "getFileExtension", "(", ")", ")", ";", "metadata", ".", "put", "(", "JSON_MIME_TYPE", ",", "printJobStatus", ".", "getResult", "(", ")", ".", "getMimeType", "(", ")", ")", ";", "}", "this", ".", "registry", ".", "put", "(", "RESULT_METADATA", "+", "printJobStatus", ".", "getReferenceId", "(", ")", ",", "metadata", ")", ";", "}" ]
Store the data of a print job in the registry. @param printJobStatus the print job status
[ "Store", "the", "data", "of", "a", "print", "job", "in", "the", "registry", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/RegistryJobQueue.java#L226-L246
159,514
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/style/json/ColorParser.java
ColorParser.canParseColor
public static boolean canParseColor(final String colorString) { try { return ColorParser.toColor(colorString) != null; } catch (Exception exc) { return false; } }
java
public static boolean canParseColor(final String colorString) { try { return ColorParser.toColor(colorString) != null; } catch (Exception exc) { return false; } }
[ "public", "static", "boolean", "canParseColor", "(", "final", "String", "colorString", ")", "{", "try", "{", "return", "ColorParser", ".", "toColor", "(", "colorString", ")", "!=", "null", ";", "}", "catch", "(", "Exception", "exc", ")", "{", "return", "false", ";", "}", "}" ]
Check if the given color string can be parsed. @param colorString The color to parse.
[ "Check", "if", "the", "given", "color", "string", "can", "be", "parsed", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/style/json/ColorParser.java#L283-L289
159,515
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/SetTiledWmsProcessor.java
SetTiledWmsProcessor.adaptTileDimensions
private static Dimension adaptTileDimensions( final Dimension pixels, final int maxWidth, final int maxHeight) { return new Dimension(adaptTileDimension(pixels.width, maxWidth), adaptTileDimension(pixels.height, maxHeight)); }
java
private static Dimension adaptTileDimensions( final Dimension pixels, final int maxWidth, final int maxHeight) { return new Dimension(adaptTileDimension(pixels.width, maxWidth), adaptTileDimension(pixels.height, maxHeight)); }
[ "private", "static", "Dimension", "adaptTileDimensions", "(", "final", "Dimension", "pixels", ",", "final", "int", "maxWidth", ",", "final", "int", "maxHeight", ")", "{", "return", "new", "Dimension", "(", "adaptTileDimension", "(", "pixels", ".", "width", ",", "maxWidth", ")", ",", "adaptTileDimension", "(", "pixels", ".", "height", ",", "maxHeight", ")", ")", ";", "}" ]
Adapt the size of the tiles so that we have the same amount of tiles as we would have had with maxWidth and maxHeight, but with the smallest tiles as possible.
[ "Adapt", "the", "size", "of", "the", "tiles", "so", "that", "we", "have", "the", "same", "amount", "of", "tiles", "as", "we", "would", "have", "had", "with", "maxWidth", "and", "maxHeight", "but", "with", "the", "smallest", "tiles", "as", "possible", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/SetTiledWmsProcessor.java#L67-L71
159,516
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/URIUtils.java
URIUtils.getParameters
public static Multimap<String, String> getParameters(final String rawQuery) { Multimap<String, String> result = HashMultimap.create(); if (rawQuery == null) { return result; } StringTokenizer tokens = new StringTokenizer(rawQuery, "&"); while (tokens.hasMoreTokens()) { String pair = tokens.nextToken(); int pos = pair.indexOf('='); String key; String value; if (pos == -1) { key = pair; value = ""; } else { try { key = URLDecoder.decode(pair.substring(0, pos), "UTF-8"); value = URLDecoder.decode(pair.substring(pos + 1), "UTF-8"); } catch (UnsupportedEncodingException e) { throw ExceptionUtils.getRuntimeException(e); } } result.put(key, value); } return result; }
java
public static Multimap<String, String> getParameters(final String rawQuery) { Multimap<String, String> result = HashMultimap.create(); if (rawQuery == null) { return result; } StringTokenizer tokens = new StringTokenizer(rawQuery, "&"); while (tokens.hasMoreTokens()) { String pair = tokens.nextToken(); int pos = pair.indexOf('='); String key; String value; if (pos == -1) { key = pair; value = ""; } else { try { key = URLDecoder.decode(pair.substring(0, pos), "UTF-8"); value = URLDecoder.decode(pair.substring(pos + 1), "UTF-8"); } catch (UnsupportedEncodingException e) { throw ExceptionUtils.getRuntimeException(e); } } result.put(key, value); } return result; }
[ "public", "static", "Multimap", "<", "String", ",", "String", ">", "getParameters", "(", "final", "String", "rawQuery", ")", "{", "Multimap", "<", "String", ",", "String", ">", "result", "=", "HashMultimap", ".", "create", "(", ")", ";", "if", "(", "rawQuery", "==", "null", ")", "{", "return", "result", ";", "}", "StringTokenizer", "tokens", "=", "new", "StringTokenizer", "(", "rawQuery", ",", "\"&\"", ")", ";", "while", "(", "tokens", ".", "hasMoreTokens", "(", ")", ")", "{", "String", "pair", "=", "tokens", ".", "nextToken", "(", ")", ";", "int", "pos", "=", "pair", ".", "indexOf", "(", "'", "'", ")", ";", "String", "key", ";", "String", "value", ";", "if", "(", "pos", "==", "-", "1", ")", "{", "key", "=", "pair", ";", "value", "=", "\"\"", ";", "}", "else", "{", "try", "{", "key", "=", "URLDecoder", ".", "decode", "(", "pair", ".", "substring", "(", "0", ",", "pos", ")", ",", "\"UTF-8\"", ")", ";", "value", "=", "URLDecoder", ".", "decode", "(", "pair", ".", "substring", "(", "pos", "+", "1", ")", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "ExceptionUtils", ".", "getRuntimeException", "(", "e", ")", ";", "}", "}", "result", ".", "put", "(", "key", ",", "value", ")", ";", "}", "return", "result", ";", "}" ]
Parse the URI and get all the parameters in map form. Query name -&gt; List of Query values. @param rawQuery query portion of the uri to analyze.
[ "Parse", "the", "URI", "and", "get", "all", "the", "parameters", "in", "map", "form", ".", "Query", "name", "-", "&gt", ";", "List", "of", "Query", "values", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/URIUtils.java#L44-L72
159,517
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/URIUtils.java
URIUtils.setQueryParams
public static URI setQueryParams(final URI initialUri, final Multimap<String, String> queryParams) { StringBuilder queryString = new StringBuilder(); for (Map.Entry<String, String> entry: queryParams.entries()) { if (queryString.length() > 0) { queryString.append("&"); } queryString.append(entry.getKey()).append("=").append(entry.getValue()); } try { if (initialUri.getHost() == null && initialUri.getAuthority() != null) { return new URI(initialUri.getScheme(), initialUri.getAuthority(), initialUri.getPath(), queryString.toString(), initialUri.getFragment()); } else { return new URI(initialUri.getScheme(), initialUri.getUserInfo(), initialUri.getHost(), initialUri.getPort(), initialUri.getPath(), queryString.toString(), initialUri.getFragment()); } } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } }
java
public static URI setQueryParams(final URI initialUri, final Multimap<String, String> queryParams) { StringBuilder queryString = new StringBuilder(); for (Map.Entry<String, String> entry: queryParams.entries()) { if (queryString.length() > 0) { queryString.append("&"); } queryString.append(entry.getKey()).append("=").append(entry.getValue()); } try { if (initialUri.getHost() == null && initialUri.getAuthority() != null) { return new URI(initialUri.getScheme(), initialUri.getAuthority(), initialUri.getPath(), queryString.toString(), initialUri.getFragment()); } else { return new URI(initialUri.getScheme(), initialUri.getUserInfo(), initialUri.getHost(), initialUri.getPort(), initialUri.getPath(), queryString.toString(), initialUri.getFragment()); } } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } }
[ "public", "static", "URI", "setQueryParams", "(", "final", "URI", "initialUri", ",", "final", "Multimap", "<", "String", ",", "String", ">", "queryParams", ")", "{", "StringBuilder", "queryString", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "queryParams", ".", "entries", "(", ")", ")", "{", "if", "(", "queryString", ".", "length", "(", ")", ">", "0", ")", "{", "queryString", ".", "append", "(", "\"&\"", ")", ";", "}", "queryString", ".", "append", "(", "entry", ".", "getKey", "(", ")", ")", ".", "append", "(", "\"=\"", ")", ".", "append", "(", "entry", ".", "getValue", "(", ")", ")", ";", "}", "try", "{", "if", "(", "initialUri", ".", "getHost", "(", ")", "==", "null", "&&", "initialUri", ".", "getAuthority", "(", ")", "!=", "null", ")", "{", "return", "new", "URI", "(", "initialUri", ".", "getScheme", "(", ")", ",", "initialUri", ".", "getAuthority", "(", ")", ",", "initialUri", ".", "getPath", "(", ")", ",", "queryString", ".", "toString", "(", ")", ",", "initialUri", ".", "getFragment", "(", ")", ")", ";", "}", "else", "{", "return", "new", "URI", "(", "initialUri", ".", "getScheme", "(", ")", ",", "initialUri", ".", "getUserInfo", "(", ")", ",", "initialUri", ".", "getHost", "(", ")", ",", "initialUri", ".", "getPort", "(", ")", ",", "initialUri", ".", "getPath", "(", ")", ",", "queryString", ".", "toString", "(", ")", ",", "initialUri", ".", "getFragment", "(", ")", ")", ";", "}", "}", "catch", "(", "URISyntaxException", "e", ")", "{", "throw", "ExceptionUtils", ".", "getRuntimeException", "(", "e", ")", ";", "}", "}" ]
Construct a new uri by replacing query parameters in initialUri with the query parameters provided. @param initialUri the initial/template URI @param queryParams the new query parameters.
[ "Construct", "a", "new", "uri", "by", "replacing", "query", "parameters", "in", "initialUri", "with", "the", "query", "parameters", "provided", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/URIUtils.java#L200-L222
159,518
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/URIUtils.java
URIUtils.setPath
public static URI setPath(final URI initialUri, final String path) { String finalPath = path; if (!finalPath.startsWith("/")) { finalPath = '/' + path; } try { if (initialUri.getHost() == null && initialUri.getAuthority() != null) { return new URI(initialUri.getScheme(), initialUri.getAuthority(), finalPath, initialUri.getQuery(), initialUri.getFragment()); } else { return new URI(initialUri.getScheme(), initialUri.getUserInfo(), initialUri.getHost(), initialUri.getPort(), finalPath, initialUri.getQuery(), initialUri.getFragment()); } } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } }
java
public static URI setPath(final URI initialUri, final String path) { String finalPath = path; if (!finalPath.startsWith("/")) { finalPath = '/' + path; } try { if (initialUri.getHost() == null && initialUri.getAuthority() != null) { return new URI(initialUri.getScheme(), initialUri.getAuthority(), finalPath, initialUri.getQuery(), initialUri.getFragment()); } else { return new URI(initialUri.getScheme(), initialUri.getUserInfo(), initialUri.getHost(), initialUri.getPort(), finalPath, initialUri.getQuery(), initialUri.getFragment()); } } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } }
[ "public", "static", "URI", "setPath", "(", "final", "URI", "initialUri", ",", "final", "String", "path", ")", "{", "String", "finalPath", "=", "path", ";", "if", "(", "!", "finalPath", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "finalPath", "=", "'", "'", "+", "path", ";", "}", "try", "{", "if", "(", "initialUri", ".", "getHost", "(", ")", "==", "null", "&&", "initialUri", ".", "getAuthority", "(", ")", "!=", "null", ")", "{", "return", "new", "URI", "(", "initialUri", ".", "getScheme", "(", ")", ",", "initialUri", ".", "getAuthority", "(", ")", ",", "finalPath", ",", "initialUri", ".", "getQuery", "(", ")", ",", "initialUri", ".", "getFragment", "(", ")", ")", ";", "}", "else", "{", "return", "new", "URI", "(", "initialUri", ".", "getScheme", "(", ")", ",", "initialUri", ".", "getUserInfo", "(", ")", ",", "initialUri", ".", "getHost", "(", ")", ",", "initialUri", ".", "getPort", "(", ")", ",", "finalPath", ",", "initialUri", ".", "getQuery", "(", ")", ",", "initialUri", ".", "getFragment", "(", ")", ")", ";", "}", "}", "catch", "(", "URISyntaxException", "e", ")", "{", "throw", "ExceptionUtils", ".", "getRuntimeException", "(", "e", ")", ";", "}", "}" ]
Set the replace of the uri and return the new URI. @param initialUri the starting URI, the URI to update @param path the path to set on the baeURI
[ "Set", "the", "replace", "of", "the", "uri", "and", "return", "the", "new", "URI", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/URIUtils.java#L260-L278
159,519
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/yaml/PYamlArray.java
PYamlArray.toJSON
public final PJsonArray toJSON() { JSONArray jsonArray = new JSONArray(); final int size = this.array.size(); for (int i = 0; i < size; i++) { final Object o = get(i); if (o instanceof PYamlObject) { PYamlObject pYamlObject = (PYamlObject) o; jsonArray.put(pYamlObject.toJSON().getInternalObj()); } else if (o instanceof PYamlArray) { PYamlArray pYamlArray = (PYamlArray) o; jsonArray.put(pYamlArray.toJSON().getInternalArray()); } else { jsonArray.put(o); } } return new PJsonArray(null, jsonArray, getContextName()); }
java
public final PJsonArray toJSON() { JSONArray jsonArray = new JSONArray(); final int size = this.array.size(); for (int i = 0; i < size; i++) { final Object o = get(i); if (o instanceof PYamlObject) { PYamlObject pYamlObject = (PYamlObject) o; jsonArray.put(pYamlObject.toJSON().getInternalObj()); } else if (o instanceof PYamlArray) { PYamlArray pYamlArray = (PYamlArray) o; jsonArray.put(pYamlArray.toJSON().getInternalArray()); } else { jsonArray.put(o); } } return new PJsonArray(null, jsonArray, getContextName()); }
[ "public", "final", "PJsonArray", "toJSON", "(", ")", "{", "JSONArray", "jsonArray", "=", "new", "JSONArray", "(", ")", ";", "final", "int", "size", "=", "this", ".", "array", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "final", "Object", "o", "=", "get", "(", "i", ")", ";", "if", "(", "o", "instanceof", "PYamlObject", ")", "{", "PYamlObject", "pYamlObject", "=", "(", "PYamlObject", ")", "o", ";", "jsonArray", ".", "put", "(", "pYamlObject", ".", "toJSON", "(", ")", ".", "getInternalObj", "(", ")", ")", ";", "}", "else", "if", "(", "o", "instanceof", "PYamlArray", ")", "{", "PYamlArray", "pYamlArray", "=", "(", "PYamlArray", ")", "o", ";", "jsonArray", ".", "put", "(", "pYamlArray", ".", "toJSON", "(", ")", ".", "getInternalArray", "(", ")", ")", ";", "}", "else", "{", "jsonArray", ".", "put", "(", "o", ")", ";", "}", "}", "return", "new", "PJsonArray", "(", "null", ",", "jsonArray", ",", "getContextName", "(", ")", ")", ";", "}" ]
Convert this object to a json array.
[ "Convert", "this", "object", "to", "a", "json", "array", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/yaml/PYamlArray.java#L125-L142
159,520
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/fileloader/ConfigFileLoaderManager.java
ConfigFileLoaderManager.checkUniqueSchemes
@PostConstruct public void checkUniqueSchemes() { Multimap<String, ConfigFileLoaderPlugin> schemeToPluginMap = HashMultimap.create(); for (ConfigFileLoaderPlugin plugin: getLoaderPlugins()) { schemeToPluginMap.put(plugin.getUriScheme(), plugin); } StringBuilder violations = new StringBuilder(); for (String scheme: schemeToPluginMap.keySet()) { final Collection<ConfigFileLoaderPlugin> plugins = schemeToPluginMap.get(scheme); if (plugins.size() > 1) { violations.append("\n\n* ").append("There are has multiple ") .append(ConfigFileLoaderPlugin.class.getSimpleName()) .append(" plugins that support the scheme: '").append(scheme).append('\'') .append(":\n\t").append(plugins); } } if (violations.length() > 0) { throw new IllegalStateException(violations.toString()); } }
java
@PostConstruct public void checkUniqueSchemes() { Multimap<String, ConfigFileLoaderPlugin> schemeToPluginMap = HashMultimap.create(); for (ConfigFileLoaderPlugin plugin: getLoaderPlugins()) { schemeToPluginMap.put(plugin.getUriScheme(), plugin); } StringBuilder violations = new StringBuilder(); for (String scheme: schemeToPluginMap.keySet()) { final Collection<ConfigFileLoaderPlugin> plugins = schemeToPluginMap.get(scheme); if (plugins.size() > 1) { violations.append("\n\n* ").append("There are has multiple ") .append(ConfigFileLoaderPlugin.class.getSimpleName()) .append(" plugins that support the scheme: '").append(scheme).append('\'') .append(":\n\t").append(plugins); } } if (violations.length() > 0) { throw new IllegalStateException(violations.toString()); } }
[ "@", "PostConstruct", "public", "void", "checkUniqueSchemes", "(", ")", "{", "Multimap", "<", "String", ",", "ConfigFileLoaderPlugin", ">", "schemeToPluginMap", "=", "HashMultimap", ".", "create", "(", ")", ";", "for", "(", "ConfigFileLoaderPlugin", "plugin", ":", "getLoaderPlugins", "(", ")", ")", "{", "schemeToPluginMap", ".", "put", "(", "plugin", ".", "getUriScheme", "(", ")", ",", "plugin", ")", ";", "}", "StringBuilder", "violations", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "scheme", ":", "schemeToPluginMap", ".", "keySet", "(", ")", ")", "{", "final", "Collection", "<", "ConfigFileLoaderPlugin", ">", "plugins", "=", "schemeToPluginMap", ".", "get", "(", "scheme", ")", ";", "if", "(", "plugins", ".", "size", "(", ")", ">", "1", ")", "{", "violations", ".", "append", "(", "\"\\n\\n* \"", ")", ".", "append", "(", "\"There are has multiple \"", ")", ".", "append", "(", "ConfigFileLoaderPlugin", ".", "class", ".", "getSimpleName", "(", ")", ")", ".", "append", "(", "\" plugins that support the scheme: '\"", ")", ".", "append", "(", "scheme", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "\":\\n\\t\"", ")", ".", "append", "(", "plugins", ")", ";", "}", "}", "if", "(", "violations", ".", "length", "(", ")", ">", "0", ")", "{", "throw", "new", "IllegalStateException", "(", "violations", ".", "toString", "(", ")", ")", ";", "}", "}" ]
Method is called by spring and verifies that there is only one plugin per URI scheme.
[ "Method", "is", "called", "by", "spring", "and", "verifies", "that", "there", "is", "only", "one", "plugin", "per", "URI", "scheme", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/fileloader/ConfigFileLoaderManager.java#L34-L56
159,521
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/fileloader/ConfigFileLoaderManager.java
ConfigFileLoaderManager.getSupportedUriSchemes
public Set<String> getSupportedUriSchemes() { Set<String> schemes = new HashSet<>(); for (ConfigFileLoaderPlugin loaderPlugin: this.getLoaderPlugins()) { schemes.add(loaderPlugin.getUriScheme()); } return schemes; }
java
public Set<String> getSupportedUriSchemes() { Set<String> schemes = new HashSet<>(); for (ConfigFileLoaderPlugin loaderPlugin: this.getLoaderPlugins()) { schemes.add(loaderPlugin.getUriScheme()); } return schemes; }
[ "public", "Set", "<", "String", ">", "getSupportedUriSchemes", "(", ")", "{", "Set", "<", "String", ">", "schemes", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "ConfigFileLoaderPlugin", "loaderPlugin", ":", "this", ".", "getLoaderPlugins", "(", ")", ")", "{", "schemes", ".", "add", "(", "loaderPlugin", ".", "getUriScheme", "(", ")", ")", ";", "}", "return", "schemes", ";", "}" ]
Return all URI schemes that are supported in the system.
[ "Return", "all", "URI", "schemes", "that", "are", "supported", "in", "the", "system", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/fileloader/ConfigFileLoaderManager.java#L79-L87
159,522
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/GenericMapAttribute.java
GenericMapAttribute.parseProjection
public static CoordinateReferenceSystem parseProjection( final String projection, final Boolean longitudeFirst) { try { if (longitudeFirst == null) { return CRS.decode(projection); } else { return CRS.decode(projection, longitudeFirst); } } catch (NoSuchAuthorityCodeException e) { throw new RuntimeException(projection + " was not recognized as a crs code", e); } catch (FactoryException e) { throw new RuntimeException("Error occurred while parsing: " + projection, e); } }
java
public static CoordinateReferenceSystem parseProjection( final String projection, final Boolean longitudeFirst) { try { if (longitudeFirst == null) { return CRS.decode(projection); } else { return CRS.decode(projection, longitudeFirst); } } catch (NoSuchAuthorityCodeException e) { throw new RuntimeException(projection + " was not recognized as a crs code", e); } catch (FactoryException e) { throw new RuntimeException("Error occurred while parsing: " + projection, e); } }
[ "public", "static", "CoordinateReferenceSystem", "parseProjection", "(", "final", "String", "projection", ",", "final", "Boolean", "longitudeFirst", ")", "{", "try", "{", "if", "(", "longitudeFirst", "==", "null", ")", "{", "return", "CRS", ".", "decode", "(", "projection", ")", ";", "}", "else", "{", "return", "CRS", ".", "decode", "(", "projection", ",", "longitudeFirst", ")", ";", "}", "}", "catch", "(", "NoSuchAuthorityCodeException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "projection", "+", "\" was not recognized as a crs code\"", ",", "e", ")", ";", "}", "catch", "(", "FactoryException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error occurred while parsing: \"", "+", "projection", ",", "e", ")", ";", "}", "}" ]
Parse the given projection. @param projection The projection string. @param longitudeFirst longitudeFirst
[ "Parse", "the", "given", "projection", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/GenericMapAttribute.java#L84-L97
159,523
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/GenericMapAttribute.java
GenericMapAttribute.getDpiSuggestions
public final double[] getDpiSuggestions() { if (this.dpiSuggestions == null) { List<Double> list = new ArrayList<>(); for (double suggestion: DEFAULT_DPI_VALUES) { if (suggestion <= this.maxDpi) { list.add(suggestion); } } double[] suggestions = new double[list.size()]; for (int i = 0; i < suggestions.length; i++) { suggestions[i] = list.get(i); } return suggestions; } return this.dpiSuggestions; }
java
public final double[] getDpiSuggestions() { if (this.dpiSuggestions == null) { List<Double> list = new ArrayList<>(); for (double suggestion: DEFAULT_DPI_VALUES) { if (suggestion <= this.maxDpi) { list.add(suggestion); } } double[] suggestions = new double[list.size()]; for (int i = 0; i < suggestions.length; i++) { suggestions[i] = list.get(i); } return suggestions; } return this.dpiSuggestions; }
[ "public", "final", "double", "[", "]", "getDpiSuggestions", "(", ")", "{", "if", "(", "this", ".", "dpiSuggestions", "==", "null", ")", "{", "List", "<", "Double", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "double", "suggestion", ":", "DEFAULT_DPI_VALUES", ")", "{", "if", "(", "suggestion", "<=", "this", ".", "maxDpi", ")", "{", "list", ".", "add", "(", "suggestion", ")", ";", "}", "}", "double", "[", "]", "suggestions", "=", "new", "double", "[", "list", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "suggestions", ".", "length", ";", "i", "++", ")", "{", "suggestions", "[", "i", "]", "=", "list", ".", "get", "(", "i", ")", ";", "}", "return", "suggestions", ";", "}", "return", "this", ".", "dpiSuggestions", ";", "}" ]
Get DPI suggestions. @return DPI suggestions
[ "Get", "DPI", "suggestions", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/GenericMapAttribute.java#L119-L134
159,524
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java
AbstractSingleImageLayer.createErrorImage
protected BufferedImage createErrorImage(final Rectangle area) { final BufferedImage bufferedImage = new BufferedImage(area.width, area.height, TYPE_INT_ARGB_PRE); final Graphics2D graphics = bufferedImage.createGraphics(); try { graphics.setBackground(ColorParser.toColor(this.configuration.getTransparentTileErrorColor())); graphics.clearRect(0, 0, area.width, area.height); return bufferedImage; } finally { graphics.dispose(); } }
java
protected BufferedImage createErrorImage(final Rectangle area) { final BufferedImage bufferedImage = new BufferedImage(area.width, area.height, TYPE_INT_ARGB_PRE); final Graphics2D graphics = bufferedImage.createGraphics(); try { graphics.setBackground(ColorParser.toColor(this.configuration.getTransparentTileErrorColor())); graphics.clearRect(0, 0, area.width, area.height); return bufferedImage; } finally { graphics.dispose(); } }
[ "protected", "BufferedImage", "createErrorImage", "(", "final", "Rectangle", "area", ")", "{", "final", "BufferedImage", "bufferedImage", "=", "new", "BufferedImage", "(", "area", ".", "width", ",", "area", ".", "height", ",", "TYPE_INT_ARGB_PRE", ")", ";", "final", "Graphics2D", "graphics", "=", "bufferedImage", ".", "createGraphics", "(", ")", ";", "try", "{", "graphics", ".", "setBackground", "(", "ColorParser", ".", "toColor", "(", "this", ".", "configuration", ".", "getTransparentTileErrorColor", "(", ")", ")", ")", ";", "graphics", ".", "clearRect", "(", "0", ",", "0", ",", "area", ".", "width", ",", "area", ".", "height", ")", ";", "return", "bufferedImage", ";", "}", "finally", "{", "graphics", ".", "dispose", "(", ")", ";", "}", "}" ]
Create an error image. @param area The size of the image
[ "Create", "an", "error", "image", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java#L133-L143
159,525
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java
AbstractSingleImageLayer.fetchImage
protected BufferedImage fetchImage( @Nonnull final ClientHttpRequest request, @Nonnull final MapfishMapContext transformer) throws IOException { final String baseMetricName = getClass().getName() + ".read." + StatsUtils.quotePart(request.getURI().getHost()); final Timer.Context timerDownload = this.registry.timer(baseMetricName).time(); try (ClientHttpResponse httpResponse = request.execute()) { if (httpResponse.getStatusCode() != HttpStatus.OK) { final String message = String.format( "Invalid status code for %s (%d!=%d). The response was: '%s'", request.getURI(), httpResponse.getStatusCode().value(), HttpStatus.OK.value(), httpResponse.getStatusText()); this.registry.counter(baseMetricName + ".error").inc(); if (getFailOnError()) { throw new RuntimeException(message); } else { LOGGER.info(message); return createErrorImage(transformer.getPaintArea()); } } final List<String> contentType = httpResponse.getHeaders().get("Content-Type"); if (contentType == null || contentType.size() != 1) { LOGGER.debug("The image {} didn't return a valid content type header.", request.getURI()); } else if (!contentType.get(0).startsWith("image/")) { final byte[] data; try (InputStream body = httpResponse.getBody()) { data = IOUtils.toByteArray(body); } LOGGER.debug("We get a wrong image for {}, content type: {}\nresult:\n{}", request.getURI(), contentType.get(0), new String(data, StandardCharsets.UTF_8)); this.registry.counter(baseMetricName + ".error").inc(); return createErrorImage(transformer.getPaintArea()); } final BufferedImage image = ImageIO.read(httpResponse.getBody()); if (image == null) { LOGGER.warn("Cannot read image from %a", request.getURI()); this.registry.counter(baseMetricName + ".error").inc(); if (getFailOnError()) { throw new RuntimeException("Cannot read image from " + request.getURI()); } else { return createErrorImage(transformer.getPaintArea()); } } timerDownload.stop(); return image; } catch (Throwable e) { this.registry.counter(baseMetricName + ".error").inc(); throw e; } }
java
protected BufferedImage fetchImage( @Nonnull final ClientHttpRequest request, @Nonnull final MapfishMapContext transformer) throws IOException { final String baseMetricName = getClass().getName() + ".read." + StatsUtils.quotePart(request.getURI().getHost()); final Timer.Context timerDownload = this.registry.timer(baseMetricName).time(); try (ClientHttpResponse httpResponse = request.execute()) { if (httpResponse.getStatusCode() != HttpStatus.OK) { final String message = String.format( "Invalid status code for %s (%d!=%d). The response was: '%s'", request.getURI(), httpResponse.getStatusCode().value(), HttpStatus.OK.value(), httpResponse.getStatusText()); this.registry.counter(baseMetricName + ".error").inc(); if (getFailOnError()) { throw new RuntimeException(message); } else { LOGGER.info(message); return createErrorImage(transformer.getPaintArea()); } } final List<String> contentType = httpResponse.getHeaders().get("Content-Type"); if (contentType == null || contentType.size() != 1) { LOGGER.debug("The image {} didn't return a valid content type header.", request.getURI()); } else if (!contentType.get(0).startsWith("image/")) { final byte[] data; try (InputStream body = httpResponse.getBody()) { data = IOUtils.toByteArray(body); } LOGGER.debug("We get a wrong image for {}, content type: {}\nresult:\n{}", request.getURI(), contentType.get(0), new String(data, StandardCharsets.UTF_8)); this.registry.counter(baseMetricName + ".error").inc(); return createErrorImage(transformer.getPaintArea()); } final BufferedImage image = ImageIO.read(httpResponse.getBody()); if (image == null) { LOGGER.warn("Cannot read image from %a", request.getURI()); this.registry.counter(baseMetricName + ".error").inc(); if (getFailOnError()) { throw new RuntimeException("Cannot read image from " + request.getURI()); } else { return createErrorImage(transformer.getPaintArea()); } } timerDownload.stop(); return image; } catch (Throwable e) { this.registry.counter(baseMetricName + ".error").inc(); throw e; } }
[ "protected", "BufferedImage", "fetchImage", "(", "@", "Nonnull", "final", "ClientHttpRequest", "request", ",", "@", "Nonnull", "final", "MapfishMapContext", "transformer", ")", "throws", "IOException", "{", "final", "String", "baseMetricName", "=", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\".read.\"", "+", "StatsUtils", ".", "quotePart", "(", "request", ".", "getURI", "(", ")", ".", "getHost", "(", ")", ")", ";", "final", "Timer", ".", "Context", "timerDownload", "=", "this", ".", "registry", ".", "timer", "(", "baseMetricName", ")", ".", "time", "(", ")", ";", "try", "(", "ClientHttpResponse", "httpResponse", "=", "request", ".", "execute", "(", ")", ")", "{", "if", "(", "httpResponse", ".", "getStatusCode", "(", ")", "!=", "HttpStatus", ".", "OK", ")", "{", "final", "String", "message", "=", "String", ".", "format", "(", "\"Invalid status code for %s (%d!=%d). The response was: '%s'\"", ",", "request", ".", "getURI", "(", ")", ",", "httpResponse", ".", "getStatusCode", "(", ")", ".", "value", "(", ")", ",", "HttpStatus", ".", "OK", ".", "value", "(", ")", ",", "httpResponse", ".", "getStatusText", "(", ")", ")", ";", "this", ".", "registry", ".", "counter", "(", "baseMetricName", "+", "\".error\"", ")", ".", "inc", "(", ")", ";", "if", "(", "getFailOnError", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "message", ")", ";", "}", "else", "{", "LOGGER", ".", "info", "(", "message", ")", ";", "return", "createErrorImage", "(", "transformer", ".", "getPaintArea", "(", ")", ")", ";", "}", "}", "final", "List", "<", "String", ">", "contentType", "=", "httpResponse", ".", "getHeaders", "(", ")", ".", "get", "(", "\"Content-Type\"", ")", ";", "if", "(", "contentType", "==", "null", "||", "contentType", ".", "size", "(", ")", "!=", "1", ")", "{", "LOGGER", ".", "debug", "(", "\"The image {} didn't return a valid content type header.\"", ",", "request", ".", "getURI", "(", ")", ")", ";", "}", "else", "if", "(", "!", "contentType", ".", "get", "(", "0", ")", ".", "startsWith", "(", "\"image/\"", ")", ")", "{", "final", "byte", "[", "]", "data", ";", "try", "(", "InputStream", "body", "=", "httpResponse", ".", "getBody", "(", ")", ")", "{", "data", "=", "IOUtils", ".", "toByteArray", "(", "body", ")", ";", "}", "LOGGER", ".", "debug", "(", "\"We get a wrong image for {}, content type: {}\\nresult:\\n{}\"", ",", "request", ".", "getURI", "(", ")", ",", "contentType", ".", "get", "(", "0", ")", ",", "new", "String", "(", "data", ",", "StandardCharsets", ".", "UTF_8", ")", ")", ";", "this", ".", "registry", ".", "counter", "(", "baseMetricName", "+", "\".error\"", ")", ".", "inc", "(", ")", ";", "return", "createErrorImage", "(", "transformer", ".", "getPaintArea", "(", ")", ")", ";", "}", "final", "BufferedImage", "image", "=", "ImageIO", ".", "read", "(", "httpResponse", ".", "getBody", "(", ")", ")", ";", "if", "(", "image", "==", "null", ")", "{", "LOGGER", ".", "warn", "(", "\"Cannot read image from %a\"", ",", "request", ".", "getURI", "(", ")", ")", ";", "this", ".", "registry", ".", "counter", "(", "baseMetricName", "+", "\".error\"", ")", ".", "inc", "(", ")", ";", "if", "(", "getFailOnError", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Cannot read image from \"", "+", "request", ".", "getURI", "(", ")", ")", ";", "}", "else", "{", "return", "createErrorImage", "(", "transformer", ".", "getPaintArea", "(", ")", ")", ";", "}", "}", "timerDownload", ".", "stop", "(", ")", ";", "return", "image", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "this", ".", "registry", ".", "counter", "(", "baseMetricName", "+", "\".error\"", ")", ".", "inc", "(", ")", ";", "throw", "e", ";", "}", "}" ]
Fetch the given image from the web. @param request The request @param transformer The transformer @return The image
[ "Fetch", "the", "given", "image", "from", "the", "web", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java#L152-L205
159,526
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/SetsUtils.java
SetsUtils.create
@SafeVarargs public static <T> Set<T> create(final T... values) { Set<T> result = new HashSet<>(values.length); Collections.addAll(result, values); return result; }
java
@SafeVarargs public static <T> Set<T> create(final T... values) { Set<T> result = new HashSet<>(values.length); Collections.addAll(result, values); return result; }
[ "@", "SafeVarargs", "public", "static", "<", "T", ">", "Set", "<", "T", ">", "create", "(", "final", "T", "...", "values", ")", "{", "Set", "<", "T", ">", "result", "=", "new", "HashSet", "<>", "(", "values", ".", "length", ")", ";", "Collections", ".", "addAll", "(", "result", ",", "values", ")", ";", "return", "result", ";", "}" ]
Create a HashSet with the given initial values. @param values The values @param <T> The type.
[ "Create", "a", "HashSet", "with", "the", "given", "initial", "values", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/SetsUtils.java#L20-L25
159,527
mjiderhamn/classloader-leak-prevention
classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/ShutdownHookCleanUp.java
ShutdownHookCleanUp.removeShutdownHook
@SuppressWarnings({"deprecation", "WeakerAccess"}) protected void removeShutdownHook(ClassLoaderLeakPreventor preventor, Thread shutdownHook) { final String displayString = "'" + shutdownHook + "' of type " + shutdownHook.getClass().getName(); preventor.error("Removing shutdown hook: " + displayString); Runtime.getRuntime().removeShutdownHook(shutdownHook); if(executeShutdownHooks) { // Shutdown hooks should be executed preventor.info("Executing shutdown hook now: " + displayString); // Make sure it's from protected ClassLoader shutdownHook.start(); // Run cleanup immediately if(shutdownHookWaitMs > 0) { // Wait for shutdown hook to finish try { shutdownHook.join(shutdownHookWaitMs); // Wait for thread to run } catch (InterruptedException e) { // Do nothing } if(shutdownHook.isAlive()) { preventor.warn(shutdownHook + "still running after " + shutdownHookWaitMs + " ms - Stopping!"); shutdownHook.stop(); } } } }
java
@SuppressWarnings({"deprecation", "WeakerAccess"}) protected void removeShutdownHook(ClassLoaderLeakPreventor preventor, Thread shutdownHook) { final String displayString = "'" + shutdownHook + "' of type " + shutdownHook.getClass().getName(); preventor.error("Removing shutdown hook: " + displayString); Runtime.getRuntime().removeShutdownHook(shutdownHook); if(executeShutdownHooks) { // Shutdown hooks should be executed preventor.info("Executing shutdown hook now: " + displayString); // Make sure it's from protected ClassLoader shutdownHook.start(); // Run cleanup immediately if(shutdownHookWaitMs > 0) { // Wait for shutdown hook to finish try { shutdownHook.join(shutdownHookWaitMs); // Wait for thread to run } catch (InterruptedException e) { // Do nothing } if(shutdownHook.isAlive()) { preventor.warn(shutdownHook + "still running after " + shutdownHookWaitMs + " ms - Stopping!"); shutdownHook.stop(); } } } }
[ "@", "SuppressWarnings", "(", "{", "\"deprecation\"", ",", "\"WeakerAccess\"", "}", ")", "protected", "void", "removeShutdownHook", "(", "ClassLoaderLeakPreventor", "preventor", ",", "Thread", "shutdownHook", ")", "{", "final", "String", "displayString", "=", "\"'\"", "+", "shutdownHook", "+", "\"' of type \"", "+", "shutdownHook", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "preventor", ".", "error", "(", "\"Removing shutdown hook: \"", "+", "displayString", ")", ";", "Runtime", ".", "getRuntime", "(", ")", ".", "removeShutdownHook", "(", "shutdownHook", ")", ";", "if", "(", "executeShutdownHooks", ")", "{", "// Shutdown hooks should be executed", "preventor", ".", "info", "(", "\"Executing shutdown hook now: \"", "+", "displayString", ")", ";", "// Make sure it's from protected ClassLoader", "shutdownHook", ".", "start", "(", ")", ";", "// Run cleanup immediately", "if", "(", "shutdownHookWaitMs", ">", "0", ")", "{", "// Wait for shutdown hook to finish", "try", "{", "shutdownHook", ".", "join", "(", "shutdownHookWaitMs", ")", ";", "// Wait for thread to run", "}", "catch", "(", "InterruptedException", "e", ")", "{", "// Do nothing", "}", "if", "(", "shutdownHook", ".", "isAlive", "(", ")", ")", "{", "preventor", ".", "warn", "(", "shutdownHook", "+", "\"still running after \"", "+", "shutdownHookWaitMs", "+", "\" ms - Stopping!\"", ")", ";", "shutdownHook", ".", "stop", "(", ")", ";", "}", "}", "}", "}" ]
Deregister shutdown hook and execute it immediately
[ "Deregister", "shutdown", "hook", "and", "execute", "it", "immediately" ]
eea8e3cef64f8096dbbb87552df0a1bd272bcb63
https://github.com/mjiderhamn/classloader-leak-prevention/blob/eea8e3cef64f8096dbbb87552df0a1bd272bcb63/classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/ShutdownHookCleanUp.java#L65-L90
159,528
mjiderhamn/classloader-leak-prevention
classloader-leak-prevention/classloader-leak-prevention-servlet/src/main/java/se/jiderhamn/classloader/leak/prevention/ClassLoaderLeakPreventorListener.java
ClassLoaderLeakPreventorListener.getIntInitParameter
protected static int getIntInitParameter(ServletContext servletContext, String parameterName, int defaultValue) { final String parameterString = servletContext.getInitParameter(parameterName); if(parameterString != null && parameterString.trim().length() > 0) { try { return Integer.parseInt(parameterString); } catch (NumberFormatException e) { // Do nothing, return default value } } return defaultValue; }
java
protected static int getIntInitParameter(ServletContext servletContext, String parameterName, int defaultValue) { final String parameterString = servletContext.getInitParameter(parameterName); if(parameterString != null && parameterString.trim().length() > 0) { try { return Integer.parseInt(parameterString); } catch (NumberFormatException e) { // Do nothing, return default value } } return defaultValue; }
[ "protected", "static", "int", "getIntInitParameter", "(", "ServletContext", "servletContext", ",", "String", "parameterName", ",", "int", "defaultValue", ")", "{", "final", "String", "parameterString", "=", "servletContext", ".", "getInitParameter", "(", "parameterName", ")", ";", "if", "(", "parameterString", "!=", "null", "&&", "parameterString", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "try", "{", "return", "Integer", ".", "parseInt", "(", "parameterString", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "// Do nothing, return default value", "}", "}", "return", "defaultValue", ";", "}" ]
Parse init parameter for integer value, returning default if not found or invalid
[ "Parse", "init", "parameter", "for", "integer", "value", "returning", "default", "if", "not", "found", "or", "invalid" ]
eea8e3cef64f8096dbbb87552df0a1bd272bcb63
https://github.com/mjiderhamn/classloader-leak-prevention/blob/eea8e3cef64f8096dbbb87552df0a1bd272bcb63/classloader-leak-prevention/classloader-leak-prevention-servlet/src/main/java/se/jiderhamn/classloader/leak/prevention/ClassLoaderLeakPreventorListener.java#L255-L266
159,529
mjiderhamn/classloader-leak-prevention
classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/RmiTargetsCleanUp.java
RmiTargetsCleanUp.clearRmiTargetsMap
@SuppressWarnings("WeakerAccess") protected void clearRmiTargetsMap(ClassLoaderLeakPreventor preventor, Map<?, ?> rmiTargetsMap) { try { final Field cclField = preventor.findFieldOfClass("sun.rmi.transport.Target", "ccl"); preventor.debug("Looping " + rmiTargetsMap.size() + " RMI Targets to find leaks"); for(Iterator<?> iter = rmiTargetsMap.values().iterator(); iter.hasNext(); ) { Object target = iter.next(); // sun.rmi.transport.Target ClassLoader ccl = (ClassLoader) cclField.get(target); if(preventor.isClassLoaderOrChild(ccl)) { preventor.warn("Removing RMI Target: " + target); iter.remove(); } } } catch (Exception ex) { preventor.error(ex); } }
java
@SuppressWarnings("WeakerAccess") protected void clearRmiTargetsMap(ClassLoaderLeakPreventor preventor, Map<?, ?> rmiTargetsMap) { try { final Field cclField = preventor.findFieldOfClass("sun.rmi.transport.Target", "ccl"); preventor.debug("Looping " + rmiTargetsMap.size() + " RMI Targets to find leaks"); for(Iterator<?> iter = rmiTargetsMap.values().iterator(); iter.hasNext(); ) { Object target = iter.next(); // sun.rmi.transport.Target ClassLoader ccl = (ClassLoader) cclField.get(target); if(preventor.isClassLoaderOrChild(ccl)) { preventor.warn("Removing RMI Target: " + target); iter.remove(); } } } catch (Exception ex) { preventor.error(ex); } }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "protected", "void", "clearRmiTargetsMap", "(", "ClassLoaderLeakPreventor", "preventor", ",", "Map", "<", "?", ",", "?", ">", "rmiTargetsMap", ")", "{", "try", "{", "final", "Field", "cclField", "=", "preventor", ".", "findFieldOfClass", "(", "\"sun.rmi.transport.Target\"", ",", "\"ccl\"", ")", ";", "preventor", ".", "debug", "(", "\"Looping \"", "+", "rmiTargetsMap", ".", "size", "(", ")", "+", "\" RMI Targets to find leaks\"", ")", ";", "for", "(", "Iterator", "<", "?", ">", "iter", "=", "rmiTargetsMap", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "target", "=", "iter", ".", "next", "(", ")", ";", "// sun.rmi.transport.Target", "ClassLoader", "ccl", "=", "(", "ClassLoader", ")", "cclField", ".", "get", "(", "target", ")", ";", "if", "(", "preventor", ".", "isClassLoaderOrChild", "(", "ccl", ")", ")", "{", "preventor", ".", "warn", "(", "\"Removing RMI Target: \"", "+", "target", ")", ";", "iter", ".", "remove", "(", ")", ";", "}", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "preventor", ".", "error", "(", "ex", ")", ";", "}", "}" ]
Iterate RMI Targets Map and remove entries loaded by protected ClassLoader
[ "Iterate", "RMI", "Targets", "Map", "and", "remove", "entries", "loaded", "by", "protected", "ClassLoader" ]
eea8e3cef64f8096dbbb87552df0a1bd272bcb63
https://github.com/mjiderhamn/classloader-leak-prevention/blob/eea8e3cef64f8096dbbb87552df0a1bd272bcb63/classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/RmiTargetsCleanUp.java#L30-L47
159,530
mjiderhamn/classloader-leak-prevention
classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/MBeanCleanUp.java
MBeanCleanUp.isJettyWithJMX
@SuppressWarnings("WeakerAccess") protected boolean isJettyWithJMX(ClassLoaderLeakPreventor preventor) { final ClassLoader classLoader = preventor.getClassLoader(); try { // If package org.eclipse.jetty is found, we may be running under jetty if (classLoader.getResource("org/eclipse/jetty") == null) { return false; } Class.forName("org.eclipse.jetty.jmx.MBeanContainer", false, classLoader.getParent()); // JMX enabled? Class.forName("org.eclipse.jetty.webapp.WebAppContext", false, classLoader.getParent()); } catch(Exception ex) { // For example ClassNotFoundException return false; } // Seems we are running in Jetty with JMX enabled return true; }
java
@SuppressWarnings("WeakerAccess") protected boolean isJettyWithJMX(ClassLoaderLeakPreventor preventor) { final ClassLoader classLoader = preventor.getClassLoader(); try { // If package org.eclipse.jetty is found, we may be running under jetty if (classLoader.getResource("org/eclipse/jetty") == null) { return false; } Class.forName("org.eclipse.jetty.jmx.MBeanContainer", false, classLoader.getParent()); // JMX enabled? Class.forName("org.eclipse.jetty.webapp.WebAppContext", false, classLoader.getParent()); } catch(Exception ex) { // For example ClassNotFoundException return false; } // Seems we are running in Jetty with JMX enabled return true; }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "protected", "boolean", "isJettyWithJMX", "(", "ClassLoaderLeakPreventor", "preventor", ")", "{", "final", "ClassLoader", "classLoader", "=", "preventor", ".", "getClassLoader", "(", ")", ";", "try", "{", "// If package org.eclipse.jetty is found, we may be running under jetty", "if", "(", "classLoader", ".", "getResource", "(", "\"org/eclipse/jetty\"", ")", "==", "null", ")", "{", "return", "false", ";", "}", "Class", ".", "forName", "(", "\"org.eclipse.jetty.jmx.MBeanContainer\"", ",", "false", ",", "classLoader", ".", "getParent", "(", ")", ")", ";", "// JMX enabled?", "Class", ".", "forName", "(", "\"org.eclipse.jetty.webapp.WebAppContext\"", ",", "false", ",", "classLoader", ".", "getParent", "(", ")", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "// For example ClassNotFoundException", "return", "false", ";", "}", "// Seems we are running in Jetty with JMX enabled", "return", "true", ";", "}" ]
Are we running in Jetty with JMX enabled?
[ "Are", "we", "running", "in", "Jetty", "with", "JMX", "enabled?" ]
eea8e3cef64f8096dbbb87552df0a1bd272bcb63
https://github.com/mjiderhamn/classloader-leak-prevention/blob/eea8e3cef64f8096dbbb87552df0a1bd272bcb63/classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/MBeanCleanUp.java#L71-L89
159,531
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashMap.java
LongHashMap.keys
public long[] keys() { long[] values = new long[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { values[idx++] = entry.key; entry = entry.next; } } return values; }
java
public long[] keys() { long[] values = new long[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { values[idx++] = entry.key; entry = entry.next; } } return values; }
[ "public", "long", "[", "]", "keys", "(", ")", "{", "long", "[", "]", "values", "=", "new", "long", "[", "size", "]", ";", "int", "idx", "=", "0", ";", "for", "(", "Entry", "entry", ":", "table", ")", "{", "while", "(", "entry", "!=", "null", ")", "{", "values", "[", "idx", "++", "]", "=", "entry", ".", "key", ";", "entry", "=", "entry", ".", "next", ";", "}", "}", "return", "values", ";", "}" ]
Returns all keys in no particular order.
[ "Returns", "all", "keys", "in", "no", "particular", "order", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashMap.java#L136-L146
159,532
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashMap.java
LongHashMap.entries
public Entry<T>[] entries() { @SuppressWarnings("unchecked") Entry<T>[] entries = new Entry[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { entries[idx++] = entry; entry = entry.next; } } return entries; }
java
public Entry<T>[] entries() { @SuppressWarnings("unchecked") Entry<T>[] entries = new Entry[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { entries[idx++] = entry; entry = entry.next; } } return entries; }
[ "public", "Entry", "<", "T", ">", "[", "]", "entries", "(", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Entry", "<", "T", ">", "[", "]", "entries", "=", "new", "Entry", "[", "size", "]", ";", "int", "idx", "=", "0", ";", "for", "(", "Entry", "entry", ":", "table", ")", "{", "while", "(", "entry", "!=", "null", ")", "{", "entries", "[", "idx", "++", "]", "=", "entry", ";", "entry", "=", "entry", ".", "next", ";", "}", "}", "return", "entries", ";", "}" ]
Returns all entries in no particular order.
[ "Returns", "all", "entries", "in", "no", "particular", "order", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashMap.java#L151-L162
159,533
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashSet.java
LongHashSet.add
public boolean add(long key) { final int index = ((((int) (key >>> 32)) ^ ((int) (key))) & 0x7fffffff) % capacity; final Entry entryOriginal = table[index]; for (Entry entry = entryOriginal; entry != null; entry = entry.next) { if (entry.key == key) { return false; } } table[index] = new Entry(key, entryOriginal); size++; if (size > threshold) { setCapacity(2 * capacity); } return true; }
java
public boolean add(long key) { final int index = ((((int) (key >>> 32)) ^ ((int) (key))) & 0x7fffffff) % capacity; final Entry entryOriginal = table[index]; for (Entry entry = entryOriginal; entry != null; entry = entry.next) { if (entry.key == key) { return false; } } table[index] = new Entry(key, entryOriginal); size++; if (size > threshold) { setCapacity(2 * capacity); } return true; }
[ "public", "boolean", "add", "(", "long", "key", ")", "{", "final", "int", "index", "=", "(", "(", "(", "(", "int", ")", "(", "key", ">>>", "32", ")", ")", "^", "(", "(", "int", ")", "(", "key", ")", ")", ")", "&", "0x7fffffff", ")", "%", "capacity", ";", "final", "Entry", "entryOriginal", "=", "table", "[", "index", "]", ";", "for", "(", "Entry", "entry", "=", "entryOriginal", ";", "entry", "!=", "null", ";", "entry", "=", "entry", ".", "next", ")", "{", "if", "(", "entry", ".", "key", "==", "key", ")", "{", "return", "false", ";", "}", "}", "table", "[", "index", "]", "=", "new", "Entry", "(", "key", ",", "entryOriginal", ")", ";", "size", "++", ";", "if", "(", "size", ">", "threshold", ")", "{", "setCapacity", "(", "2", "*", "capacity", ")", ";", "}", "return", "true", ";", "}" ]
Adds the given value to the set. @return true if the value was actually new
[ "Adds", "the", "given", "value", "to", "the", "set", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashSet.java#L88-L102
159,534
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashSet.java
LongHashSet.remove
public boolean remove(long key) { int index = ((((int) (key >>> 32)) ^ ((int) (key))) & 0x7fffffff) % capacity; Entry previous = null; Entry entry = table[index]; while (entry != null) { Entry next = entry.next; if (entry.key == key) { if (previous == null) { table[index] = next; } else { previous.next = next; } size--; return true; } previous = entry; entry = next; } return false; }
java
public boolean remove(long key) { int index = ((((int) (key >>> 32)) ^ ((int) (key))) & 0x7fffffff) % capacity; Entry previous = null; Entry entry = table[index]; while (entry != null) { Entry next = entry.next; if (entry.key == key) { if (previous == null) { table[index] = next; } else { previous.next = next; } size--; return true; } previous = entry; entry = next; } return false; }
[ "public", "boolean", "remove", "(", "long", "key", ")", "{", "int", "index", "=", "(", "(", "(", "(", "int", ")", "(", "key", ">>>", "32", ")", ")", "^", "(", "(", "int", ")", "(", "key", ")", ")", ")", "&", "0x7fffffff", ")", "%", "capacity", ";", "Entry", "previous", "=", "null", ";", "Entry", "entry", "=", "table", "[", "index", "]", ";", "while", "(", "entry", "!=", "null", ")", "{", "Entry", "next", "=", "entry", ".", "next", ";", "if", "(", "entry", ".", "key", "==", "key", ")", "{", "if", "(", "previous", "==", "null", ")", "{", "table", "[", "index", "]", "=", "next", ";", "}", "else", "{", "previous", ".", "next", "=", "next", ";", "}", "size", "--", ";", "return", "true", ";", "}", "previous", "=", "entry", ";", "entry", "=", "next", ";", "}", "return", "false", ";", "}" ]
Removes the given value to the set. @return true if the value was actually removed
[ "Removes", "the", "given", "value", "to", "the", "set", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashSet.java#L109-L128
159,535
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java
ObjectCache.put
public VALUE put(KEY key, VALUE object) { CacheEntry<VALUE> entry; if (referenceType == ReferenceType.WEAK) { entry = new CacheEntry<>(new WeakReference<>(object), null); } else if (referenceType == ReferenceType.SOFT) { entry = new CacheEntry<>(new SoftReference<>(object), null); } else { entry = new CacheEntry<>(null, object); } countPutCountSinceEviction++; countPut++; if (isExpiring && nextCleanUpTimestamp == 0) { nextCleanUpTimestamp = System.currentTimeMillis() + expirationMillis + 1; } CacheEntry<VALUE> oldEntry; synchronized (this) { if (values.size() >= maxSize) { evictToTargetSize(maxSize - 1); } oldEntry = values.put(key, entry); } return getValueForRemoved(oldEntry); }
java
public VALUE put(KEY key, VALUE object) { CacheEntry<VALUE> entry; if (referenceType == ReferenceType.WEAK) { entry = new CacheEntry<>(new WeakReference<>(object), null); } else if (referenceType == ReferenceType.SOFT) { entry = new CacheEntry<>(new SoftReference<>(object), null); } else { entry = new CacheEntry<>(null, object); } countPutCountSinceEviction++; countPut++; if (isExpiring && nextCleanUpTimestamp == 0) { nextCleanUpTimestamp = System.currentTimeMillis() + expirationMillis + 1; } CacheEntry<VALUE> oldEntry; synchronized (this) { if (values.size() >= maxSize) { evictToTargetSize(maxSize - 1); } oldEntry = values.put(key, entry); } return getValueForRemoved(oldEntry); }
[ "public", "VALUE", "put", "(", "KEY", "key", ",", "VALUE", "object", ")", "{", "CacheEntry", "<", "VALUE", ">", "entry", ";", "if", "(", "referenceType", "==", "ReferenceType", ".", "WEAK", ")", "{", "entry", "=", "new", "CacheEntry", "<>", "(", "new", "WeakReference", "<>", "(", "object", ")", ",", "null", ")", ";", "}", "else", "if", "(", "referenceType", "==", "ReferenceType", ".", "SOFT", ")", "{", "entry", "=", "new", "CacheEntry", "<>", "(", "new", "SoftReference", "<>", "(", "object", ")", ",", "null", ")", ";", "}", "else", "{", "entry", "=", "new", "CacheEntry", "<>", "(", "null", ",", "object", ")", ";", "}", "countPutCountSinceEviction", "++", ";", "countPut", "++", ";", "if", "(", "isExpiring", "&&", "nextCleanUpTimestamp", "==", "0", ")", "{", "nextCleanUpTimestamp", "=", "System", ".", "currentTimeMillis", "(", ")", "+", "expirationMillis", "+", "1", ";", "}", "CacheEntry", "<", "VALUE", ">", "oldEntry", ";", "synchronized", "(", "this", ")", "{", "if", "(", "values", ".", "size", "(", ")", ">=", "maxSize", ")", "{", "evictToTargetSize", "(", "maxSize", "-", "1", ")", ";", "}", "oldEntry", "=", "values", ".", "put", "(", "key", ",", "entry", ")", ";", "}", "return", "getValueForRemoved", "(", "oldEntry", ")", ";", "}" ]
Stores an new entry in the cache.
[ "Stores", "an", "new", "entry", "in", "the", "cache", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java#L91-L115
159,536
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java
ObjectCache.putAll
public void putAll(Map<KEY, VALUE> mapDataToPut) { int targetSize = maxSize - mapDataToPut.size(); if (maxSize > 0 && values.size() > targetSize) { evictToTargetSize(targetSize); } Set<Entry<KEY, VALUE>> entries = mapDataToPut.entrySet(); for (Entry<KEY, VALUE> entry : entries) { put(entry.getKey(), entry.getValue()); } }
java
public void putAll(Map<KEY, VALUE> mapDataToPut) { int targetSize = maxSize - mapDataToPut.size(); if (maxSize > 0 && values.size() > targetSize) { evictToTargetSize(targetSize); } Set<Entry<KEY, VALUE>> entries = mapDataToPut.entrySet(); for (Entry<KEY, VALUE> entry : entries) { put(entry.getKey(), entry.getValue()); } }
[ "public", "void", "putAll", "(", "Map", "<", "KEY", ",", "VALUE", ">", "mapDataToPut", ")", "{", "int", "targetSize", "=", "maxSize", "-", "mapDataToPut", ".", "size", "(", ")", ";", "if", "(", "maxSize", ">", "0", "&&", "values", ".", "size", "(", ")", ">", "targetSize", ")", "{", "evictToTargetSize", "(", "targetSize", ")", ";", "}", "Set", "<", "Entry", "<", "KEY", ",", "VALUE", ">", ">", "entries", "=", "mapDataToPut", ".", "entrySet", "(", ")", ";", "for", "(", "Entry", "<", "KEY", ",", "VALUE", ">", "entry", ":", "entries", ")", "{", "put", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}" ]
Stores all entries contained in the given map in the cache.
[ "Stores", "all", "entries", "contained", "in", "the", "given", "map", "in", "the", "cache", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java#L147-L156
159,537
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java
ObjectCache.get
public VALUE get(KEY key) { CacheEntry<VALUE> entry; synchronized (this) { entry = values.get(key); } VALUE value; if (entry != null) { if (isExpiring) { long age = System.currentTimeMillis() - entry.timeCreated; if (age < expirationMillis) { value = getValue(key, entry); } else { countExpired++; synchronized (this) { values.remove(key); } value = null; } } else { value = getValue(key, entry); } } else { value = null; } if (value != null) { countHit++; } else { countMiss++; } return value; }
java
public VALUE get(KEY key) { CacheEntry<VALUE> entry; synchronized (this) { entry = values.get(key); } VALUE value; if (entry != null) { if (isExpiring) { long age = System.currentTimeMillis() - entry.timeCreated; if (age < expirationMillis) { value = getValue(key, entry); } else { countExpired++; synchronized (this) { values.remove(key); } value = null; } } else { value = getValue(key, entry); } } else { value = null; } if (value != null) { countHit++; } else { countMiss++; } return value; }
[ "public", "VALUE", "get", "(", "KEY", "key", ")", "{", "CacheEntry", "<", "VALUE", ">", "entry", ";", "synchronized", "(", "this", ")", "{", "entry", "=", "values", ".", "get", "(", "key", ")", ";", "}", "VALUE", "value", ";", "if", "(", "entry", "!=", "null", ")", "{", "if", "(", "isExpiring", ")", "{", "long", "age", "=", "System", ".", "currentTimeMillis", "(", ")", "-", "entry", ".", "timeCreated", ";", "if", "(", "age", "<", "expirationMillis", ")", "{", "value", "=", "getValue", "(", "key", ",", "entry", ")", ";", "}", "else", "{", "countExpired", "++", ";", "synchronized", "(", "this", ")", "{", "values", ".", "remove", "(", "key", ")", ";", "}", "value", "=", "null", ";", "}", "}", "else", "{", "value", "=", "getValue", "(", "key", ",", "entry", ")", ";", "}", "}", "else", "{", "value", "=", "null", ";", "}", "if", "(", "value", "!=", "null", ")", "{", "countHit", "++", ";", "}", "else", "{", "countMiss", "++", ";", "}", "return", "value", ";", "}" ]
Get the cached entry or null if no valid cached entry is found.
[ "Get", "the", "cached", "entry", "or", "null", "if", "no", "valid", "cached", "entry", "is", "found", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java#L159-L189
159,538
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/IoUtils.java
IoUtils.copyAllBytes
public static int copyAllBytes(InputStream in, OutputStream out) throws IOException { int byteCount = 0; byte[] buffer = new byte[BUFFER_SIZE]; while (true) { int read = in.read(buffer); if (read == -1) { break; } out.write(buffer, 0, read); byteCount += read; } return byteCount; }
java
public static int copyAllBytes(InputStream in, OutputStream out) throws IOException { int byteCount = 0; byte[] buffer = new byte[BUFFER_SIZE]; while (true) { int read = in.read(buffer); if (read == -1) { break; } out.write(buffer, 0, read); byteCount += read; } return byteCount; }
[ "public", "static", "int", "copyAllBytes", "(", "InputStream", "in", ",", "OutputStream", "out", ")", "throws", "IOException", "{", "int", "byteCount", "=", "0", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "BUFFER_SIZE", "]", ";", "while", "(", "true", ")", "{", "int", "read", "=", "in", ".", "read", "(", "buffer", ")", ";", "if", "(", "read", "==", "-", "1", ")", "{", "break", ";", "}", "out", ".", "write", "(", "buffer", ",", "0", ",", "read", ")", ";", "byteCount", "+=", "read", ";", "}", "return", "byteCount", ";", "}" ]
Copies all available data from in to out without closing any stream. @return number of bytes copied
[ "Copies", "all", "available", "data", "from", "in", "to", "out", "without", "closing", "any", "stream", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/IoUtils.java#L130-L142
159,539
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java
CircularByteBuffer.get
public synchronized int get() { if (available == 0) { return -1; } byte value = buffer[idxGet]; idxGet = (idxGet + 1) % capacity; available--; return value; }
java
public synchronized int get() { if (available == 0) { return -1; } byte value = buffer[idxGet]; idxGet = (idxGet + 1) % capacity; available--; return value; }
[ "public", "synchronized", "int", "get", "(", ")", "{", "if", "(", "available", "==", "0", ")", "{", "return", "-", "1", ";", "}", "byte", "value", "=", "buffer", "[", "idxGet", "]", ";", "idxGet", "=", "(", "idxGet", "+", "1", ")", "%", "capacity", ";", "available", "--", ";", "return", "value", ";", "}" ]
Gets a single byte return or -1 if no data is available.
[ "Gets", "a", "single", "byte", "return", "or", "-", "1", "if", "no", "data", "is", "available", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java#L56-L64
159,540
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java
CircularByteBuffer.get
public synchronized int get(byte[] dst, int off, int len) { if (available == 0) { return 0; } // limit is last index to read + 1 int limit = idxGet < idxPut ? idxPut : capacity; int count = Math.min(limit - idxGet, len); System.arraycopy(buffer, idxGet, dst, off, count); idxGet += count; if (idxGet == capacity) { // Array end reached, check if we have more int count2 = Math.min(len - count, idxPut); if (count2 > 0) { System.arraycopy(buffer, 0, dst, off + count, count2); idxGet = count2; count += count2; } else { idxGet = 0; } } available -= count; return count; }
java
public synchronized int get(byte[] dst, int off, int len) { if (available == 0) { return 0; } // limit is last index to read + 1 int limit = idxGet < idxPut ? idxPut : capacity; int count = Math.min(limit - idxGet, len); System.arraycopy(buffer, idxGet, dst, off, count); idxGet += count; if (idxGet == capacity) { // Array end reached, check if we have more int count2 = Math.min(len - count, idxPut); if (count2 > 0) { System.arraycopy(buffer, 0, dst, off + count, count2); idxGet = count2; count += count2; } else { idxGet = 0; } } available -= count; return count; }
[ "public", "synchronized", "int", "get", "(", "byte", "[", "]", "dst", ",", "int", "off", ",", "int", "len", ")", "{", "if", "(", "available", "==", "0", ")", "{", "return", "0", ";", "}", "// limit is last index to read + 1", "int", "limit", "=", "idxGet", "<", "idxPut", "?", "idxPut", ":", "capacity", ";", "int", "count", "=", "Math", ".", "min", "(", "limit", "-", "idxGet", ",", "len", ")", ";", "System", ".", "arraycopy", "(", "buffer", ",", "idxGet", ",", "dst", ",", "off", ",", "count", ")", ";", "idxGet", "+=", "count", ";", "if", "(", "idxGet", "==", "capacity", ")", "{", "// Array end reached, check if we have more", "int", "count2", "=", "Math", ".", "min", "(", "len", "-", "count", ",", "idxPut", ")", ";", "if", "(", "count2", ">", "0", ")", "{", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "dst", ",", "off", "+", "count", ",", "count2", ")", ";", "idxGet", "=", "count2", ";", "count", "+=", "count2", ";", "}", "else", "{", "idxGet", "=", "0", ";", "}", "}", "available", "-=", "count", ";", "return", "count", ";", "}" ]
Gets as many of the requested bytes as available from this buffer. @return number of bytes actually got from this buffer (0 if no bytes are available)
[ "Gets", "as", "many", "of", "the", "requested", "bytes", "as", "available", "from", "this", "buffer", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java#L80-L104
159,541
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java
CircularByteBuffer.put
public synchronized boolean put(byte value) { if (available == capacity) { return false; } buffer[idxPut] = value; idxPut = (idxPut + 1) % capacity; available++; return true; }
java
public synchronized boolean put(byte value) { if (available == capacity) { return false; } buffer[idxPut] = value; idxPut = (idxPut + 1) % capacity; available++; return true; }
[ "public", "synchronized", "boolean", "put", "(", "byte", "value", ")", "{", "if", "(", "available", "==", "capacity", ")", "{", "return", "false", ";", "}", "buffer", "[", "idxPut", "]", "=", "value", ";", "idxPut", "=", "(", "idxPut", "+", "1", ")", "%", "capacity", ";", "available", "++", ";", "return", "true", ";", "}" ]
Puts a single byte if the buffer is not yet full. @return true if the byte was put, or false if the buffer is full
[ "Puts", "a", "single", "byte", "if", "the", "buffer", "is", "not", "yet", "full", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java#L112-L120
159,542
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java
CircularByteBuffer.put
public synchronized int put(byte[] src, int off, int len) { if (available == capacity) { return 0; } // limit is last index to put + 1 int limit = idxPut < idxGet ? idxGet : capacity; int count = Math.min(limit - idxPut, len); System.arraycopy(src, off, buffer, idxPut, count); idxPut += count; if (idxPut == capacity) { // Array end reached, check if we have more int count2 = Math.min(len - count, idxGet); if (count2 > 0) { System.arraycopy(src, off + count, buffer, 0, count2); idxPut = count2; count += count2; } else { idxPut = 0; } } available += count; return count; }
java
public synchronized int put(byte[] src, int off, int len) { if (available == capacity) { return 0; } // limit is last index to put + 1 int limit = idxPut < idxGet ? idxGet : capacity; int count = Math.min(limit - idxPut, len); System.arraycopy(src, off, buffer, idxPut, count); idxPut += count; if (idxPut == capacity) { // Array end reached, check if we have more int count2 = Math.min(len - count, idxGet); if (count2 > 0) { System.arraycopy(src, off + count, buffer, 0, count2); idxPut = count2; count += count2; } else { idxPut = 0; } } available += count; return count; }
[ "public", "synchronized", "int", "put", "(", "byte", "[", "]", "src", ",", "int", "off", ",", "int", "len", ")", "{", "if", "(", "available", "==", "capacity", ")", "{", "return", "0", ";", "}", "// limit is last index to put + 1", "int", "limit", "=", "idxPut", "<", "idxGet", "?", "idxGet", ":", "capacity", ";", "int", "count", "=", "Math", ".", "min", "(", "limit", "-", "idxPut", ",", "len", ")", ";", "System", ".", "arraycopy", "(", "src", ",", "off", ",", "buffer", ",", "idxPut", ",", "count", ")", ";", "idxPut", "+=", "count", ";", "if", "(", "idxPut", "==", "capacity", ")", "{", "// Array end reached, check if we have more", "int", "count2", "=", "Math", ".", "min", "(", "len", "-", "count", ",", "idxGet", ")", ";", "if", "(", "count2", ">", "0", ")", "{", "System", ".", "arraycopy", "(", "src", ",", "off", "+", "count", ",", "buffer", ",", "0", ",", "count2", ")", ";", "idxPut", "=", "count2", ";", "count", "+=", "count2", ";", "}", "else", "{", "idxPut", "=", "0", ";", "}", "}", "available", "+=", "count", ";", "return", "count", ";", "}" ]
Puts as many of the given bytes as possible into this buffer. @return number of bytes actually put into this buffer (0 if the buffer is full)
[ "Puts", "as", "many", "of", "the", "given", "bytes", "as", "possible", "into", "this", "buffer", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java#L136-L160
159,543
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java
CircularByteBuffer.skip
public synchronized int skip(int count) { if (count > available) { count = available; } idxGet = (idxGet + count) % capacity; available -= count; return count; }
java
public synchronized int skip(int count) { if (count > available) { count = available; } idxGet = (idxGet + count) % capacity; available -= count; return count; }
[ "public", "synchronized", "int", "skip", "(", "int", "count", ")", "{", "if", "(", "count", ">", "available", ")", "{", "count", "=", "available", ";", "}", "idxGet", "=", "(", "idxGet", "+", "count", ")", "%", "capacity", ";", "available", "-=", "count", ";", "return", "count", ";", "}" ]
Skips the given count of bytes, but at most the currently available count. @return number of bytes actually skipped from this buffer (0 if no bytes are available)
[ "Skips", "the", "given", "count", "of", "bytes", "but", "at", "most", "the", "currently", "available", "count", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java#L174-L181
159,544
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/FileUtils.java
FileUtils.readObject
public static Object readObject(File file) throws IOException, ClassNotFoundException { FileInputStream fileIn = new FileInputStream(file); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(fileIn)); try { return in.readObject(); } finally { IoUtils.safeClose(in); } }
java
public static Object readObject(File file) throws IOException, ClassNotFoundException { FileInputStream fileIn = new FileInputStream(file); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(fileIn)); try { return in.readObject(); } finally { IoUtils.safeClose(in); } }
[ "public", "static", "Object", "readObject", "(", "File", "file", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "FileInputStream", "fileIn", "=", "new", "FileInputStream", "(", "file", ")", ";", "ObjectInputStream", "in", "=", "new", "ObjectInputStream", "(", "new", "BufferedInputStream", "(", "fileIn", ")", ")", ";", "try", "{", "return", "in", ".", "readObject", "(", ")", ";", "}", "finally", "{", "IoUtils", ".", "safeClose", "(", "in", ")", ";", "}", "}" ]
To read an object in a quick & dirty way. Prepare to handle failures when object serialization changes!
[ "To", "read", "an", "object", "in", "a", "quick", "&", "dirty", "way", ".", "Prepare", "to", "handle", "failures", "when", "object", "serialization", "changes!" ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/FileUtils.java#L99-L108
159,545
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/FileUtils.java
FileUtils.writeObject
public static void writeObject(File file, Object object) throws IOException { FileOutputStream fileOut = new FileOutputStream(file); ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(fileOut)); try { out.writeObject(object); out.flush(); // Force sync fileOut.getFD().sync(); } finally { IoUtils.safeClose(out); } }
java
public static void writeObject(File file, Object object) throws IOException { FileOutputStream fileOut = new FileOutputStream(file); ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(fileOut)); try { out.writeObject(object); out.flush(); // Force sync fileOut.getFD().sync(); } finally { IoUtils.safeClose(out); } }
[ "public", "static", "void", "writeObject", "(", "File", "file", ",", "Object", "object", ")", "throws", "IOException", "{", "FileOutputStream", "fileOut", "=", "new", "FileOutputStream", "(", "file", ")", ";", "ObjectOutputStream", "out", "=", "new", "ObjectOutputStream", "(", "new", "BufferedOutputStream", "(", "fileOut", ")", ")", ";", "try", "{", "out", ".", "writeObject", "(", "object", ")", ";", "out", ".", "flush", "(", ")", ";", "// Force sync", "fileOut", ".", "getFD", "(", ")", ".", "sync", "(", ")", ";", "}", "finally", "{", "IoUtils", ".", "safeClose", "(", "out", ")", ";", "}", "}" ]
To store an object in a quick & dirty way.
[ "To", "store", "an", "object", "in", "a", "quick", "&", "dirty", "way", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/FileUtils.java#L111-L122
159,546
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java
DateUtils.setTime
public static void setTime(Calendar calendar, int hourOfDay, int minute, int second, int millisecond) { calendar.set(Calendar.HOUR_OF_DAY, hourOfDay); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, second); calendar.set(Calendar.MILLISECOND, millisecond); }
java
public static void setTime(Calendar calendar, int hourOfDay, int minute, int second, int millisecond) { calendar.set(Calendar.HOUR_OF_DAY, hourOfDay); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, second); calendar.set(Calendar.MILLISECOND, millisecond); }
[ "public", "static", "void", "setTime", "(", "Calendar", "calendar", ",", "int", "hourOfDay", ",", "int", "minute", ",", "int", "second", ",", "int", "millisecond", ")", "{", "calendar", ".", "set", "(", "Calendar", ".", "HOUR_OF_DAY", ",", "hourOfDay", ")", ";", "calendar", ".", "set", "(", "Calendar", ".", "MINUTE", ",", "minute", ")", ";", "calendar", ".", "set", "(", "Calendar", ".", "SECOND", ",", "second", ")", ";", "calendar", ".", "set", "(", "Calendar", ".", "MILLISECOND", ",", "millisecond", ")", ";", "}" ]
Sets hour, minutes, seconds and milliseconds to the given values. Leaves date info untouched.
[ "Sets", "hour", "minutes", "seconds", "and", "milliseconds", "to", "the", "given", "values", ".", "Leaves", "date", "info", "untouched", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java#L51-L56
159,547
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java
DateUtils.getDayAsReadableInt
public static int getDayAsReadableInt(long time) { Calendar cal = calendarThreadLocal.get(); cal.setTimeInMillis(time); return getDayAsReadableInt(cal); }
java
public static int getDayAsReadableInt(long time) { Calendar cal = calendarThreadLocal.get(); cal.setTimeInMillis(time); return getDayAsReadableInt(cal); }
[ "public", "static", "int", "getDayAsReadableInt", "(", "long", "time", ")", "{", "Calendar", "cal", "=", "calendarThreadLocal", ".", "get", "(", ")", ";", "cal", ".", "setTimeInMillis", "(", "time", ")", ";", "return", "getDayAsReadableInt", "(", "cal", ")", ";", "}" ]
Readable yyyyMMdd int representation of a day, which is also sortable.
[ "Readable", "yyyyMMdd", "int", "representation", "of", "a", "day", "which", "is", "also", "sortable", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java#L59-L63
159,548
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java
DateUtils.getDayAsReadableInt
public static int getDayAsReadableInt(Calendar calendar) { int day = calendar.get(Calendar.DAY_OF_MONTH); int month = calendar.get(Calendar.MONTH) + 1; int year = calendar.get(Calendar.YEAR); return year * 10000 + month * 100 + day; }
java
public static int getDayAsReadableInt(Calendar calendar) { int day = calendar.get(Calendar.DAY_OF_MONTH); int month = calendar.get(Calendar.MONTH) + 1; int year = calendar.get(Calendar.YEAR); return year * 10000 + month * 100 + day; }
[ "public", "static", "int", "getDayAsReadableInt", "(", "Calendar", "calendar", ")", "{", "int", "day", "=", "calendar", ".", "get", "(", "Calendar", ".", "DAY_OF_MONTH", ")", ";", "int", "month", "=", "calendar", ".", "get", "(", "Calendar", ".", "MONTH", ")", "+", "1", ";", "int", "year", "=", "calendar", ".", "get", "(", "Calendar", ".", "YEAR", ")", ";", "return", "year", "*", "10000", "+", "month", "*", "100", "+", "day", ";", "}" ]
Readable yyyyMMdd representation of a day, which is also sortable.
[ "Readable", "yyyyMMdd", "representation", "of", "a", "day", "which", "is", "also", "sortable", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java#L66-L71
159,549
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java
StringUtils.encodeUrlIso
public static String encodeUrlIso(String stringToEncode) { try { return URLEncoder.encode(stringToEncode, "ISO-8859-1"); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } }
java
public static String encodeUrlIso(String stringToEncode) { try { return URLEncoder.encode(stringToEncode, "ISO-8859-1"); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } }
[ "public", "static", "String", "encodeUrlIso", "(", "String", "stringToEncode", ")", "{", "try", "{", "return", "URLEncoder", ".", "encode", "(", "stringToEncode", ",", "\"ISO-8859-1\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e1", ")", "{", "throw", "new", "RuntimeException", "(", "e1", ")", ";", "}", "}" ]
URL-encodes a given string using ISO-8859-1, which may work better with web pages and umlauts compared to UTF-8. No UnsupportedEncodingException to handle as it is dealt with in this method.
[ "URL", "-", "encodes", "a", "given", "string", "using", "ISO", "-", "8859", "-", "1", "which", "may", "work", "better", "with", "web", "pages", "and", "umlauts", "compared", "to", "UTF", "-", "8", ".", "No", "UnsupportedEncodingException", "to", "handle", "as", "it", "is", "dealt", "with", "in", "this", "method", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java#L80-L86
159,550
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java
StringUtils.decodeUrl
public static String decodeUrl(String stringToDecode) { try { return URLDecoder.decode(stringToDecode, "UTF-8"); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } }
java
public static String decodeUrl(String stringToDecode) { try { return URLDecoder.decode(stringToDecode, "UTF-8"); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } }
[ "public", "static", "String", "decodeUrl", "(", "String", "stringToDecode", ")", "{", "try", "{", "return", "URLDecoder", ".", "decode", "(", "stringToDecode", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e1", ")", "{", "throw", "new", "RuntimeException", "(", "e1", ")", ";", "}", "}" ]
URL-Decodes a given string using UTF-8. No UnsupportedEncodingException to handle as it is dealt with in this method.
[ "URL", "-", "Decodes", "a", "given", "string", "using", "UTF", "-", "8", ".", "No", "UnsupportedEncodingException", "to", "handle", "as", "it", "is", "dealt", "with", "in", "this", "method", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java#L92-L98
159,551
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java
StringUtils.decodeUrlIso
public static String decodeUrlIso(String stringToDecode) { try { return URLDecoder.decode(stringToDecode, "ISO-8859-1"); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } }
java
public static String decodeUrlIso(String stringToDecode) { try { return URLDecoder.decode(stringToDecode, "ISO-8859-1"); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } }
[ "public", "static", "String", "decodeUrlIso", "(", "String", "stringToDecode", ")", "{", "try", "{", "return", "URLDecoder", ".", "decode", "(", "stringToDecode", ",", "\"ISO-8859-1\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e1", ")", "{", "throw", "new", "RuntimeException", "(", "e1", ")", ";", "}", "}" ]
URL-Decodes a given string using ISO-8859-1. No UnsupportedEncodingException to handle as it is dealt with in this method.
[ "URL", "-", "Decodes", "a", "given", "string", "using", "ISO", "-", "8859", "-", "1", ".", "No", "UnsupportedEncodingException", "to", "handle", "as", "it", "is", "dealt", "with", "in", "this", "method", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java#L104-L110
159,552
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java
StringUtils.ellipsize
public static String ellipsize(String text, int maxLength, String end) { if (text != null && text.length() > maxLength) { return text.substring(0, maxLength - end.length()) + end; } return text; }
java
public static String ellipsize(String text, int maxLength, String end) { if (text != null && text.length() > maxLength) { return text.substring(0, maxLength - end.length()) + end; } return text; }
[ "public", "static", "String", "ellipsize", "(", "String", "text", ",", "int", "maxLength", ",", "String", "end", ")", "{", "if", "(", "text", "!=", "null", "&&", "text", ".", "length", "(", ")", ">", "maxLength", ")", "{", "return", "text", ".", "substring", "(", "0", ",", "maxLength", "-", "end", ".", "length", "(", ")", ")", "+", "end", ";", "}", "return", "text", ";", "}" ]
Cuts the string at the end if it's longer than maxLength and appends the given end string to it. The length of the resulting string is always less or equal to the given maxLength. It's valid to pass a null text; in this case null is returned.
[ "Cuts", "the", "string", "at", "the", "end", "if", "it", "s", "longer", "than", "maxLength", "and", "appends", "the", "given", "end", "string", "to", "it", ".", "The", "length", "of", "the", "resulting", "string", "is", "always", "less", "or", "equal", "to", "the", "given", "maxLength", ".", "It", "s", "valid", "to", "pass", "a", "null", "text", ";", "in", "this", "case", "null", "is", "returned", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java#L228-L233
159,553
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java
StringUtils.join
public static String join(Iterable<?> iterable, String separator) { if (iterable != null) { StringBuilder buf = new StringBuilder(); Iterator<?> it = iterable.iterator(); char singleChar = separator.length() == 1 ? separator.charAt(0) : 0; while (it.hasNext()) { buf.append(it.next()); if (it.hasNext()) { if (singleChar != 0) { // More efficient buf.append(singleChar); } else { buf.append(separator); } } } return buf.toString(); } else { return ""; } }
java
public static String join(Iterable<?> iterable, String separator) { if (iterable != null) { StringBuilder buf = new StringBuilder(); Iterator<?> it = iterable.iterator(); char singleChar = separator.length() == 1 ? separator.charAt(0) : 0; while (it.hasNext()) { buf.append(it.next()); if (it.hasNext()) { if (singleChar != 0) { // More efficient buf.append(singleChar); } else { buf.append(separator); } } } return buf.toString(); } else { return ""; } }
[ "public", "static", "String", "join", "(", "Iterable", "<", "?", ">", "iterable", ",", "String", "separator", ")", "{", "if", "(", "iterable", "!=", "null", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "Iterator", "<", "?", ">", "it", "=", "iterable", ".", "iterator", "(", ")", ";", "char", "singleChar", "=", "separator", ".", "length", "(", ")", "==", "1", "?", "separator", ".", "charAt", "(", "0", ")", ":", "0", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "buf", ".", "append", "(", "it", ".", "next", "(", ")", ")", ";", "if", "(", "it", ".", "hasNext", "(", ")", ")", "{", "if", "(", "singleChar", "!=", "0", ")", "{", "// More efficient", "buf", ".", "append", "(", "singleChar", ")", ";", "}", "else", "{", "buf", ".", "append", "(", "separator", ")", ";", "}", "}", "}", "return", "buf", ".", "toString", "(", ")", ";", "}", "else", "{", "return", "\"\"", ";", "}", "}" ]
Joins the given iterable objects using the given separator into a single string. @return the joined string or an empty string if iterable is null
[ "Joins", "the", "given", "iterable", "objects", "using", "the", "given", "separator", "into", "a", "single", "string", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java#L259-L279
159,554
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java
StringUtils.join
public static String join(int[] array, String separator) { if (array != null) { StringBuilder buf = new StringBuilder(Math.max(16, (separator.length() + 1) * array.length)); char singleChar = separator.length() == 1 ? separator.charAt(0) : 0; for (int i = 0; i < array.length; i++) { if (i != 0) { if (singleChar != 0) { // More efficient buf.append(singleChar); } else { buf.append(separator); } } buf.append(array[i]); } return buf.toString(); } else { return ""; } }
java
public static String join(int[] array, String separator) { if (array != null) { StringBuilder buf = new StringBuilder(Math.max(16, (separator.length() + 1) * array.length)); char singleChar = separator.length() == 1 ? separator.charAt(0) : 0; for (int i = 0; i < array.length; i++) { if (i != 0) { if (singleChar != 0) { // More efficient buf.append(singleChar); } else { buf.append(separator); } } buf.append(array[i]); } return buf.toString(); } else { return ""; } }
[ "public", "static", "String", "join", "(", "int", "[", "]", "array", ",", "String", "separator", ")", "{", "if", "(", "array", "!=", "null", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", "Math", ".", "max", "(", "16", ",", "(", "separator", ".", "length", "(", ")", "+", "1", ")", "*", "array", ".", "length", ")", ")", ";", "char", "singleChar", "=", "separator", ".", "length", "(", ")", "==", "1", "?", "separator", ".", "charAt", "(", "0", ")", ":", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "0", ")", "{", "if", "(", "singleChar", "!=", "0", ")", "{", "// More efficient", "buf", ".", "append", "(", "singleChar", ")", ";", "}", "else", "{", "buf", ".", "append", "(", "separator", ")", ";", "}", "}", "buf", ".", "append", "(", "array", "[", "i", "]", ")", ";", "}", "return", "buf", ".", "toString", "(", ")", ";", "}", "else", "{", "return", "\"\"", ";", "}", "}" ]
Joins the given ints using the given separator into a single string. @return the joined string or an empty string if the int array is null
[ "Joins", "the", "given", "ints", "using", "the", "given", "separator", "into", "a", "single", "string", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java#L286-L305
159,555
mkopylec/charon-spring-boot-starter
src/main/java/com/github/mkopylec/charon/core/http/RequestForwarder.java
RequestForwarder.prepareForwardedResponseHeaders
protected void prepareForwardedResponseHeaders(ResponseData response) { HttpHeaders headers = response.getHeaders(); headers.remove(TRANSFER_ENCODING); headers.remove(CONNECTION); headers.remove("Public-Key-Pins"); headers.remove(SERVER); headers.remove("Strict-Transport-Security"); }
java
protected void prepareForwardedResponseHeaders(ResponseData response) { HttpHeaders headers = response.getHeaders(); headers.remove(TRANSFER_ENCODING); headers.remove(CONNECTION); headers.remove("Public-Key-Pins"); headers.remove(SERVER); headers.remove("Strict-Transport-Security"); }
[ "protected", "void", "prepareForwardedResponseHeaders", "(", "ResponseData", "response", ")", "{", "HttpHeaders", "headers", "=", "response", ".", "getHeaders", "(", ")", ";", "headers", ".", "remove", "(", "TRANSFER_ENCODING", ")", ";", "headers", ".", "remove", "(", "CONNECTION", ")", ";", "headers", ".", "remove", "(", "\"Public-Key-Pins\"", ")", ";", "headers", ".", "remove", "(", "SERVER", ")", ";", "headers", ".", "remove", "(", "\"Strict-Transport-Security\"", ")", ";", "}" ]
Remove any protocol-level headers from the remote server's response that do not apply to the new response we are sending. @param response
[ "Remove", "any", "protocol", "-", "level", "headers", "from", "the", "remote", "server", "s", "response", "that", "do", "not", "apply", "to", "the", "new", "response", "we", "are", "sending", "." ]
9a3aa4ffd0bae6a1f94cd983bbf17cd36f4ff594
https://github.com/mkopylec/charon-spring-boot-starter/blob/9a3aa4ffd0bae6a1f94cd983bbf17cd36f4ff594/src/main/java/com/github/mkopylec/charon/core/http/RequestForwarder.java#L98-L105
159,556
mkopylec/charon-spring-boot-starter
src/main/java/com/github/mkopylec/charon/core/http/RequestForwarder.java
RequestForwarder.prepareForwardedRequestHeaders
protected void prepareForwardedRequestHeaders(RequestData request, ForwardDestination destination) { HttpHeaders headers = request.getHeaders(); headers.set(HOST, destination.getUri().getAuthority()); headers.remove(TE); }
java
protected void prepareForwardedRequestHeaders(RequestData request, ForwardDestination destination) { HttpHeaders headers = request.getHeaders(); headers.set(HOST, destination.getUri().getAuthority()); headers.remove(TE); }
[ "protected", "void", "prepareForwardedRequestHeaders", "(", "RequestData", "request", ",", "ForwardDestination", "destination", ")", "{", "HttpHeaders", "headers", "=", "request", ".", "getHeaders", "(", ")", ";", "headers", ".", "set", "(", "HOST", ",", "destination", ".", "getUri", "(", ")", ".", "getAuthority", "(", ")", ")", ";", "headers", ".", "remove", "(", "TE", ")", ";", "}" ]
Remove any protocol-level headers from the clients request that do not apply to the new request we are sending to the remote server. @param request @param destination
[ "Remove", "any", "protocol", "-", "level", "headers", "from", "the", "clients", "request", "that", "do", "not", "apply", "to", "the", "new", "request", "we", "are", "sending", "to", "the", "remote", "server", "." ]
9a3aa4ffd0bae6a1f94cd983bbf17cd36f4ff594
https://github.com/mkopylec/charon-spring-boot-starter/blob/9a3aa4ffd0bae6a1f94cd983bbf17cd36f4ff594/src/main/java/com/github/mkopylec/charon/core/http/RequestForwarder.java#L114-L118
159,557
patka/cassandra-migration
cassandra-migration/src/main/java/org/cognitor/cassandra/migration/MigrationRepository.java
MigrationRepository.normalizePath
private String normalizePath(String scriptPath) { StringBuilder builder = new StringBuilder(scriptPath.length() + 1); if (scriptPath.startsWith("/")) { builder.append(scriptPath.substring(1)); } else { builder.append(scriptPath); } if (!scriptPath.endsWith("/")) { builder.append("/"); } return builder.toString(); }
java
private String normalizePath(String scriptPath) { StringBuilder builder = new StringBuilder(scriptPath.length() + 1); if (scriptPath.startsWith("/")) { builder.append(scriptPath.substring(1)); } else { builder.append(scriptPath); } if (!scriptPath.endsWith("/")) { builder.append("/"); } return builder.toString(); }
[ "private", "String", "normalizePath", "(", "String", "scriptPath", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", "scriptPath", ".", "length", "(", ")", "+", "1", ")", ";", "if", "(", "scriptPath", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "builder", ".", "append", "(", "scriptPath", ".", "substring", "(", "1", ")", ")", ";", "}", "else", "{", "builder", ".", "append", "(", "scriptPath", ")", ";", "}", "if", "(", "!", "scriptPath", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "builder", ".", "append", "(", "\"/\"", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Ensures that every path starts and ends with a slash character. @param scriptPath the scriptPath that needs to be normalized @return a path with leading and trailing slash
[ "Ensures", "that", "every", "path", "starts", "and", "ends", "with", "a", "slash", "character", "." ]
c61840c23b17a18df704d136909c26ff46bd5c77
https://github.com/patka/cassandra-migration/blob/c61840c23b17a18df704d136909c26ff46bd5c77/cassandra-migration/src/main/java/org/cognitor/cassandra/migration/MigrationRepository.java#L143-L154
159,558
patka/cassandra-migration
cassandra-migration/src/main/java/org/cognitor/cassandra/migration/MigrationRepository.java
MigrationRepository.getMigrationsSinceVersion
public List<DbMigration> getMigrationsSinceVersion(int version) { List<DbMigration> dbMigrations = new ArrayList<>(); migrationScripts.stream().filter(script -> script.getVersion() > version).forEach(script -> { String content = loadScriptContent(script); dbMigrations.add(new DbMigration(script.getScriptName(), script.getVersion(), content)); }); return dbMigrations; }
java
public List<DbMigration> getMigrationsSinceVersion(int version) { List<DbMigration> dbMigrations = new ArrayList<>(); migrationScripts.stream().filter(script -> script.getVersion() > version).forEach(script -> { String content = loadScriptContent(script); dbMigrations.add(new DbMigration(script.getScriptName(), script.getVersion(), content)); }); return dbMigrations; }
[ "public", "List", "<", "DbMigration", ">", "getMigrationsSinceVersion", "(", "int", "version", ")", "{", "List", "<", "DbMigration", ">", "dbMigrations", "=", "new", "ArrayList", "<>", "(", ")", ";", "migrationScripts", ".", "stream", "(", ")", ".", "filter", "(", "script", "->", "script", ".", "getVersion", "(", ")", ">", "version", ")", ".", "forEach", "(", "script", "->", "{", "String", "content", "=", "loadScriptContent", "(", "script", ")", ";", "dbMigrations", ".", "add", "(", "new", "DbMigration", "(", "script", ".", "getScriptName", "(", ")", ",", "script", ".", "getVersion", "(", ")", ",", "content", ")", ")", ";", "}", ")", ";", "return", "dbMigrations", ";", "}" ]
Returns all migrations starting from and excluding the given version. Usually you want to provide the version of the database here to get all migrations that need to be executed. In case there is no script with a newer version than the one given, an empty list is returned. @param version the version that is currently in the database @return all versions since the given version or an empty list if no newer script is available. Never null. Does not include the given version.
[ "Returns", "all", "migrations", "starting", "from", "and", "excluding", "the", "given", "version", ".", "Usually", "you", "want", "to", "provide", "the", "version", "of", "the", "database", "here", "to", "get", "all", "migrations", "that", "need", "to", "be", "executed", ".", "In", "case", "there", "is", "no", "script", "with", "a", "newer", "version", "than", "the", "one", "given", "an", "empty", "list", "is", "returned", "." ]
c61840c23b17a18df704d136909c26ff46bd5c77
https://github.com/patka/cassandra-migration/blob/c61840c23b17a18df704d136909c26ff46bd5c77/cassandra-migration/src/main/java/org/cognitor/cassandra/migration/MigrationRepository.java#L235-L242
159,559
patka/cassandra-migration
cassandra-migration/src/main/java/org/cognitor/cassandra/migration/Database.java
Database.getVersion
public int getVersion() { ResultSet resultSet = session.execute(format(VERSION_QUERY, getTableName())); Row result = resultSet.one(); if (result == null) { return 0; } return result.getInt(0); }
java
public int getVersion() { ResultSet resultSet = session.execute(format(VERSION_QUERY, getTableName())); Row result = resultSet.one(); if (result == null) { return 0; } return result.getInt(0); }
[ "public", "int", "getVersion", "(", ")", "{", "ResultSet", "resultSet", "=", "session", ".", "execute", "(", "format", "(", "VERSION_QUERY", ",", "getTableName", "(", ")", ")", ")", ";", "Row", "result", "=", "resultSet", ".", "one", "(", ")", ";", "if", "(", "result", "==", "null", ")", "{", "return", "0", ";", "}", "return", "result", ".", "getInt", "(", "0", ")", ";", "}" ]
Gets the current version of the database schema. This version is taken from the migration table and represent the latest successful entry. @return the current schema version
[ "Gets", "the", "current", "version", "of", "the", "database", "schema", ".", "This", "version", "is", "taken", "from", "the", "migration", "table", "and", "represent", "the", "latest", "successful", "entry", "." ]
c61840c23b17a18df704d136909c26ff46bd5c77
https://github.com/patka/cassandra-migration/blob/c61840c23b17a18df704d136909c26ff46bd5c77/cassandra-migration/src/main/java/org/cognitor/cassandra/migration/Database.java#L134-L141
159,560
patka/cassandra-migration
cassandra-migration/src/main/java/org/cognitor/cassandra/migration/Database.java
Database.logMigration
private void logMigration(DbMigration migration, boolean wasSuccessful) { BoundStatement boundStatement = logMigrationStatement.bind(wasSuccessful, migration.getVersion(), migration.getScriptName(), migration.getMigrationScript(), new Date()); session.execute(boundStatement); }
java
private void logMigration(DbMigration migration, boolean wasSuccessful) { BoundStatement boundStatement = logMigrationStatement.bind(wasSuccessful, migration.getVersion(), migration.getScriptName(), migration.getMigrationScript(), new Date()); session.execute(boundStatement); }
[ "private", "void", "logMigration", "(", "DbMigration", "migration", ",", "boolean", "wasSuccessful", ")", "{", "BoundStatement", "boundStatement", "=", "logMigrationStatement", ".", "bind", "(", "wasSuccessful", ",", "migration", ".", "getVersion", "(", ")", ",", "migration", ".", "getScriptName", "(", ")", ",", "migration", ".", "getMigrationScript", "(", ")", ",", "new", "Date", "(", ")", ")", ";", "session", ".", "execute", "(", "boundStatement", ")", ";", "}" ]
Inserts the result of the migration into the migration table @param migration the migration that was executed @param wasSuccessful indicates if the migration was successful or not
[ "Inserts", "the", "result", "of", "the", "migration", "into", "the", "migration", "table" ]
c61840c23b17a18df704d136909c26ff46bd5c77
https://github.com/patka/cassandra-migration/blob/c61840c23b17a18df704d136909c26ff46bd5c77/cassandra-migration/src/main/java/org/cognitor/cassandra/migration/Database.java#L219-L223
159,561
patka/cassandra-migration
cassandra-migration/src/main/java/org/cognitor/cassandra/migration/MigrationTask.java
MigrationTask.migrate
public void migrate() { if (databaseIsUpToDate()) { LOGGER.info(format("Keyspace %s is already up to date at version %d", database.getKeyspaceName(), database.getVersion())); return; } List<DbMigration> migrations = repository.getMigrationsSinceVersion(database.getVersion()); migrations.forEach(database::execute); LOGGER.info(format("Migrated keyspace %s to version %d", database.getKeyspaceName(), database.getVersion())); database.close(); }
java
public void migrate() { if (databaseIsUpToDate()) { LOGGER.info(format("Keyspace %s is already up to date at version %d", database.getKeyspaceName(), database.getVersion())); return; } List<DbMigration> migrations = repository.getMigrationsSinceVersion(database.getVersion()); migrations.forEach(database::execute); LOGGER.info(format("Migrated keyspace %s to version %d", database.getKeyspaceName(), database.getVersion())); database.close(); }
[ "public", "void", "migrate", "(", ")", "{", "if", "(", "databaseIsUpToDate", "(", ")", ")", "{", "LOGGER", ".", "info", "(", "format", "(", "\"Keyspace %s is already up to date at version %d\"", ",", "database", ".", "getKeyspaceName", "(", ")", ",", "database", ".", "getVersion", "(", ")", ")", ")", ";", "return", ";", "}", "List", "<", "DbMigration", ">", "migrations", "=", "repository", ".", "getMigrationsSinceVersion", "(", "database", ".", "getVersion", "(", ")", ")", ";", "migrations", ".", "forEach", "(", "database", "::", "execute", ")", ";", "LOGGER", ".", "info", "(", "format", "(", "\"Migrated keyspace %s to version %d\"", ",", "database", ".", "getKeyspaceName", "(", ")", ",", "database", ".", "getVersion", "(", ")", ")", ")", ";", "database", ".", "close", "(", ")", ";", "}" ]
Start the actual migration. Take the version of the database, get all required migrations and execute them or do nothing if the DB is already up to date. At the end the underlying database instance is closed. @throws MigrationException if a migration fails
[ "Start", "the", "actual", "migration", ".", "Take", "the", "version", "of", "the", "database", "get", "all", "required", "migrations", "and", "execute", "them", "or", "do", "nothing", "if", "the", "DB", "is", "already", "up", "to", "date", "." ]
c61840c23b17a18df704d136909c26ff46bd5c77
https://github.com/patka/cassandra-migration/blob/c61840c23b17a18df704d136909c26ff46bd5c77/cassandra-migration/src/main/java/org/cognitor/cassandra/migration/MigrationTask.java#L44-L55
159,562
patka/cassandra-migration
cassandra-migration/src/main/java/org/cognitor/cassandra/migration/scanner/FileSystemLocationScanner.java
FileSystemLocationScanner.findResourceNames
public Set<String> findResourceNames(String location, URI locationUri) throws IOException { String filePath = toFilePath(locationUri); File folder = new File(filePath); if (!folder.isDirectory()) { LOGGER.debug("Skipping path as it is not a directory: " + filePath); return new TreeSet<>(); } String classPathRootOnDisk = filePath.substring(0, filePath.length() - location.length()); if (!classPathRootOnDisk.endsWith(File.separator)) { classPathRootOnDisk = classPathRootOnDisk + File.separator; } LOGGER.debug("Scanning starting at classpath root in filesystem: " + classPathRootOnDisk); return findResourceNamesFromFileSystem(classPathRootOnDisk, location, folder); }
java
public Set<String> findResourceNames(String location, URI locationUri) throws IOException { String filePath = toFilePath(locationUri); File folder = new File(filePath); if (!folder.isDirectory()) { LOGGER.debug("Skipping path as it is not a directory: " + filePath); return new TreeSet<>(); } String classPathRootOnDisk = filePath.substring(0, filePath.length() - location.length()); if (!classPathRootOnDisk.endsWith(File.separator)) { classPathRootOnDisk = classPathRootOnDisk + File.separator; } LOGGER.debug("Scanning starting at classpath root in filesystem: " + classPathRootOnDisk); return findResourceNamesFromFileSystem(classPathRootOnDisk, location, folder); }
[ "public", "Set", "<", "String", ">", "findResourceNames", "(", "String", "location", ",", "URI", "locationUri", ")", "throws", "IOException", "{", "String", "filePath", "=", "toFilePath", "(", "locationUri", ")", ";", "File", "folder", "=", "new", "File", "(", "filePath", ")", ";", "if", "(", "!", "folder", ".", "isDirectory", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"Skipping path as it is not a directory: \"", "+", "filePath", ")", ";", "return", "new", "TreeSet", "<>", "(", ")", ";", "}", "String", "classPathRootOnDisk", "=", "filePath", ".", "substring", "(", "0", ",", "filePath", ".", "length", "(", ")", "-", "location", ".", "length", "(", ")", ")", ";", "if", "(", "!", "classPathRootOnDisk", ".", "endsWith", "(", "File", ".", "separator", ")", ")", "{", "classPathRootOnDisk", "=", "classPathRootOnDisk", "+", "File", ".", "separator", ";", "}", "LOGGER", ".", "debug", "(", "\"Scanning starting at classpath root in filesystem: \"", "+", "classPathRootOnDisk", ")", ";", "return", "findResourceNamesFromFileSystem", "(", "classPathRootOnDisk", ",", "location", ",", "folder", ")", ";", "}" ]
Scans a path on the filesystem for resources inside the given classpath location. @param location The system-independent location on the classpath. @param locationUri The system-specific physical location URI. @return a sorted set containing all the resources inside the given location @throws IOException if an error accessing the filesystem happens
[ "Scans", "a", "path", "on", "the", "filesystem", "for", "resources", "inside", "the", "given", "classpath", "location", "." ]
c61840c23b17a18df704d136909c26ff46bd5c77
https://github.com/patka/cassandra-migration/blob/c61840c23b17a18df704d136909c26ff46bd5c77/cassandra-migration/src/main/java/org/cognitor/cassandra/migration/scanner/FileSystemLocationScanner.java#L34-L48
159,563
patka/cassandra-migration
cassandra-migration/src/main/java/org/cognitor/cassandra/migration/scanner/FileSystemLocationScanner.java
FileSystemLocationScanner.findResourceNamesFromFileSystem
private Set<String> findResourceNamesFromFileSystem(String classPathRootOnDisk, String scanRootLocation, File folder) { LOGGER.debug("Scanning for resources in path: {} ({})", folder.getPath(), scanRootLocation); File[] files = folder.listFiles(); if (files == null) { return emptySet(); } Set<String> resourceNames = new TreeSet<>(); for (File file : files) { if (file.canRead()) { if (file.isDirectory()) { resourceNames.addAll(findResourceNamesFromFileSystem(classPathRootOnDisk, scanRootLocation, file)); } else { resourceNames.add(toResourceNameOnClasspath(classPathRootOnDisk, file)); } } } return resourceNames; }
java
private Set<String> findResourceNamesFromFileSystem(String classPathRootOnDisk, String scanRootLocation, File folder) { LOGGER.debug("Scanning for resources in path: {} ({})", folder.getPath(), scanRootLocation); File[] files = folder.listFiles(); if (files == null) { return emptySet(); } Set<String> resourceNames = new TreeSet<>(); for (File file : files) { if (file.canRead()) { if (file.isDirectory()) { resourceNames.addAll(findResourceNamesFromFileSystem(classPathRootOnDisk, scanRootLocation, file)); } else { resourceNames.add(toResourceNameOnClasspath(classPathRootOnDisk, file)); } } } return resourceNames; }
[ "private", "Set", "<", "String", ">", "findResourceNamesFromFileSystem", "(", "String", "classPathRootOnDisk", ",", "String", "scanRootLocation", ",", "File", "folder", ")", "{", "LOGGER", ".", "debug", "(", "\"Scanning for resources in path: {} ({})\"", ",", "folder", ".", "getPath", "(", ")", ",", "scanRootLocation", ")", ";", "File", "[", "]", "files", "=", "folder", ".", "listFiles", "(", ")", ";", "if", "(", "files", "==", "null", ")", "{", "return", "emptySet", "(", ")", ";", "}", "Set", "<", "String", ">", "resourceNames", "=", "new", "TreeSet", "<>", "(", ")", ";", "for", "(", "File", "file", ":", "files", ")", "{", "if", "(", "file", ".", "canRead", "(", ")", ")", "{", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "resourceNames", ".", "addAll", "(", "findResourceNamesFromFileSystem", "(", "classPathRootOnDisk", ",", "scanRootLocation", ",", "file", ")", ")", ";", "}", "else", "{", "resourceNames", ".", "add", "(", "toResourceNameOnClasspath", "(", "classPathRootOnDisk", ",", "file", ")", ")", ";", "}", "}", "}", "return", "resourceNames", ";", "}" ]
Finds all the resource names contained in this file system folder. @param classPathRootOnDisk The location of the classpath root on disk, with a trailing slash. @param scanRootLocation The root location of the scan on the classpath, without leading or trailing slashes. @param folder The folder to look for resources under on disk. @return The resource names;
[ "Finds", "all", "the", "resource", "names", "contained", "in", "this", "file", "system", "folder", "." ]
c61840c23b17a18df704d136909c26ff46bd5c77
https://github.com/patka/cassandra-migration/blob/c61840c23b17a18df704d136909c26ff46bd5c77/cassandra-migration/src/main/java/org/cognitor/cassandra/migration/scanner/FileSystemLocationScanner.java#L58-L79
159,564
patka/cassandra-migration
cassandra-migration/src/main/java/org/cognitor/cassandra/migration/scanner/FileSystemLocationScanner.java
FileSystemLocationScanner.toResourceNameOnClasspath
private String toResourceNameOnClasspath(String classPathRootOnDisk, File file) { String fileName = file.getAbsolutePath().replace("\\", "/"); return fileName.substring(classPathRootOnDisk.length()); }
java
private String toResourceNameOnClasspath(String classPathRootOnDisk, File file) { String fileName = file.getAbsolutePath().replace("\\", "/"); return fileName.substring(classPathRootOnDisk.length()); }
[ "private", "String", "toResourceNameOnClasspath", "(", "String", "classPathRootOnDisk", ",", "File", "file", ")", "{", "String", "fileName", "=", "file", ".", "getAbsolutePath", "(", ")", ".", "replace", "(", "\"\\\\\"", ",", "\"/\"", ")", ";", "return", "fileName", ".", "substring", "(", "classPathRootOnDisk", ".", "length", "(", ")", ")", ";", "}" ]
Converts this file into a resource name on the classpath by cutting of the file path to the classpath root. @param classPathRootOnDisk The location of the classpath root on disk, with a trailing slash. @param file The file. @return The resource name on the classpath.
[ "Converts", "this", "file", "into", "a", "resource", "name", "on", "the", "classpath", "by", "cutting", "of", "the", "file", "path", "to", "the", "classpath", "root", "." ]
c61840c23b17a18df704d136909c26ff46bd5c77
https://github.com/patka/cassandra-migration/blob/c61840c23b17a18df704d136909c26ff46bd5c77/cassandra-migration/src/main/java/org/cognitor/cassandra/migration/scanner/FileSystemLocationScanner.java#L89-L92
159,565
patka/cassandra-migration
cassandra-migration/src/main/java/org/cognitor/cassandra/migration/util/Ensure.java
Ensure.notNull
public static <T> T notNull(T argument, String argumentName) { if (argument == null) { throw new IllegalArgumentException("Argument " + argumentName + " must not be null."); } return argument; }
java
public static <T> T notNull(T argument, String argumentName) { if (argument == null) { throw new IllegalArgumentException("Argument " + argumentName + " must not be null."); } return argument; }
[ "public", "static", "<", "T", ">", "T", "notNull", "(", "T", "argument", ",", "String", "argumentName", ")", "{", "if", "(", "argument", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Argument \"", "+", "argumentName", "+", "\" must not be null.\"", ")", ";", "}", "return", "argument", ";", "}" ]
Checks if the given argument is null and throws an exception with a message containing the argument name if that it true. @param argument the argument to check for null @param argumentName the name of the argument to check. This is used in the exception message. @param <T> the type of the argument @return the argument itself @throws IllegalArgumentException in case argument is null
[ "Checks", "if", "the", "given", "argument", "is", "null", "and", "throws", "an", "exception", "with", "a", "message", "containing", "the", "argument", "name", "if", "that", "it", "true", "." ]
c61840c23b17a18df704d136909c26ff46bd5c77
https://github.com/patka/cassandra-migration/blob/c61840c23b17a18df704d136909c26ff46bd5c77/cassandra-migration/src/main/java/org/cognitor/cassandra/migration/util/Ensure.java#L21-L26
159,566
patka/cassandra-migration
cassandra-migration/src/main/java/org/cognitor/cassandra/migration/util/Ensure.java
Ensure.notNullOrEmpty
public static String notNullOrEmpty(String argument, String argumentName) { if (argument == null || argument.trim().isEmpty()) { throw new IllegalArgumentException("Argument " + argumentName + " must not be null or empty."); } return argument; }
java
public static String notNullOrEmpty(String argument, String argumentName) { if (argument == null || argument.trim().isEmpty()) { throw new IllegalArgumentException("Argument " + argumentName + " must not be null or empty."); } return argument; }
[ "public", "static", "String", "notNullOrEmpty", "(", "String", "argument", ",", "String", "argumentName", ")", "{", "if", "(", "argument", "==", "null", "||", "argument", ".", "trim", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Argument \"", "+", "argumentName", "+", "\" must not be null or empty.\"", ")", ";", "}", "return", "argument", ";", "}" ]
Checks if the given String is null or contains only whitespaces. The String is trimmed before the empty check. @param argument the String to check for null or emptiness @param argumentName the name of the argument to check. This is used in the exception message. @return the String that was given as argument @throws IllegalArgumentException in case argument is null or empty
[ "Checks", "if", "the", "given", "String", "is", "null", "or", "contains", "only", "whitespaces", ".", "The", "String", "is", "trimmed", "before", "the", "empty", "check", "." ]
c61840c23b17a18df704d136909c26ff46bd5c77
https://github.com/patka/cassandra-migration/blob/c61840c23b17a18df704d136909c26ff46bd5c77/cassandra-migration/src/main/java/org/cognitor/cassandra/migration/util/Ensure.java#L38-L43
159,567
allure-framework/allure1
allure-commons/src/main/java/ru/yandex/qatools/allure/commons/AllureFileUtils.java
AllureFileUtils.unmarshal
public static TestSuiteResult unmarshal(File testSuite) throws IOException { try (InputStream stream = new FileInputStream(testSuite)) { return unmarshal(stream); } }
java
public static TestSuiteResult unmarshal(File testSuite) throws IOException { try (InputStream stream = new FileInputStream(testSuite)) { return unmarshal(stream); } }
[ "public", "static", "TestSuiteResult", "unmarshal", "(", "File", "testSuite", ")", "throws", "IOException", "{", "try", "(", "InputStream", "stream", "=", "new", "FileInputStream", "(", "testSuite", ")", ")", "{", "return", "unmarshal", "(", "stream", ")", ";", "}", "}" ]
Unmarshal test suite from given file.
[ "Unmarshal", "test", "suite", "from", "given", "file", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commons/src/main/java/ru/yandex/qatools/allure/commons/AllureFileUtils.java#L38-L42
159,568
allure-framework/allure1
allure-commons/src/main/java/ru/yandex/qatools/allure/commons/AllureFileUtils.java
AllureFileUtils.unmarshalSuites
public static List<TestSuiteResult> unmarshalSuites(File... directories) throws IOException { List<TestSuiteResult> results = new ArrayList<>(); List<File> files = listTestSuiteFiles(directories); for (File file : files) { results.add(unmarshal(file)); } return results; }
java
public static List<TestSuiteResult> unmarshalSuites(File... directories) throws IOException { List<TestSuiteResult> results = new ArrayList<>(); List<File> files = listTestSuiteFiles(directories); for (File file : files) { results.add(unmarshal(file)); } return results; }
[ "public", "static", "List", "<", "TestSuiteResult", ">", "unmarshalSuites", "(", "File", "...", "directories", ")", "throws", "IOException", "{", "List", "<", "TestSuiteResult", ">", "results", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "File", ">", "files", "=", "listTestSuiteFiles", "(", "directories", ")", ";", "for", "(", "File", "file", ":", "files", ")", "{", "results", ".", "add", "(", "unmarshal", "(", "file", ")", ")", ";", "}", "return", "results", ";", "}" ]
Find and unmarshal all test suite files in given directories. @throws IOException if any occurs. @see #unmarshal(File)
[ "Find", "and", "unmarshal", "all", "test", "suite", "files", "in", "given", "directories", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commons/src/main/java/ru/yandex/qatools/allure/commons/AllureFileUtils.java#L68-L77
159,569
allure-framework/allure1
allure-commons/src/main/java/ru/yandex/qatools/allure/commons/AllureFileUtils.java
AllureFileUtils.listFilesByRegex
public static List<File> listFilesByRegex(String regex, File... directories) { return listFiles(directories, new RegexFileFilter(regex), CanReadFileFilter.CAN_READ); }
java
public static List<File> listFilesByRegex(String regex, File... directories) { return listFiles(directories, new RegexFileFilter(regex), CanReadFileFilter.CAN_READ); }
[ "public", "static", "List", "<", "File", ">", "listFilesByRegex", "(", "String", "regex", ",", "File", "...", "directories", ")", "{", "return", "listFiles", "(", "directories", ",", "new", "RegexFileFilter", "(", "regex", ")", ",", "CanReadFileFilter", ".", "CAN_READ", ")", ";", "}" ]
Returns list of files matches specified regex in specified directories @param regex to match file names @param directories to find @return list of files matches specified regex in specified directories
[ "Returns", "list", "of", "files", "matches", "specified", "regex", "in", "specified", "directories" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commons/src/main/java/ru/yandex/qatools/allure/commons/AllureFileUtils.java#L112-L116
159,570
allure-framework/allure1
allure-commons/src/main/java/ru/yandex/qatools/allure/commons/AllureFileUtils.java
AllureFileUtils.listFiles
public static List<File> listFiles(File[] directories, IOFileFilter fileFilter, IOFileFilter dirFilter) { List<File> files = new ArrayList<>(); for (File directory : directories) { if (!directory.isDirectory()) { continue; } Collection<File> filesInDirectory = FileUtils.listFiles(directory, fileFilter, dirFilter); files.addAll(filesInDirectory); } return files; }
java
public static List<File> listFiles(File[] directories, IOFileFilter fileFilter, IOFileFilter dirFilter) { List<File> files = new ArrayList<>(); for (File directory : directories) { if (!directory.isDirectory()) { continue; } Collection<File> filesInDirectory = FileUtils.listFiles(directory, fileFilter, dirFilter); files.addAll(filesInDirectory); } return files; }
[ "public", "static", "List", "<", "File", ">", "listFiles", "(", "File", "[", "]", "directories", ",", "IOFileFilter", "fileFilter", ",", "IOFileFilter", "dirFilter", ")", "{", "List", "<", "File", ">", "files", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "File", "directory", ":", "directories", ")", "{", "if", "(", "!", "directory", ".", "isDirectory", "(", ")", ")", "{", "continue", ";", "}", "Collection", "<", "File", ">", "filesInDirectory", "=", "FileUtils", ".", "listFiles", "(", "directory", ",", "fileFilter", ",", "dirFilter", ")", ";", "files", ".", "addAll", "(", "filesInDirectory", ")", ";", "}", "return", "files", ";", "}" ]
Returns list of files matches filters in specified directories @param directories which will using to find files @param fileFilter file filter @param dirFilter directory filter @return list of files matches filters in specified directories
[ "Returns", "list", "of", "files", "matches", "filters", "in", "specified", "directories" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commons/src/main/java/ru/yandex/qatools/allure/commons/AllureFileUtils.java#L126-L138
159,571
allure-framework/allure1
allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AnnotationManager.java
AnnotationManager.populateAnnotations
private void populateAnnotations(Collection<Annotation> annotations) { for (Annotation each : annotations) { this.annotations.put(each.annotationType(), each); } }
java
private void populateAnnotations(Collection<Annotation> annotations) { for (Annotation each : annotations) { this.annotations.put(each.annotationType(), each); } }
[ "private", "void", "populateAnnotations", "(", "Collection", "<", "Annotation", ">", "annotations", ")", "{", "for", "(", "Annotation", "each", ":", "annotations", ")", "{", "this", ".", "annotations", ".", "put", "(", "each", ".", "annotationType", "(", ")", ",", "each", ")", ";", "}", "}" ]
Used to populate Map with given annotations @param annotations initial value for annotations
[ "Used", "to", "populate", "Map", "with", "given", "annotations" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AnnotationManager.java#L76-L80
159,572
allure-framework/allure1
allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AnnotationManager.java
AnnotationManager.setDefaults
public void setDefaults(Annotation[] defaultAnnotations) { if (defaultAnnotations == null) { return; } for (Annotation each : defaultAnnotations) { Class<? extends Annotation> key = each.annotationType(); if (Title.class.equals(key) || Description.class.equals(key)) { continue; } if (!annotations.containsKey(key)) { annotations.put(key, each); } } }
java
public void setDefaults(Annotation[] defaultAnnotations) { if (defaultAnnotations == null) { return; } for (Annotation each : defaultAnnotations) { Class<? extends Annotation> key = each.annotationType(); if (Title.class.equals(key) || Description.class.equals(key)) { continue; } if (!annotations.containsKey(key)) { annotations.put(key, each); } } }
[ "public", "void", "setDefaults", "(", "Annotation", "[", "]", "defaultAnnotations", ")", "{", "if", "(", "defaultAnnotations", "==", "null", ")", "{", "return", ";", "}", "for", "(", "Annotation", "each", ":", "defaultAnnotations", ")", "{", "Class", "<", "?", "extends", "Annotation", ">", "key", "=", "each", ".", "annotationType", "(", ")", ";", "if", "(", "Title", ".", "class", ".", "equals", "(", "key", ")", "||", "Description", ".", "class", ".", "equals", "(", "key", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "annotations", ".", "containsKey", "(", "key", ")", ")", "{", "annotations", ".", "put", "(", "key", ",", "each", ")", ";", "}", "}", "}" ]
Set default values for annotations. Initial annotation take precedence over the default annotation when both annotation types are present @param defaultAnnotations default value for annotations
[ "Set", "default", "values", "for", "annotations", ".", "Initial", "annotation", "take", "precedence", "over", "the", "default", "annotation", "when", "both", "annotation", "types", "are", "present" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AnnotationManager.java#L88-L101
159,573
allure-framework/allure1
allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AnnotationManager.java
AnnotationManager.getHostname
private static String getHostname() { if (Hostname == null) { try { Hostname = InetAddress.getLocalHost().getHostName(); } catch (Exception e) { Hostname = "default"; LOGGER.warn("Can not get current hostname", e); } } return Hostname; }
java
private static String getHostname() { if (Hostname == null) { try { Hostname = InetAddress.getLocalHost().getHostName(); } catch (Exception e) { Hostname = "default"; LOGGER.warn("Can not get current hostname", e); } } return Hostname; }
[ "private", "static", "String", "getHostname", "(", ")", "{", "if", "(", "Hostname", "==", "null", ")", "{", "try", "{", "Hostname", "=", "InetAddress", ".", "getLocalHost", "(", ")", ".", "getHostName", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Hostname", "=", "\"default\"", ";", "LOGGER", ".", "warn", "(", "\"Can not get current hostname\"", ",", "e", ")", ";", "}", "}", "return", "Hostname", ";", "}" ]
Save current hostname and reuse it. @return hostname as String
[ "Save", "current", "hostname", "and", "reuse", "it", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AnnotationManager.java#L108-L118
159,574
allure-framework/allure1
allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AnnotationManager.java
AnnotationManager.withExecutorInfo
public static TestCaseStartedEvent withExecutorInfo(TestCaseStartedEvent event) { event.getLabels().add(createHostLabel(getHostname())); event.getLabels().add(createThreadLabel(format("%s.%s(%s)", ManagementFactory.getRuntimeMXBean().getName(), Thread.currentThread().getName(), Thread.currentThread().getId()) )); return event; }
java
public static TestCaseStartedEvent withExecutorInfo(TestCaseStartedEvent event) { event.getLabels().add(createHostLabel(getHostname())); event.getLabels().add(createThreadLabel(format("%s.%s(%s)", ManagementFactory.getRuntimeMXBean().getName(), Thread.currentThread().getName(), Thread.currentThread().getId()) )); return event; }
[ "public", "static", "TestCaseStartedEvent", "withExecutorInfo", "(", "TestCaseStartedEvent", "event", ")", "{", "event", ".", "getLabels", "(", ")", ".", "add", "(", "createHostLabel", "(", "getHostname", "(", ")", ")", ")", ";", "event", ".", "getLabels", "(", ")", ".", "add", "(", "createThreadLabel", "(", "format", "(", "\"%s.%s(%s)\"", ",", "ManagementFactory", ".", "getRuntimeMXBean", "(", ")", ".", "getName", "(", ")", ",", "Thread", ".", "currentThread", "(", ")", ".", "getName", "(", ")", ",", "Thread", ".", "currentThread", "(", ")", ".", "getId", "(", ")", ")", ")", ")", ";", "return", "event", ";", "}" ]
Add information about host and thread to specified test case started event @param event given event to update @return updated event
[ "Add", "information", "about", "host", "and", "thread", "to", "specified", "test", "case", "started", "event" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AnnotationManager.java#L193-L201
159,575
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportOpen.java
ReportOpen.openBrowser
private void openBrowser(URI url) throws IOException { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(url); } else { LOGGER.error("Can not open browser because this capability is not supported on " + "your platform. You can use the link below to open the report manually."); } }
java
private void openBrowser(URI url) throws IOException { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(url); } else { LOGGER.error("Can not open browser because this capability is not supported on " + "your platform. You can use the link below to open the report manually."); } }
[ "private", "void", "openBrowser", "(", "URI", "url", ")", "throws", "IOException", "{", "if", "(", "Desktop", ".", "isDesktopSupported", "(", ")", ")", "{", "Desktop", ".", "getDesktop", "(", ")", ".", "browse", "(", "url", ")", ";", "}", "else", "{", "LOGGER", ".", "error", "(", "\"Can not open browser because this capability is not supported on \"", "+", "\"your platform. You can use the link below to open the report manually.\"", ")", ";", "}", "}" ]
Open the given url in default system browser.
[ "Open", "the", "given", "url", "in", "default", "system", "browser", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportOpen.java#L53-L60
159,576
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportOpen.java
ReportOpen.setUpServer
private Server setUpServer() { Server server = new Server(port); ResourceHandler handler = new ResourceHandler(); handler.setDirectoriesListed(true); handler.setWelcomeFiles(new String[]{"index.html"}); handler.setResourceBase(getReportDirectoryPath().toAbsolutePath().toString()); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[]{handler, new DefaultHandler()}); server.setStopAtShutdown(true); server.setHandler(handlers); return server; }
java
private Server setUpServer() { Server server = new Server(port); ResourceHandler handler = new ResourceHandler(); handler.setDirectoriesListed(true); handler.setWelcomeFiles(new String[]{"index.html"}); handler.setResourceBase(getReportDirectoryPath().toAbsolutePath().toString()); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[]{handler, new DefaultHandler()}); server.setStopAtShutdown(true); server.setHandler(handlers); return server; }
[ "private", "Server", "setUpServer", "(", ")", "{", "Server", "server", "=", "new", "Server", "(", "port", ")", ";", "ResourceHandler", "handler", "=", "new", "ResourceHandler", "(", ")", ";", "handler", ".", "setDirectoriesListed", "(", "true", ")", ";", "handler", ".", "setWelcomeFiles", "(", "new", "String", "[", "]", "{", "\"index.html\"", "}", ")", ";", "handler", ".", "setResourceBase", "(", "getReportDirectoryPath", "(", ")", ".", "toAbsolutePath", "(", ")", ".", "toString", "(", ")", ")", ";", "HandlerList", "handlers", "=", "new", "HandlerList", "(", ")", ";", "handlers", ".", "setHandlers", "(", "new", "Handler", "[", "]", "{", "handler", ",", "new", "DefaultHandler", "(", ")", "}", ")", ";", "server", ".", "setStopAtShutdown", "(", "true", ")", ";", "server", ".", "setHandler", "(", "handlers", ")", ";", "return", "server", ";", "}" ]
Set up server for report directory.
[ "Set", "up", "server", "for", "report", "directory", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportOpen.java#L65-L76
159,577
allure-framework/allure1
allure-report-plugin-api/src/main/java/ru/yandex/qatools/allure/data/plugins/AbstractPlugin.java
AbstractPlugin.checkModifiers
private static boolean checkModifiers(Class<? extends AbstractPlugin> pluginClass) { int modifiers = pluginClass.getModifiers(); return !Modifier.isAbstract(modifiers) && !Modifier.isInterface(modifiers) && !Modifier.isPrivate(modifiers); }
java
private static boolean checkModifiers(Class<? extends AbstractPlugin> pluginClass) { int modifiers = pluginClass.getModifiers(); return !Modifier.isAbstract(modifiers) && !Modifier.isInterface(modifiers) && !Modifier.isPrivate(modifiers); }
[ "private", "static", "boolean", "checkModifiers", "(", "Class", "<", "?", "extends", "AbstractPlugin", ">", "pluginClass", ")", "{", "int", "modifiers", "=", "pluginClass", ".", "getModifiers", "(", ")", ";", "return", "!", "Modifier", ".", "isAbstract", "(", "modifiers", ")", "&&", "!", "Modifier", ".", "isInterface", "(", "modifiers", ")", "&&", "!", "Modifier", ".", "isPrivate", "(", "modifiers", ")", ";", "}" ]
Check given class modifiers. Plugin with resources plugin should not be private or abstract or interface.
[ "Check", "given", "class", "modifiers", ".", "Plugin", "with", "resources", "plugin", "should", "not", "be", "private", "or", "abstract", "or", "interface", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-report-plugin-api/src/main/java/ru/yandex/qatools/allure/data/plugins/AbstractPlugin.java#L110-L115
159,578
allure-framework/allure1
allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/experimental/ListenersNotifier.java
ListenersNotifier.fire
@Override public void fire(StepStartedEvent event) { for (LifecycleListener listener : listeners) { try { listener.fire(event); } catch (Exception e) { logError(listener, e); } } }
java
@Override public void fire(StepStartedEvent event) { for (LifecycleListener listener : listeners) { try { listener.fire(event); } catch (Exception e) { logError(listener, e); } } }
[ "@", "Override", "public", "void", "fire", "(", "StepStartedEvent", "event", ")", "{", "for", "(", "LifecycleListener", "listener", ":", "listeners", ")", "{", "try", "{", "listener", ".", "fire", "(", "event", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logError", "(", "listener", ",", "e", ")", ";", "}", "}", "}" ]
Invoke to tell listeners that an step started event processed
[ "Invoke", "to", "tell", "listeners", "that", "an", "step", "started", "event", "processed" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/experimental/ListenersNotifier.java#L106-L115
159,579
allure-framework/allure1
allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/experimental/ListenersNotifier.java
ListenersNotifier.logError
private void logError(LifecycleListener listener, Exception e) { LOGGER.error("Error for listener " + listener.getClass(), e); }
java
private void logError(LifecycleListener listener, Exception e) { LOGGER.error("Error for listener " + listener.getClass(), e); }
[ "private", "void", "logError", "(", "LifecycleListener", "listener", ",", "Exception", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Error for listener \"", "+", "listener", ".", "getClass", "(", ")", ",", "e", ")", ";", "}" ]
This method log given exception in specified listener
[ "This", "method", "log", "given", "exception", "in", "specified", "listener" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/experimental/ListenersNotifier.java#L246-L248
159,580
allure-framework/allure1
allure-java-aspects/src/main/java/ru/yandex/qatools/allure/aspects/AllureAspectUtils.java
AllureAspectUtils.cutEnd
public static String cutEnd(String data, int maxLength) { if (data.length() > maxLength) { return data.substring(0, maxLength) + "..."; } else { return data; } }
java
public static String cutEnd(String data, int maxLength) { if (data.length() > maxLength) { return data.substring(0, maxLength) + "..."; } else { return data; } }
[ "public", "static", "String", "cutEnd", "(", "String", "data", ",", "int", "maxLength", ")", "{", "if", "(", "data", ".", "length", "(", ")", ">", "maxLength", ")", "{", "return", "data", ".", "substring", "(", "0", ",", "maxLength", ")", "+", "\"...\"", ";", "}", "else", "{", "return", "data", ";", "}", "}" ]
Cut all characters from maxLength and replace it with "..."
[ "Cut", "all", "characters", "from", "maxLength", "and", "replace", "it", "with", "..." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-aspects/src/main/java/ru/yandex/qatools/allure/aspects/AllureAspectUtils.java#L90-L96
159,581
allure-framework/allure1
allure-report-data/src/main/java/ru/yandex/qatools/allure/data/utils/ServiceLoaderUtils.java
ServiceLoaderUtils.load
public static <T> List<T> load(ClassLoader classLoader, Class<T> serviceType) { List<T> foundServices = new ArrayList<>(); Iterator<T> iterator = ServiceLoader.load(serviceType, classLoader).iterator(); while (checkHasNextSafely(iterator)) { try { T item = iterator.next(); foundServices.add(item); LOGGER.debug(String.format("Found %s [%s]", serviceType.getSimpleName(), item.toString())); } catch (ServiceConfigurationError e) { LOGGER.trace("Can't find services using Java SPI", e); LOGGER.error(e.getMessage()); } } return foundServices; }
java
public static <T> List<T> load(ClassLoader classLoader, Class<T> serviceType) { List<T> foundServices = new ArrayList<>(); Iterator<T> iterator = ServiceLoader.load(serviceType, classLoader).iterator(); while (checkHasNextSafely(iterator)) { try { T item = iterator.next(); foundServices.add(item); LOGGER.debug(String.format("Found %s [%s]", serviceType.getSimpleName(), item.toString())); } catch (ServiceConfigurationError e) { LOGGER.trace("Can't find services using Java SPI", e); LOGGER.error(e.getMessage()); } } return foundServices; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "load", "(", "ClassLoader", "classLoader", ",", "Class", "<", "T", ">", "serviceType", ")", "{", "List", "<", "T", ">", "foundServices", "=", "new", "ArrayList", "<>", "(", ")", ";", "Iterator", "<", "T", ">", "iterator", "=", "ServiceLoader", ".", "load", "(", "serviceType", ",", "classLoader", ")", ".", "iterator", "(", ")", ";", "while", "(", "checkHasNextSafely", "(", "iterator", ")", ")", "{", "try", "{", "T", "item", "=", "iterator", ".", "next", "(", ")", ";", "foundServices", ".", "add", "(", "item", ")", ";", "LOGGER", ".", "debug", "(", "String", ".", "format", "(", "\"Found %s [%s]\"", ",", "serviceType", ".", "getSimpleName", "(", ")", ",", "item", ".", "toString", "(", ")", ")", ")", ";", "}", "catch", "(", "ServiceConfigurationError", "e", ")", "{", "LOGGER", ".", "trace", "(", "\"Can't find services using Java SPI\"", ",", "e", ")", ";", "LOGGER", ".", "error", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "return", "foundServices", ";", "}" ]
Invoke to find all services for given service type using specified class loader @param classLoader specified class loader @param serviceType given service type @return List of found services
[ "Invoke", "to", "find", "all", "services", "for", "given", "service", "type", "using", "specified", "class", "loader" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-report-data/src/main/java/ru/yandex/qatools/allure/data/utils/ServiceLoaderUtils.java#L35-L50
159,582
allure-framework/allure1
allure-bundle/src/main/java/ru/yandex/qatools/allure/AllureMain.java
AllureMain.unpackFace
private static void unpackFace(File outputDirectory) throws IOException { ClassLoader loader = AllureMain.class.getClassLoader(); for (ClassPath.ResourceInfo info : ClassPath.from(loader).getResources()) { Matcher matcher = REPORT_RESOURCE_PATTERN.matcher(info.getResourceName()); if (matcher.find()) { String resourcePath = matcher.group(1); File dest = new File(outputDirectory, resourcePath); Files.createParentDirs(dest); try (FileOutputStream output = new FileOutputStream(dest); InputStream input = info.url().openStream()) { IOUtils.copy(input, output); LOGGER.debug("{} successfully copied.", resourcePath); } } } }
java
private static void unpackFace(File outputDirectory) throws IOException { ClassLoader loader = AllureMain.class.getClassLoader(); for (ClassPath.ResourceInfo info : ClassPath.from(loader).getResources()) { Matcher matcher = REPORT_RESOURCE_PATTERN.matcher(info.getResourceName()); if (matcher.find()) { String resourcePath = matcher.group(1); File dest = new File(outputDirectory, resourcePath); Files.createParentDirs(dest); try (FileOutputStream output = new FileOutputStream(dest); InputStream input = info.url().openStream()) { IOUtils.copy(input, output); LOGGER.debug("{} successfully copied.", resourcePath); } } } }
[ "private", "static", "void", "unpackFace", "(", "File", "outputDirectory", ")", "throws", "IOException", "{", "ClassLoader", "loader", "=", "AllureMain", ".", "class", ".", "getClassLoader", "(", ")", ";", "for", "(", "ClassPath", ".", "ResourceInfo", "info", ":", "ClassPath", ".", "from", "(", "loader", ")", ".", "getResources", "(", ")", ")", "{", "Matcher", "matcher", "=", "REPORT_RESOURCE_PATTERN", ".", "matcher", "(", "info", ".", "getResourceName", "(", ")", ")", ";", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "String", "resourcePath", "=", "matcher", ".", "group", "(", "1", ")", ";", "File", "dest", "=", "new", "File", "(", "outputDirectory", ",", "resourcePath", ")", ";", "Files", ".", "createParentDirs", "(", "dest", ")", ";", "try", "(", "FileOutputStream", "output", "=", "new", "FileOutputStream", "(", "dest", ")", ";", "InputStream", "input", "=", "info", ".", "url", "(", ")", ".", "openStream", "(", ")", ")", "{", "IOUtils", ".", "copy", "(", "input", ",", "output", ")", ";", "LOGGER", ".", "debug", "(", "\"{} successfully copied.\"", ",", "resourcePath", ")", ";", "}", "}", "}", "}" ]
Unpack report face to given directory. @param outputDirectory the output directory to unpack face. @throws IOException if any occurs.
[ "Unpack", "report", "face", "to", "given", "directory", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-bundle/src/main/java/ru/yandex/qatools/allure/AllureMain.java#L59-L74
159,583
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/AbstractCommand.java
AbstractCommand.createTempDirectory
protected Path createTempDirectory(String prefix) { try { return Files.createTempDirectory(tempDirectory, prefix); } catch (IOException e) { throw new AllureCommandException(e); } }
java
protected Path createTempDirectory(String prefix) { try { return Files.createTempDirectory(tempDirectory, prefix); } catch (IOException e) { throw new AllureCommandException(e); } }
[ "protected", "Path", "createTempDirectory", "(", "String", "prefix", ")", "{", "try", "{", "return", "Files", ".", "createTempDirectory", "(", "tempDirectory", ",", "prefix", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "AllureCommandException", "(", "e", ")", ";", "}", "}" ]
Creates an temporary directory. The created directory will be deleted when command will ended.
[ "Creates", "an", "temporary", "directory", ".", "The", "created", "directory", "will", "be", "deleted", "when", "command", "will", "ended", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/AbstractCommand.java#L65-L71
159,584
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/AbstractCommand.java
AbstractCommand.getLogLevel
private Level getLogLevel() { return isQuiet() ? Level.OFF : isVerbose() ? Level.DEBUG : Level.INFO; }
java
private Level getLogLevel() { return isQuiet() ? Level.OFF : isVerbose() ? Level.DEBUG : Level.INFO; }
[ "private", "Level", "getLogLevel", "(", ")", "{", "return", "isQuiet", "(", ")", "?", "Level", ".", "OFF", ":", "isVerbose", "(", ")", "?", "Level", ".", "DEBUG", ":", "Level", ".", "INFO", ";", "}" ]
Get log level depends on provided client parameters such as verbose and quiet.
[ "Get", "log", "level", "depends", "on", "provided", "client", "parameters", "such", "as", "verbose", "and", "quiet", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/AbstractCommand.java#L138-L140
159,585
allure-framework/allure1
allure-model/src/main/java/ru/yandex/qatools/allure/config/AllureNamingUtils.java
AllureNamingUtils.isBadXmlCharacter
public static boolean isBadXmlCharacter(char c) { boolean cDataCharacter = c < '\u0020' && c != '\t' && c != '\r' && c != '\n'; cDataCharacter |= (c >= '\uD800' && c < '\uE000'); cDataCharacter |= (c == '\uFFFE' || c == '\uFFFF'); return cDataCharacter; }
java
public static boolean isBadXmlCharacter(char c) { boolean cDataCharacter = c < '\u0020' && c != '\t' && c != '\r' && c != '\n'; cDataCharacter |= (c >= '\uD800' && c < '\uE000'); cDataCharacter |= (c == '\uFFFE' || c == '\uFFFF'); return cDataCharacter; }
[ "public", "static", "boolean", "isBadXmlCharacter", "(", "char", "c", ")", "{", "boolean", "cDataCharacter", "=", "c", "<", "'", "'", "&&", "c", "!=", "'", "'", "&&", "c", "!=", "'", "'", "&&", "c", "!=", "'", "'", ";", "cDataCharacter", "|=", "(", "c", ">=", "'", "'", "&&", "c", "<", "'", "'", ")", ";", "cDataCharacter", "|=", "(", "c", "==", "'", "'", "||", "c", "==", "'", "'", ")", ";", "return", "cDataCharacter", ";", "}" ]
Detect bad xml 1.0 characters @param c to detect @return true if specified character valid, false otherwise
[ "Detect", "bad", "xml", "1", ".", "0", "characters" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-model/src/main/java/ru/yandex/qatools/allure/config/AllureNamingUtils.java#L49-L54
159,586
allure-framework/allure1
allure-model/src/main/java/ru/yandex/qatools/allure/config/AllureNamingUtils.java
AllureNamingUtils.replaceBadXmlCharactersBySpace
public static void replaceBadXmlCharactersBySpace(char[] cbuf, int off, int len) { for (int i = off; i < off + len; i++) { if (isBadXmlCharacter(cbuf[i])) { cbuf[i] = '\u0020'; } } }
java
public static void replaceBadXmlCharactersBySpace(char[] cbuf, int off, int len) { for (int i = off; i < off + len; i++) { if (isBadXmlCharacter(cbuf[i])) { cbuf[i] = '\u0020'; } } }
[ "public", "static", "void", "replaceBadXmlCharactersBySpace", "(", "char", "[", "]", "cbuf", ",", "int", "off", ",", "int", "len", ")", "{", "for", "(", "int", "i", "=", "off", ";", "i", "<", "off", "+", "len", ";", "i", "++", ")", "{", "if", "(", "isBadXmlCharacter", "(", "cbuf", "[", "i", "]", ")", ")", "{", "cbuf", "[", "i", "]", "=", "'", "'", ";", "}", "}", "}" ]
Replace bad xml charactes in given array by space @param cbuf buffer to replace in @param off Offset from which to start reading characters @param len Number of characters to be replaced
[ "Replace", "bad", "xml", "charactes", "in", "given", "array", "by", "space" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-model/src/main/java/ru/yandex/qatools/allure/config/AllureNamingUtils.java#L63-L69
159,587
allure-framework/allure1
allure-commons/src/main/java/ru/yandex/qatools/allure/commons/BadXmlCharacterFilterReader.java
BadXmlCharacterFilterReader.read
@Override public int read(char[] cbuf, int off, int len) throws IOException { int numChars = super.read(cbuf, off, len); replaceBadXmlCharactersBySpace(cbuf, off, len); return numChars; }
java
@Override public int read(char[] cbuf, int off, int len) throws IOException { int numChars = super.read(cbuf, off, len); replaceBadXmlCharactersBySpace(cbuf, off, len); return numChars; }
[ "@", "Override", "public", "int", "read", "(", "char", "[", "]", "cbuf", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "int", "numChars", "=", "super", ".", "read", "(", "cbuf", ",", "off", ",", "len", ")", ";", "replaceBadXmlCharactersBySpace", "(", "cbuf", ",", "off", ",", "len", ")", ";", "return", "numChars", ";", "}" ]
Reads characters into a portion of an array, then replace invalid XML characters @throws IOException If an I/O error occurs @see ru.yandex.qatools.allure.config.AllureNamingUtils#isBadXmlCharacter(char) by space
[ "Reads", "characters", "into", "a", "portion", "of", "an", "array", "then", "replace", "invalid", "XML", "characters" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commons/src/main/java/ru/yandex/qatools/allure/commons/BadXmlCharacterFilterReader.java#L31-L36
159,588
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportClean.java
ReportClean.runUnsafe
@Override protected void runUnsafe() throws Exception { Path reportDirectory = getReportDirectoryPath(); Files.walkFileTree(reportDirectory, new DeleteVisitor()); LOGGER.info("Report directory <{}> was successfully cleaned.", reportDirectory); }
java
@Override protected void runUnsafe() throws Exception { Path reportDirectory = getReportDirectoryPath(); Files.walkFileTree(reportDirectory, new DeleteVisitor()); LOGGER.info("Report directory <{}> was successfully cleaned.", reportDirectory); }
[ "@", "Override", "protected", "void", "runUnsafe", "(", ")", "throws", "Exception", "{", "Path", "reportDirectory", "=", "getReportDirectoryPath", "(", ")", ";", "Files", ".", "walkFileTree", "(", "reportDirectory", ",", "new", "DeleteVisitor", "(", ")", ")", ";", "LOGGER", ".", "info", "(", "\"Report directory <{}> was successfully cleaned.\"", ",", "reportDirectory", ")", ";", "}" ]
Remove the report directory.
[ "Remove", "the", "report", "directory", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportClean.java#L22-L27
159,589
allure-framework/allure1
allure-report-data/src/main/java/ru/yandex/qatools/allure/data/DummyReportGenerator.java
DummyReportGenerator.main
public static void main(String[] args) { if (args.length < 2) { // NOSONAR LOGGER.error("There must be at least two arguments"); return; } int lastIndex = args.length - 1; AllureReportGenerator reportGenerator = new AllureReportGenerator( getFiles(Arrays.copyOf(args, lastIndex)) ); reportGenerator.generate(new File(args[lastIndex])); }
java
public static void main(String[] args) { if (args.length < 2) { // NOSONAR LOGGER.error("There must be at least two arguments"); return; } int lastIndex = args.length - 1; AllureReportGenerator reportGenerator = new AllureReportGenerator( getFiles(Arrays.copyOf(args, lastIndex)) ); reportGenerator.generate(new File(args[lastIndex])); }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "if", "(", "args", ".", "length", "<", "2", ")", "{", "// NOSONAR", "LOGGER", ".", "error", "(", "\"There must be at least two arguments\"", ")", ";", "return", ";", "}", "int", "lastIndex", "=", "args", ".", "length", "-", "1", ";", "AllureReportGenerator", "reportGenerator", "=", "new", "AllureReportGenerator", "(", "getFiles", "(", "Arrays", ".", "copyOf", "(", "args", ",", "lastIndex", ")", ")", ")", ";", "reportGenerator", ".", "generate", "(", "new", "File", "(", "args", "[", "lastIndex", "]", ")", ")", ";", "}" ]
Generate Allure report data from directories with allure report results. @param args a list of directory paths. First (args.length - 1) arguments - results directories, last argument - the folder to generated data
[ "Generate", "Allure", "report", "data", "from", "directories", "with", "allure", "report", "results", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-report-data/src/main/java/ru/yandex/qatools/allure/data/DummyReportGenerator.java#L28-L38
159,590
allure-framework/allure1
allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AllureResultsUtils.java
AllureResultsUtils.setPropertySafely
public static void setPropertySafely(Marshaller marshaller, String name, Object value) { try { marshaller.setProperty(name, value); } catch (PropertyException e) { LOGGER.warn(String.format("Can't set \"%s\" property to given marshaller", name), e); } }
java
public static void setPropertySafely(Marshaller marshaller, String name, Object value) { try { marshaller.setProperty(name, value); } catch (PropertyException e) { LOGGER.warn(String.format("Can't set \"%s\" property to given marshaller", name), e); } }
[ "public", "static", "void", "setPropertySafely", "(", "Marshaller", "marshaller", ",", "String", "name", ",", "Object", "value", ")", "{", "try", "{", "marshaller", ".", "setProperty", "(", "name", ",", "value", ")", ";", "}", "catch", "(", "PropertyException", "e", ")", "{", "LOGGER", ".", "warn", "(", "String", ".", "format", "(", "\"Can't set \\\"%s\\\" property to given marshaller\"", ",", "name", ")", ",", "e", ")", ";", "}", "}" ]
Try to set specified property to given marshaller @param marshaller specified marshaller @param name name of property to set @param value value of property to set
[ "Try", "to", "set", "specified", "property", "to", "given", "marshaller" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AllureResultsUtils.java#L194-L200
159,591
allure-framework/allure1
allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AllureResultsUtils.java
AllureResultsUtils.writeAttachmentWithErrorMessage
public static Attachment writeAttachmentWithErrorMessage(Throwable throwable, String title) { String message = throwable.getMessage(); try { return writeAttachment(message.getBytes(CONFIG.getAttachmentsEncoding()), title); } catch (Exception e) { e.addSuppressed(throwable); LOGGER.error(String.format("Can't write attachment \"%s\"", title), e); } return new Attachment(); }
java
public static Attachment writeAttachmentWithErrorMessage(Throwable throwable, String title) { String message = throwable.getMessage(); try { return writeAttachment(message.getBytes(CONFIG.getAttachmentsEncoding()), title); } catch (Exception e) { e.addSuppressed(throwable); LOGGER.error(String.format("Can't write attachment \"%s\"", title), e); } return new Attachment(); }
[ "public", "static", "Attachment", "writeAttachmentWithErrorMessage", "(", "Throwable", "throwable", ",", "String", "title", ")", "{", "String", "message", "=", "throwable", ".", "getMessage", "(", ")", ";", "try", "{", "return", "writeAttachment", "(", "message", ".", "getBytes", "(", "CONFIG", ".", "getAttachmentsEncoding", "(", ")", ")", ",", "title", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "addSuppressed", "(", "throwable", ")", ";", "LOGGER", ".", "error", "(", "String", ".", "format", "(", "\"Can't write attachment \\\"%s\\\"\"", ",", "title", ")", ",", "e", ")", ";", "}", "return", "new", "Attachment", "(", ")", ";", "}" ]
Write throwable as attachment. @param throwable to write @param title title of attachment @return Created {@link ru.yandex.qatools.allure.model.Attachment}
[ "Write", "throwable", "as", "attachment", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AllureResultsUtils.java#L243-L252
159,592
allure-framework/allure1
allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AllureResultsUtils.java
AllureResultsUtils.getExtensionByMimeType
public static String getExtensionByMimeType(String type) { MimeTypes types = getDefaultMimeTypes(); try { return types.forName(type).getExtension(); } catch (Exception e) { LOGGER.warn("Can't detect extension for MIME-type " + type, e); return ""; } }
java
public static String getExtensionByMimeType(String type) { MimeTypes types = getDefaultMimeTypes(); try { return types.forName(type).getExtension(); } catch (Exception e) { LOGGER.warn("Can't detect extension for MIME-type " + type, e); return ""; } }
[ "public", "static", "String", "getExtensionByMimeType", "(", "String", "type", ")", "{", "MimeTypes", "types", "=", "getDefaultMimeTypes", "(", ")", ";", "try", "{", "return", "types", ".", "forName", "(", "type", ")", ".", "getExtension", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "warn", "(", "\"Can't detect extension for MIME-type \"", "+", "type", ",", "e", ")", ";", "return", "\"\"", ";", "}", "}" ]
Generate attachment extension from mime type @param type valid mime-type @return extension if it's known for specified mime-type, or empty string otherwise
[ "Generate", "attachment", "extension", "from", "mime", "type" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/utils/AllureResultsUtils.java#L311-L319
159,593
allure-framework/allure1
allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/events/AddParameterEvent.java
AddParameterEvent.process
@Override public void process(TestCaseResult context) { context.getParameters().add(new Parameter() .withName(getName()) .withValue(getValue()) .withKind(ParameterKind.valueOf(getKind())) ); }
java
@Override public void process(TestCaseResult context) { context.getParameters().add(new Parameter() .withName(getName()) .withValue(getValue()) .withKind(ParameterKind.valueOf(getKind())) ); }
[ "@", "Override", "public", "void", "process", "(", "TestCaseResult", "context", ")", "{", "context", ".", "getParameters", "(", ")", ".", "add", "(", "new", "Parameter", "(", ")", ".", "withName", "(", "getName", "(", ")", ")", ".", "withValue", "(", "getValue", "(", ")", ")", ".", "withKind", "(", "ParameterKind", ".", "valueOf", "(", "getKind", "(", ")", ")", ")", ")", ";", "}" ]
Add parameter to testCase @param context which can be changed
[ "Add", "parameter", "to", "testCase" ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-java-adaptor-api/src/main/java/ru/yandex/qatools/allure/events/AddParameterEvent.java#L46-L53
159,594
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java
ReportGenerate.validateResultsDirectories
protected void validateResultsDirectories() { for (String result : results) { if (Files.notExists(Paths.get(result))) { throw new AllureCommandException(String.format("Report directory <%s> not found.", result)); } } }
java
protected void validateResultsDirectories() { for (String result : results) { if (Files.notExists(Paths.get(result))) { throw new AllureCommandException(String.format("Report directory <%s> not found.", result)); } } }
[ "protected", "void", "validateResultsDirectories", "(", ")", "{", "for", "(", "String", "result", ":", "results", ")", "{", "if", "(", "Files", ".", "notExists", "(", "Paths", ".", "get", "(", "result", ")", ")", ")", "{", "throw", "new", "AllureCommandException", "(", "String", ".", "format", "(", "\"Report directory <%s> not found.\"", ",", "result", ")", ")", ";", "}", "}", "}" ]
Throws an exception if at least one results directory is missing.
[ "Throws", "an", "exception", "if", "at", "least", "one", "results", "directory", "is", "missing", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java#L56-L62
159,595
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java
ReportGenerate.getClasspath
protected String getClasspath() throws IOException { List<String> classpath = new ArrayList<>(); classpath.add(getBundleJarPath()); classpath.addAll(getPluginsPath()); return StringUtils.toString(classpath.toArray(new String[classpath.size()]), " "); }
java
protected String getClasspath() throws IOException { List<String> classpath = new ArrayList<>(); classpath.add(getBundleJarPath()); classpath.addAll(getPluginsPath()); return StringUtils.toString(classpath.toArray(new String[classpath.size()]), " "); }
[ "protected", "String", "getClasspath", "(", ")", "throws", "IOException", "{", "List", "<", "String", ">", "classpath", "=", "new", "ArrayList", "<>", "(", ")", ";", "classpath", ".", "add", "(", "getBundleJarPath", "(", ")", ")", ";", "classpath", ".", "addAll", "(", "getPluginsPath", "(", ")", ")", ";", "return", "StringUtils", ".", "toString", "(", "classpath", ".", "toArray", "(", "new", "String", "[", "classpath", ".", "size", "(", ")", "]", ")", ",", "\" \"", ")", ";", "}" ]
Returns the classpath for executable jar.
[ "Returns", "the", "classpath", "for", "executable", "jar", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java#L80-L85
159,596
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java
ReportGenerate.getExecutableJar
protected String getExecutableJar() throws IOException { Manifest manifest = new Manifest(); manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, MAIN); manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, getClasspath()); Path jar = createTempDirectory("exec").resolve("generate.jar"); try (JarOutputStream output = new JarOutputStream(Files.newOutputStream(jar), manifest)) { output.putNextEntry(new JarEntry("allure.properties")); Path allureConfig = PROPERTIES.getAllureConfig(); if (Files.exists(allureConfig)) { byte[] bytes = Files.readAllBytes(allureConfig); output.write(bytes); } output.closeEntry(); } return jar.toAbsolutePath().toString(); }
java
protected String getExecutableJar() throws IOException { Manifest manifest = new Manifest(); manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, MAIN); manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, getClasspath()); Path jar = createTempDirectory("exec").resolve("generate.jar"); try (JarOutputStream output = new JarOutputStream(Files.newOutputStream(jar), manifest)) { output.putNextEntry(new JarEntry("allure.properties")); Path allureConfig = PROPERTIES.getAllureConfig(); if (Files.exists(allureConfig)) { byte[] bytes = Files.readAllBytes(allureConfig); output.write(bytes); } output.closeEntry(); } return jar.toAbsolutePath().toString(); }
[ "protected", "String", "getExecutableJar", "(", ")", "throws", "IOException", "{", "Manifest", "manifest", "=", "new", "Manifest", "(", ")", ";", "manifest", ".", "getMainAttributes", "(", ")", ".", "put", "(", "Attributes", ".", "Name", ".", "MANIFEST_VERSION", ",", "\"1.0\"", ")", ";", "manifest", ".", "getMainAttributes", "(", ")", ".", "put", "(", "Attributes", ".", "Name", ".", "MAIN_CLASS", ",", "MAIN", ")", ";", "manifest", ".", "getMainAttributes", "(", ")", ".", "put", "(", "Attributes", ".", "Name", ".", "CLASS_PATH", ",", "getClasspath", "(", ")", ")", ";", "Path", "jar", "=", "createTempDirectory", "(", "\"exec\"", ")", ".", "resolve", "(", "\"generate.jar\"", ")", ";", "try", "(", "JarOutputStream", "output", "=", "new", "JarOutputStream", "(", "Files", ".", "newOutputStream", "(", "jar", ")", ",", "manifest", ")", ")", "{", "output", ".", "putNextEntry", "(", "new", "JarEntry", "(", "\"allure.properties\"", ")", ")", ";", "Path", "allureConfig", "=", "PROPERTIES", ".", "getAllureConfig", "(", ")", ";", "if", "(", "Files", ".", "exists", "(", "allureConfig", ")", ")", "{", "byte", "[", "]", "bytes", "=", "Files", ".", "readAllBytes", "(", "allureConfig", ")", ";", "output", ".", "write", "(", "bytes", ")", ";", "}", "output", ".", "closeEntry", "(", ")", ";", "}", "return", "jar", ".", "toAbsolutePath", "(", ")", ".", "toString", "(", ")", ";", "}" ]
Create an executable jar to generate the report. Created jar contains only allure configuration file.
[ "Create", "an", "executable", "jar", "to", "generate", "the", "report", ".", "Created", "jar", "contains", "only", "allure", "configuration", "file", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java#L91-L109
159,597
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java
ReportGenerate.getBundleJarPath
protected String getBundleJarPath() throws MalformedURLException { Path path = PROPERTIES.getAllureHome().resolve("app/allure-bundle.jar").toAbsolutePath(); if (Files.notExists(path)) { throw new AllureCommandException(String.format("Bundle not found by path <%s>", path)); } return path.toUri().toURL().toString(); }
java
protected String getBundleJarPath() throws MalformedURLException { Path path = PROPERTIES.getAllureHome().resolve("app/allure-bundle.jar").toAbsolutePath(); if (Files.notExists(path)) { throw new AllureCommandException(String.format("Bundle not found by path <%s>", path)); } return path.toUri().toURL().toString(); }
[ "protected", "String", "getBundleJarPath", "(", ")", "throws", "MalformedURLException", "{", "Path", "path", "=", "PROPERTIES", ".", "getAllureHome", "(", ")", ".", "resolve", "(", "\"app/allure-bundle.jar\"", ")", ".", "toAbsolutePath", "(", ")", ";", "if", "(", "Files", ".", "notExists", "(", "path", ")", ")", "{", "throw", "new", "AllureCommandException", "(", "String", ".", "format", "(", "\"Bundle not found by path <%s>\"", ",", "path", ")", ")", ";", "}", "return", "path", ".", "toUri", "(", ")", ".", "toURL", "(", ")", ".", "toString", "(", ")", ";", "}" ]
Returns the bundle jar classpath element.
[ "Returns", "the", "bundle", "jar", "classpath", "element", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java#L114-L120
159,598
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java
ReportGenerate.getPluginsPath
protected List<String> getPluginsPath() throws IOException { List<String> result = new ArrayList<>(); Path pluginsDirectory = PROPERTIES.getAllureHome().resolve("plugins").toAbsolutePath(); if (Files.notExists(pluginsDirectory)) { return Collections.emptyList(); } try (DirectoryStream<Path> plugins = Files.newDirectoryStream(pluginsDirectory, JAR_FILES)) { for (Path plugin : plugins) { result.add(plugin.toUri().toURL().toString()); } } return result; }
java
protected List<String> getPluginsPath() throws IOException { List<String> result = new ArrayList<>(); Path pluginsDirectory = PROPERTIES.getAllureHome().resolve("plugins").toAbsolutePath(); if (Files.notExists(pluginsDirectory)) { return Collections.emptyList(); } try (DirectoryStream<Path> plugins = Files.newDirectoryStream(pluginsDirectory, JAR_FILES)) { for (Path plugin : plugins) { result.add(plugin.toUri().toURL().toString()); } } return result; }
[ "protected", "List", "<", "String", ">", "getPluginsPath", "(", ")", "throws", "IOException", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "Path", "pluginsDirectory", "=", "PROPERTIES", ".", "getAllureHome", "(", ")", ".", "resolve", "(", "\"plugins\"", ")", ".", "toAbsolutePath", "(", ")", ";", "if", "(", "Files", ".", "notExists", "(", "pluginsDirectory", ")", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "try", "(", "DirectoryStream", "<", "Path", ">", "plugins", "=", "Files", ".", "newDirectoryStream", "(", "pluginsDirectory", ",", "JAR_FILES", ")", ")", "{", "for", "(", "Path", "plugin", ":", "plugins", ")", "{", "result", ".", "add", "(", "plugin", ".", "toUri", "(", ")", ".", "toURL", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Returns the plugins classpath elements.
[ "Returns", "the", "plugins", "classpath", "elements", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java#L125-L138
159,599
allure-framework/allure1
allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java
ReportGenerate.getJavaExecutablePath
protected String getJavaExecutablePath() { String executableName = isWindows() ? "bin/java.exe" : "bin/java"; return PROPERTIES.getJavaHome().resolve(executableName).toAbsolutePath().toString(); }
java
protected String getJavaExecutablePath() { String executableName = isWindows() ? "bin/java.exe" : "bin/java"; return PROPERTIES.getJavaHome().resolve(executableName).toAbsolutePath().toString(); }
[ "protected", "String", "getJavaExecutablePath", "(", ")", "{", "String", "executableName", "=", "isWindows", "(", ")", "?", "\"bin/java.exe\"", ":", "\"bin/java\"", ";", "return", "PROPERTIES", ".", "getJavaHome", "(", ")", ".", "resolve", "(", "executableName", ")", ".", "toAbsolutePath", "(", ")", ".", "toString", "(", ")", ";", "}" ]
Returns the path to java executable.
[ "Returns", "the", "path", "to", "java", "executable", "." ]
9a816fa05d8b894a917b7ebb7fd1a4056dee4693
https://github.com/allure-framework/allure1/blob/9a816fa05d8b894a917b7ebb7fd1a4056dee4693/allure-commandline/src/main/java/ru/yandex/qatools/allure/command/ReportGenerate.java#L158-L161