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
partition
stringclasses
1 value
javabits/yar
yar-guice/src/main/java/org/javabits/yar/guice/Reflections.java
Reflections.getRawType
@SuppressWarnings("unckecked") public static Class<?> getRawType(Type type) { if (type instanceof Class<?>) { // type is a normal class. return (Class<?>) type; } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; // I'm not exactly sure why getRawType() returns Type instead of Class. // Neal isn't either but suspects some pathological case related // to nested classes exists. Type rawType = parameterizedType.getRawType(); checkArgument(rawType instanceof Class, "Expected a Class, but <%s> is of type %s", type, type.getClass().getName()); //noinspection ConstantConditions return (Class<?>) rawType; } else if (type instanceof GenericArrayType) { Type componentType = ((GenericArrayType) type).getGenericComponentType(); return Array.newInstance(getRawType(componentType), 0).getClass(); } else if (type instanceof TypeVariable) { // we could use the variable's bounds, but that'll won't work if there are multiple. // having a raw type that's more general than necessary is okay return Object.class; } else { throw new IllegalArgumentException("Expected a Class, ParameterizedType, or " + "GenericArrayType, but <" + type + "> is of type " + type.getClass().getName()); } }
java
@SuppressWarnings("unckecked") public static Class<?> getRawType(Type type) { if (type instanceof Class<?>) { // type is a normal class. return (Class<?>) type; } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; // I'm not exactly sure why getRawType() returns Type instead of Class. // Neal isn't either but suspects some pathological case related // to nested classes exists. Type rawType = parameterizedType.getRawType(); checkArgument(rawType instanceof Class, "Expected a Class, but <%s> is of type %s", type, type.getClass().getName()); //noinspection ConstantConditions return (Class<?>) rawType; } else if (type instanceof GenericArrayType) { Type componentType = ((GenericArrayType) type).getGenericComponentType(); return Array.newInstance(getRawType(componentType), 0).getClass(); } else if (type instanceof TypeVariable) { // we could use the variable's bounds, but that'll won't work if there are multiple. // having a raw type that's more general than necessary is okay return Object.class; } else { throw new IllegalArgumentException("Expected a Class, ParameterizedType, or " + "GenericArrayType, but <" + type + "> is of type " + type.getClass().getName()); } }
[ "@", "SuppressWarnings", "(", "\"unckecked\"", ")", "public", "static", "Class", "<", "?", ">", "getRawType", "(", "Type", "type", ")", "{", "if", "(", "type", "instanceof", "Class", "<", "?", ">", ")", "{", "// type is a normal class.", "return", "(", "Cl...
Copy paste from Guice MoreTypes
[ "Copy", "paste", "from", "Guice", "MoreTypes" ]
e146a86611ca4831e8334c9a98fd7086cee9c03e
https://github.com/javabits/yar/blob/e146a86611ca4831e8334c9a98fd7086cee9c03e/yar-guice/src/main/java/org/javabits/yar/guice/Reflections.java#L62-L93
train
labai/ted
ted-driver/src/main/java/ted/driver/sys/TedDaoPostgres.java
TedDaoPostgres.eventQueueReserveTask
public TaskRec eventQueueReserveTask(long taskId) { String sqlLogId = "reserve_task"; String sql = "update tedtask set status = 'WORK', startTs = $now, nextTs = null" + " where status in ('NEW','RETRY') and system = '$sys'" + " and taskid in (" + " select taskid from tedtask " + " where status in ('NEW','RETRY') and system = '$sys'" + " and taskid = ?" + " for update skip locked" + ") returning tedtask.*" ; sql = sql.replace("$now", dbType.sql.now()); sql = sql.replace("$sys", thisSystem); List<TaskRec> tasks = selectData(sqlLogId, sql, TaskRec.class, asList( sqlParam(taskId, JetJdbcParamType.LONG) )); return tasks.isEmpty() ? null : tasks.get(0); }
java
public TaskRec eventQueueReserveTask(long taskId) { String sqlLogId = "reserve_task"; String sql = "update tedtask set status = 'WORK', startTs = $now, nextTs = null" + " where status in ('NEW','RETRY') and system = '$sys'" + " and taskid in (" + " select taskid from tedtask " + " where status in ('NEW','RETRY') and system = '$sys'" + " and taskid = ?" + " for update skip locked" + ") returning tedtask.*" ; sql = sql.replace("$now", dbType.sql.now()); sql = sql.replace("$sys", thisSystem); List<TaskRec> tasks = selectData(sqlLogId, sql, TaskRec.class, asList( sqlParam(taskId, JetJdbcParamType.LONG) )); return tasks.isEmpty() ? null : tasks.get(0); }
[ "public", "TaskRec", "eventQueueReserveTask", "(", "long", "taskId", ")", "{", "String", "sqlLogId", "=", "\"reserve_task\"", ";", "String", "sql", "=", "\"update tedtask set status = 'WORK', startTs = $now, nextTs = null\"", "+", "\" where status in ('NEW','RETRY') and system = ...
used in eventQueue
[ "used", "in", "eventQueue" ]
2ee197246a78d842c18d6780c48fd903b00608a6
https://github.com/labai/ted/blob/2ee197246a78d842c18d6780c48fd903b00608a6/ted-driver/src/main/java/ted/driver/sys/TedDaoPostgres.java#L131-L148
train
eFaps/eFaps-Kernel
src/main/java/org/efaps/admin/ui/field/Field.java
Field.initialize
public static void initialize() { if (InfinispanCache.get().exists(Field.IDCACHE)) { InfinispanCache.get().<Long, Field>getCache(Field.IDCACHE).clear(); } else { InfinispanCache.get().<Long, Field>getCache(Field.IDCACHE); InfinispanCache.get().<Long, Field>getCache(Field.IDCACHE).addListener(new CacheLogListener(Field.LOG)); } }
java
public static void initialize() { if (InfinispanCache.get().exists(Field.IDCACHE)) { InfinispanCache.get().<Long, Field>getCache(Field.IDCACHE).clear(); } else { InfinispanCache.get().<Long, Field>getCache(Field.IDCACHE); InfinispanCache.get().<Long, Field>getCache(Field.IDCACHE).addListener(new CacheLogListener(Field.LOG)); } }
[ "public", "static", "void", "initialize", "(", ")", "{", "if", "(", "InfinispanCache", ".", "get", "(", ")", ".", "exists", "(", "Field", ".", "IDCACHE", ")", ")", "{", "InfinispanCache", ".", "get", "(", ")", ".", "<", "Long", ",", "Field", ">", "...
Reset the cache.
[ "Reset", "the", "cache", "." ]
04b96548f518c2386a93f5ec2b9349f9b9063859
https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/ui/field/Field.java#L761-L769
train
navnorth/LRJavaLib
src/com/navnorth/learningregistry/LRExporter.java
LRExporter.configure
public void configure() throws LRException { // Trim or nullify strings nodeHost = StringUtil.nullifyBadInput(nodeHost); publishAuthUser = StringUtil.nullifyBadInput(publishAuthUser); publishAuthPassword = StringUtil.nullifyBadInput(publishAuthPassword); // Throw an exception if any of the required fields are null if (nodeHost == null) { throw new LRException(LRException.NULL_FIELD); } // Throw an error if the batch size is zero if (batchSize == 0) { throw new LRException(LRException.BATCH_ZERO); } this.batchSize = batchSize; this.publishFullUrl = publishProtocol + "://" + nodeHost + publishServiceUrl; this.publishAuthUser = publishAuthUser; this.publishAuthPassword = publishAuthPassword; this.configured = true; }
java
public void configure() throws LRException { // Trim or nullify strings nodeHost = StringUtil.nullifyBadInput(nodeHost); publishAuthUser = StringUtil.nullifyBadInput(publishAuthUser); publishAuthPassword = StringUtil.nullifyBadInput(publishAuthPassword); // Throw an exception if any of the required fields are null if (nodeHost == null) { throw new LRException(LRException.NULL_FIELD); } // Throw an error if the batch size is zero if (batchSize == 0) { throw new LRException(LRException.BATCH_ZERO); } this.batchSize = batchSize; this.publishFullUrl = publishProtocol + "://" + nodeHost + publishServiceUrl; this.publishAuthUser = publishAuthUser; this.publishAuthPassword = publishAuthPassword; this.configured = true; }
[ "public", "void", "configure", "(", ")", "throws", "LRException", "{", "// Trim or nullify strings", "nodeHost", "=", "StringUtil", ".", "nullifyBadInput", "(", "nodeHost", ")", ";", "publishAuthUser", "=", "StringUtil", ".", "nullifyBadInput", "(", "publishAuthUser",...
Attempt to configure the exporter with the values used in the constructor This must be called before an exporter can be used and after any setting of configuration values @throws LRException
[ "Attempt", "to", "configure", "the", "exporter", "with", "the", "values", "used", "in", "the", "constructor", "This", "must", "be", "called", "before", "an", "exporter", "can", "be", "used", "and", "after", "any", "setting", "of", "configuration", "values" ]
27af28b9f80d772273592414e7d0dccffaac09e1
https://github.com/navnorth/LRJavaLib/blob/27af28b9f80d772273592414e7d0dccffaac09e1/src/com/navnorth/learningregistry/LRExporter.java#L161-L186
train
navnorth/LRJavaLib
src/com/navnorth/learningregistry/LRExporter.java
LRExporter.addDocument
public void addDocument(LREnvelope envelope) throws LRException { if(!configured) { throw new LRException(LRException.NOT_CONFIGURED); } docs.add(envelope.getSendableData()); }
java
public void addDocument(LREnvelope envelope) throws LRException { if(!configured) { throw new LRException(LRException.NOT_CONFIGURED); } docs.add(envelope.getSendableData()); }
[ "public", "void", "addDocument", "(", "LREnvelope", "envelope", ")", "throws", "LRException", "{", "if", "(", "!", "configured", ")", "{", "throw", "new", "LRException", "(", "LRException", ".", "NOT_CONFIGURED", ")", ";", "}", "docs", ".", "add", "(", "en...
Adds an envelope to the exporter @param envelope envelope to add to the exporter @throws LRException NOT_CONFIGURED
[ "Adds", "an", "envelope", "to", "the", "exporter" ]
27af28b9f80d772273592414e7d0dccffaac09e1
https://github.com/navnorth/LRJavaLib/blob/27af28b9f80d772273592414e7d0dccffaac09e1/src/com/navnorth/learningregistry/LRExporter.java#L194-L202
train
Teddy-Zhu/SilentGo
framework/src/main/java/com/silentgo/servlet/http/Request.java
Request.forward
public void forward(String controllerName) throws Throwable { SilentGo instance = SilentGo.me(); ((ActionChain) instance.getConfig().getActionChain().getObject()).doAction(instance.getConfig().getCtx().get().getActionParam()); }
java
public void forward(String controllerName) throws Throwable { SilentGo instance = SilentGo.me(); ((ActionChain) instance.getConfig().getActionChain().getObject()).doAction(instance.getConfig().getCtx().get().getActionParam()); }
[ "public", "void", "forward", "(", "String", "controllerName", ")", "throws", "Throwable", "{", "SilentGo", "instance", "=", "SilentGo", ".", "me", "(", ")", ";", "(", "(", "ActionChain", ")", "instance", ".", "getConfig", "(", ")", ".", "getActionChain", "...
forward to another controller @param controllerName @throws Throwable
[ "forward", "to", "another", "controller" ]
27f58b0cafe56b2eb9fc6993efa9ca2b529661e1
https://github.com/Teddy-Zhu/SilentGo/blob/27f58b0cafe56b2eb9fc6993efa9ca2b529661e1/framework/src/main/java/com/silentgo/servlet/http/Request.java#L101-L104
train
FlyingHe/UtilsMaven
src/main/java/com/github/flyinghe/depdcy/XSSFSheetXMLHandlerPlus.java
XSSFSheetXMLHandlerPlus.characters
@Override public void characters(char[] ch, int start, int length) throws SAXException { if (vIsOpen) { value.append(ch, start, length); } if (fIsOpen) { formula.append(ch, start, length); } if (hfIsOpen) { headerFooter.append(ch, start, length); } }
java
@Override public void characters(char[] ch, int start, int length) throws SAXException { if (vIsOpen) { value.append(ch, start, length); } if (fIsOpen) { formula.append(ch, start, length); } if (hfIsOpen) { headerFooter.append(ch, start, length); } }
[ "@", "Override", "public", "void", "characters", "(", "char", "[", "]", "ch", ",", "int", "start", ",", "int", "length", ")", "throws", "SAXException", "{", "if", "(", "vIsOpen", ")", "{", "value", ".", "append", "(", "ch", ",", "start", ",", "length...
Captures characters only if a suitable element is open. Originally was just "v"; extended for inlineStr also.
[ "Captures", "characters", "only", "if", "a", "suitable", "element", "is", "open", ".", "Originally", "was", "just", "v", ";", "extended", "for", "inlineStr", "also", "." ]
d9605b7bfe0c28a05289252e12d163e114080b4a
https://github.com/FlyingHe/UtilsMaven/blob/d9605b7bfe0c28a05289252e12d163e114080b4a/src/main/java/com/github/flyinghe/depdcy/XSSFSheetXMLHandlerPlus.java#L446-L458
train
FlyingHe/UtilsMaven
src/main/java/com/github/flyinghe/depdcy/XSSFSheetXMLHandlerPlus.java
XSSFSheetXMLHandlerPlus.checkForEmptyCellComments
private void checkForEmptyCellComments(XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType type) { if (commentCellRefs != null && !commentCellRefs.isEmpty()) { // If we've reached the end of the sheet data, output any // comments we haven't yet already handled if (type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.END_OF_SHEET_DATA) { while (!commentCellRefs.isEmpty()) { outputEmptyCellComment(commentCellRefs.remove()); } return; } // At the end of a row, handle any comments for "missing" rows before us if (this.cellRef == null) { if (type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.END_OF_ROW) { while (!commentCellRefs.isEmpty()) { if (commentCellRefs.peek().getRow() == rowNum) { outputEmptyCellComment(commentCellRefs.remove()); } else { return; } } return; } else { throw new IllegalStateException( "Cell ref should be null only if there are only empty cells in the row; rowNum: " + rowNum); } } CellAddress nextCommentCellRef; do { CellAddress cellRef = new CellAddress(this.cellRef); CellAddress peekCellRef = commentCellRefs.peek(); if (type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.CELL && cellRef.equals(peekCellRef)) { // remove the comment cell ref from the list if we're about to handle it alongside the cell content commentCellRefs.remove(); return; } else { // fill in any gaps if there are empty cells with comment mixed in with non-empty cells int comparison = peekCellRef.compareTo(cellRef); if (comparison > 0 && type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.END_OF_ROW && peekCellRef.getRow() <= rowNum) { nextCommentCellRef = commentCellRefs.remove(); outputEmptyCellComment(nextCommentCellRef); } else if (comparison < 0 && type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.CELL && peekCellRef.getRow() <= rowNum) { nextCommentCellRef = commentCellRefs.remove(); outputEmptyCellComment(nextCommentCellRef); } else { nextCommentCellRef = null; } } } while (nextCommentCellRef != null && !commentCellRefs.isEmpty()); } }
java
private void checkForEmptyCellComments(XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType type) { if (commentCellRefs != null && !commentCellRefs.isEmpty()) { // If we've reached the end of the sheet data, output any // comments we haven't yet already handled if (type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.END_OF_SHEET_DATA) { while (!commentCellRefs.isEmpty()) { outputEmptyCellComment(commentCellRefs.remove()); } return; } // At the end of a row, handle any comments for "missing" rows before us if (this.cellRef == null) { if (type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.END_OF_ROW) { while (!commentCellRefs.isEmpty()) { if (commentCellRefs.peek().getRow() == rowNum) { outputEmptyCellComment(commentCellRefs.remove()); } else { return; } } return; } else { throw new IllegalStateException( "Cell ref should be null only if there are only empty cells in the row; rowNum: " + rowNum); } } CellAddress nextCommentCellRef; do { CellAddress cellRef = new CellAddress(this.cellRef); CellAddress peekCellRef = commentCellRefs.peek(); if (type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.CELL && cellRef.equals(peekCellRef)) { // remove the comment cell ref from the list if we're about to handle it alongside the cell content commentCellRefs.remove(); return; } else { // fill in any gaps if there are empty cells with comment mixed in with non-empty cells int comparison = peekCellRef.compareTo(cellRef); if (comparison > 0 && type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.END_OF_ROW && peekCellRef.getRow() <= rowNum) { nextCommentCellRef = commentCellRefs.remove(); outputEmptyCellComment(nextCommentCellRef); } else if (comparison < 0 && type == XSSFSheetXMLHandlerPlus.EmptyCellCommentsCheckType.CELL && peekCellRef.getRow() <= rowNum) { nextCommentCellRef = commentCellRefs.remove(); outputEmptyCellComment(nextCommentCellRef); } else { nextCommentCellRef = null; } } } while (nextCommentCellRef != null && !commentCellRefs.isEmpty()); } }
[ "private", "void", "checkForEmptyCellComments", "(", "XSSFSheetXMLHandlerPlus", ".", "EmptyCellCommentsCheckType", "type", ")", "{", "if", "(", "commentCellRefs", "!=", "null", "&&", "!", "commentCellRefs", ".", "isEmpty", "(", ")", ")", "{", "// If we've reached the ...
Do a check for, and output, comments in otherwise empty cells.
[ "Do", "a", "check", "for", "and", "output", "comments", "in", "otherwise", "empty", "cells", "." ]
d9605b7bfe0c28a05289252e12d163e114080b4a
https://github.com/FlyingHe/UtilsMaven/blob/d9605b7bfe0c28a05289252e12d163e114080b4a/src/main/java/com/github/flyinghe/depdcy/XSSFSheetXMLHandlerPlus.java#L463-L516
train
FlyingHe/UtilsMaven
src/main/java/com/github/flyinghe/depdcy/XSSFSheetXMLHandlerPlus.java
XSSFSheetXMLHandlerPlus.outputEmptyCellComment
private void outputEmptyCellComment(CellAddress cellRef) { XSSFComment comment = commentsTable.findCellComment(cellRef); output.cell(cellRef.formatAsString(), null, comment); }
java
private void outputEmptyCellComment(CellAddress cellRef) { XSSFComment comment = commentsTable.findCellComment(cellRef); output.cell(cellRef.formatAsString(), null, comment); }
[ "private", "void", "outputEmptyCellComment", "(", "CellAddress", "cellRef", ")", "{", "XSSFComment", "comment", "=", "commentsTable", ".", "findCellComment", "(", "cellRef", ")", ";", "output", ".", "cell", "(", "cellRef", ".", "formatAsString", "(", ")", ",", ...
Output an empty-cell comment.
[ "Output", "an", "empty", "-", "cell", "comment", "." ]
d9605b7bfe0c28a05289252e12d163e114080b4a
https://github.com/FlyingHe/UtilsMaven/blob/d9605b7bfe0c28a05289252e12d163e114080b4a/src/main/java/com/github/flyinghe/depdcy/XSSFSheetXMLHandlerPlus.java#L522-L525
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.format
public String format(GeometryIndex index) { if (index.hasChild()) { return "geometry" + index.getValue() + "." + format(index.getChild()); } switch (index.getType()) { case TYPE_VERTEX: return "vertex" + index.getValue(); case TYPE_EDGE: return "edge" + index.getValue(); default: return "geometry" + index.getValue(); } }
java
public String format(GeometryIndex index) { if (index.hasChild()) { return "geometry" + index.getValue() + "." + format(index.getChild()); } switch (index.getType()) { case TYPE_VERTEX: return "vertex" + index.getValue(); case TYPE_EDGE: return "edge" + index.getValue(); default: return "geometry" + index.getValue(); } }
[ "public", "String", "format", "(", "GeometryIndex", "index", ")", "{", "if", "(", "index", ".", "hasChild", "(", ")", ")", "{", "return", "\"geometry\"", "+", "index", ".", "getValue", "(", ")", "+", "\".\"", "+", "format", "(", "index", ".", "getChild...
Format a given geometry index, creating something like "geometry2.vertex1". @param index The geometry index to format. @return Returns the string value resulting from the index.
[ "Format", "a", "given", "geometry", "index", "creating", "something", "like", "geometry2", ".", "vertex1", "." ]
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L99-L111
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.getVertex
public Coordinate getVertex(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException { if (index.hasChild()) { if (geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) { return getVertex(geometry.getGeometries()[index.getValue()], index.getChild()); } throw new GeometryIndexNotFoundException("Could not match index with given geometry"); } if (index.getType() == GeometryIndexType.TYPE_VERTEX && geometry.getCoordinates() != null && geometry.getCoordinates().length > index.getValue() && index.getValue() >= 0) { return geometry.getCoordinates()[index.getValue()]; } throw new GeometryIndexNotFoundException("Could not match index with given geometry"); }
java
public Coordinate getVertex(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException { if (index.hasChild()) { if (geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) { return getVertex(geometry.getGeometries()[index.getValue()], index.getChild()); } throw new GeometryIndexNotFoundException("Could not match index with given geometry"); } if (index.getType() == GeometryIndexType.TYPE_VERTEX && geometry.getCoordinates() != null && geometry.getCoordinates().length > index.getValue() && index.getValue() >= 0) { return geometry.getCoordinates()[index.getValue()]; } throw new GeometryIndexNotFoundException("Could not match index with given geometry"); }
[ "public", "Coordinate", "getVertex", "(", "Geometry", "geometry", ",", "GeometryIndex", "index", ")", "throws", "GeometryIndexNotFoundException", "{", "if", "(", "index", ".", "hasChild", "(", ")", ")", "{", "if", "(", "geometry", ".", "getGeometries", "(", ")...
Given a certain geometry, get the vertex the index points to. This only works if the index actually points to a vertex. @param geometry The geometry to search in. @param index The index that points to a vertex within the given geometry. @return Returns the vertex if it exists. @throws GeometryIndexNotFoundException Thrown in case the index is of the wrong type, or if the vertex could not be found within the given geometry.
[ "Given", "a", "certain", "geometry", "get", "the", "vertex", "the", "index", "points", "to", ".", "This", "only", "works", "if", "the", "index", "actually", "points", "to", "a", "vertex", "." ]
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L190-L202
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.isVertex
public boolean isVertex(GeometryIndex index) { if (index.hasChild()) { return isVertex(index.getChild()); } return index.getType() == GeometryIndexType.TYPE_VERTEX; }
java
public boolean isVertex(GeometryIndex index) { if (index.hasChild()) { return isVertex(index.getChild()); } return index.getType() == GeometryIndexType.TYPE_VERTEX; }
[ "public", "boolean", "isVertex", "(", "GeometryIndex", "index", ")", "{", "if", "(", "index", ".", "hasChild", "(", ")", ")", "{", "return", "isVertex", "(", "index", ".", "getChild", "(", ")", ")", ";", "}", "return", "index", ".", "getType", "(", "...
Does the given index point to a vertex or not? We look at the deepest level to check this. @param index The index to check. @return true or false.
[ "Does", "the", "given", "index", "point", "to", "a", "vertex", "or", "not?", "We", "look", "at", "the", "deepest", "level", "to", "check", "this", "." ]
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L243-L248
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.isEdge
public boolean isEdge(GeometryIndex index) { if (index.hasChild()) { return isEdge(index.getChild()); } return index.getType() == GeometryIndexType.TYPE_EDGE; }
java
public boolean isEdge(GeometryIndex index) { if (index.hasChild()) { return isEdge(index.getChild()); } return index.getType() == GeometryIndexType.TYPE_EDGE; }
[ "public", "boolean", "isEdge", "(", "GeometryIndex", "index", ")", "{", "if", "(", "index", ".", "hasChild", "(", ")", ")", "{", "return", "isEdge", "(", "index", ".", "getChild", "(", ")", ")", ";", "}", "return", "index", ".", "getType", "(", ")", ...
Does the given index point to an edge or not? We look at the deepest level to check this. @param index The index to check. @return true or false.
[ "Does", "the", "given", "index", "point", "to", "an", "edge", "or", "not?", "We", "look", "at", "the", "deepest", "level", "to", "check", "this", "." ]
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L257-L262
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.isGeometry
public boolean isGeometry(GeometryIndex index) { if (index.hasChild()) { return isGeometry(index.getChild()); } return index.getType() == GeometryIndexType.TYPE_GEOMETRY; }
java
public boolean isGeometry(GeometryIndex index) { if (index.hasChild()) { return isGeometry(index.getChild()); } return index.getType() == GeometryIndexType.TYPE_GEOMETRY; }
[ "public", "boolean", "isGeometry", "(", "GeometryIndex", "index", ")", "{", "if", "(", "index", ".", "hasChild", "(", ")", ")", "{", "return", "isGeometry", "(", "index", ".", "getChild", "(", ")", ")", ";", "}", "return", "index", ".", "getType", "(",...
Does the given index point to a sub-geometry or not? We look at the deepest level to check this. @param index The index to check. @return true or false.
[ "Does", "the", "given", "index", "point", "to", "a", "sub", "-", "geometry", "or", "not?", "We", "look", "at", "the", "deepest", "level", "to", "check", "this", "." ]
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L271-L276
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.getType
public GeometryIndexType getType(GeometryIndex index) { if (index.hasChild()) { return getType(index.getChild()); } return index.getType(); }
java
public GeometryIndexType getType(GeometryIndex index) { if (index.hasChild()) { return getType(index.getChild()); } return index.getType(); }
[ "public", "GeometryIndexType", "getType", "(", "GeometryIndex", "index", ")", "{", "if", "(", "index", ".", "hasChild", "(", ")", ")", "{", "return", "getType", "(", "index", ".", "getChild", "(", ")", ")", ";", "}", "return", "index", ".", "getType", ...
Get the type of sub-part the given index points to. We look at the deepest level to check this. @param index The index to check. @return true or false.
[ "Get", "the", "type", "of", "sub", "-", "part", "the", "given", "index", "points", "to", ".", "We", "look", "at", "the", "deepest", "level", "to", "check", "this", "." ]
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L297-L302
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.getGeometryType
public String getGeometryType(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException { if (index != null && index.getType() == GeometryIndexType.TYPE_GEOMETRY) { if (geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) { return getGeometryType(geometry.getGeometries()[index.getValue()], index.getChild()); } else { throw new GeometryIndexNotFoundException("Can't find the geometry referred to in the given index."); } } return geometry.getGeometryType(); }
java
public String getGeometryType(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException { if (index != null && index.getType() == GeometryIndexType.TYPE_GEOMETRY) { if (geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) { return getGeometryType(geometry.getGeometries()[index.getValue()], index.getChild()); } else { throw new GeometryIndexNotFoundException("Can't find the geometry referred to in the given index."); } } return geometry.getGeometryType(); }
[ "public", "String", "getGeometryType", "(", "Geometry", "geometry", ",", "GeometryIndex", "index", ")", "throws", "GeometryIndexNotFoundException", "{", "if", "(", "index", "!=", "null", "&&", "index", ".", "getType", "(", ")", "==", "GeometryIndexType", ".", "T...
What is the geometry type of the sub-geometry pointed to by the given index? If the index points to a vertex or edge, the geometry type at the parent level is returned. @param geometry The geometry wherein to search. @param index The index pointing to a vertex/edge/sub-geometry. In the case of a vertex/edge, the parent geometry type is returned. If index is null, the type of the given geometry is returned. @return The geometry type as defined in the {@link Geometry} class. @throws GeometryIndexNotFoundException Thrown in case the index points to a non-existing sub-geometry.
[ "What", "is", "the", "geometry", "type", "of", "the", "sub", "-", "geometry", "pointed", "to", "by", "the", "given", "index?", "If", "the", "index", "points", "to", "a", "vertex", "or", "edge", "the", "geometry", "type", "at", "the", "parent", "level", ...
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L317-L326
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.getValue
public int getValue(GeometryIndex index) { if (index.hasChild()) { return getValue(index.getChild()); } return index.getValue(); }
java
public int getValue(GeometryIndex index) { if (index.hasChild()) { return getValue(index.getChild()); } return index.getValue(); }
[ "public", "int", "getValue", "(", "GeometryIndex", "index", ")", "{", "if", "(", "index", ".", "hasChild", "(", ")", ")", "{", "return", "getValue", "(", "index", ".", "getChild", "(", ")", ")", ";", "}", "return", "index", ".", "getValue", "(", ")",...
Returns the value of the innermost child index. @param index The index to recursively search. @return The value of the deepest child.
[ "Returns", "the", "value", "of", "the", "innermost", "child", "index", "." ]
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L356-L361
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.getParent
public GeometryIndex getParent(GeometryIndex index) { GeometryIndex parent = new GeometryIndex(index); GeometryIndex deepestParent = null; GeometryIndex p = parent; while (p.hasChild()) { deepestParent = p; p = p.getChild(); } if (deepestParent != null) { deepestParent.setChild(null); } return parent; }
java
public GeometryIndex getParent(GeometryIndex index) { GeometryIndex parent = new GeometryIndex(index); GeometryIndex deepestParent = null; GeometryIndex p = parent; while (p.hasChild()) { deepestParent = p; p = p.getChild(); } if (deepestParent != null) { deepestParent.setChild(null); } return parent; }
[ "public", "GeometryIndex", "getParent", "(", "GeometryIndex", "index", ")", "{", "GeometryIndex", "parent", "=", "new", "GeometryIndex", "(", "index", ")", ";", "GeometryIndex", "deepestParent", "=", "null", ";", "GeometryIndex", "p", "=", "parent", ";", "while"...
Returns a new index that is one level higher than this index. Useful to get the index of a ring for a vertex. @param index @return the parent index
[ "Returns", "a", "new", "index", "that", "is", "one", "level", "higher", "than", "this", "index", ".", "Useful", "to", "get", "the", "index", "of", "a", "ring", "for", "a", "vertex", "." ]
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L369-L381
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.getNextVertex
public GeometryIndex getNextVertex(GeometryIndex index) { if (index.hasChild()) { return new GeometryIndex(index.getType(), index.getValue(), getNextVertex(index.getChild())); } else { return new GeometryIndex(GeometryIndexType.TYPE_VERTEX, index.getValue() + 1, null); } }
java
public GeometryIndex getNextVertex(GeometryIndex index) { if (index.hasChild()) { return new GeometryIndex(index.getType(), index.getValue(), getNextVertex(index.getChild())); } else { return new GeometryIndex(GeometryIndexType.TYPE_VERTEX, index.getValue() + 1, null); } }
[ "public", "GeometryIndex", "getNextVertex", "(", "GeometryIndex", "index", ")", "{", "if", "(", "index", ".", "hasChild", "(", ")", ")", "{", "return", "new", "GeometryIndex", "(", "index", ".", "getType", "(", ")", ",", "index", ".", "getValue", "(", ")...
Given a certain index, find the next vertex in line. @param index The index to start out from. Must point to either a vertex or and edge. @return Returns the next vertex index. Note that no geometry is given, and so no actual checking is done. It just returns the theoretical answer.
[ "Given", "a", "certain", "index", "find", "the", "next", "vertex", "in", "line", "." ]
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L500-L506
train
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.getSiblingVertices
public Coordinate[] getSiblingVertices(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException { if (index.hasChild() && geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) { return getSiblingVertices(geometry.getGeometries()[index.getValue()], index.getChild()); } switch (index.getType()) { case TYPE_VERTEX: case TYPE_EDGE: return geometry.getCoordinates(); case TYPE_GEOMETRY: default: throw new GeometryIndexNotFoundException("Given index is of wrong type. Can't find sibling vertices " + "for a geometry type of index."); } }
java
public Coordinate[] getSiblingVertices(Geometry geometry, GeometryIndex index) throws GeometryIndexNotFoundException { if (index.hasChild() && geometry.getGeometries() != null && geometry.getGeometries().length > index.getValue()) { return getSiblingVertices(geometry.getGeometries()[index.getValue()], index.getChild()); } switch (index.getType()) { case TYPE_VERTEX: case TYPE_EDGE: return geometry.getCoordinates(); case TYPE_GEOMETRY: default: throw new GeometryIndexNotFoundException("Given index is of wrong type. Can't find sibling vertices " + "for a geometry type of index."); } }
[ "public", "Coordinate", "[", "]", "getSiblingVertices", "(", "Geometry", "geometry", ",", "GeometryIndex", "index", ")", "throws", "GeometryIndexNotFoundException", "{", "if", "(", "index", ".", "hasChild", "(", ")", "&&", "geometry", ".", "getGeometries", "(", ...
Get the full list of sibling vertices in the form of a coordinate array. @param geometry The geometry wherein to search for a certain coordinate array. @param index An index pointing to a vertex or edge within the geometry. This index will then naturally be a part of a coordinate array. It is this array we're looking for. @return Returns the array of coordinate from within the geometry where the given index is a part of. @throws GeometryIndexNotFoundException geometry index not found
[ "Get", "the", "full", "list", "of", "sibling", "vertices", "in", "the", "form", "of", "a", "coordinate", "array", "." ]
09a214fede69c9c01e41630828c4abbb551a557d
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L573-L588
train
passwordmaker/java-passwordmaker-lib
src/main/java/org/daveware/passwordmaker/LeetLevel.java
LeetLevel.fromString
public static LeetLevel fromString(String str) throws Exception { if (str == null || str.equalsIgnoreCase("null") || str.length() == 0) return LEVEL1; try { int i = Integer.parseInt(str); if (i >= 1 && i <= LEVELS.length) return LEVELS[i - 1]; } catch (Exception ignored) {} String exceptionStr = String.format("Invalid LeetLevel '%1s', valid values are '1' to '9'", str); throw new Exception(exceptionStr); }
java
public static LeetLevel fromString(String str) throws Exception { if (str == null || str.equalsIgnoreCase("null") || str.length() == 0) return LEVEL1; try { int i = Integer.parseInt(str); if (i >= 1 && i <= LEVELS.length) return LEVELS[i - 1]; } catch (Exception ignored) {} String exceptionStr = String.format("Invalid LeetLevel '%1s', valid values are '1' to '9'", str); throw new Exception(exceptionStr); }
[ "public", "static", "LeetLevel", "fromString", "(", "String", "str", ")", "throws", "Exception", "{", "if", "(", "str", "==", "null", "||", "str", ".", "equalsIgnoreCase", "(", "\"null\"", ")", "||", "str", ".", "length", "(", ")", "==", "0", ")", "ret...
Converts a string to a leet level. @param str The string to parse the leet level from. @return The leet level if valid. @throws Exception upon invalid level.
[ "Converts", "a", "string", "to", "a", "leet", "level", "." ]
18c22fca7dd9a47f08161425b85a5bd257afbb2b
https://github.com/passwordmaker/java-passwordmaker-lib/blob/18c22fca7dd9a47f08161425b85a5bd257afbb2b/src/main/java/org/daveware/passwordmaker/LeetLevel.java#L66-L79
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/LocalVariableTypeTable.java
LocalVariableTypeTable.addLocalTypeVariable
public void addLocalTypeVariable(VariableElement ve, String signature, int index) { localTypeVariables.add(new LocalTypeVariable(ve, signature, index)); }
java
public void addLocalTypeVariable(VariableElement ve, String signature, int index) { localTypeVariables.add(new LocalTypeVariable(ve, signature, index)); }
[ "public", "void", "addLocalTypeVariable", "(", "VariableElement", "ve", ",", "String", "signature", ",", "int", "index", ")", "{", "localTypeVariables", ".", "add", "(", "new", "LocalTypeVariable", "(", "ve", ",", "signature", ",", "index", ")", ")", ";", "}...
Adds a entry into LocalTypeVariableTable if variable is of generic type @param ve @param index
[ "Adds", "a", "entry", "into", "LocalTypeVariableTable", "if", "variable", "is", "of", "generic", "type" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/LocalVariableTypeTable.java#L61-L64
train
btaz/data-util
src/main/java/com/btaz/util/files/FileSplitter.java
FileSplitter.writePartToFile
private static File writePartToFile(File splitDir, List<String> data) { BufferedWriter writer = null; File splitFile; try { splitFile = File.createTempFile("split-", ".part", splitDir); writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(splitFile.getAbsoluteFile(), false), DataUtilDefaults.charSet)); for(String item : data) { writer.write(item + DataUtilDefaults.lineTerminator); } writer.flush(); writer.close(); writer = null; } catch (UnsupportedEncodingException e) { throw new DataUtilException(e); } catch (FileNotFoundException e) { throw new DataUtilException(e); } catch (IOException e) { throw new DataUtilException(e); } finally { if(writer != null) { try { writer.close(); } catch (IOException e) { // Intentionally we're doing nothing here } } } return splitFile; }
java
private static File writePartToFile(File splitDir, List<String> data) { BufferedWriter writer = null; File splitFile; try { splitFile = File.createTempFile("split-", ".part", splitDir); writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(splitFile.getAbsoluteFile(), false), DataUtilDefaults.charSet)); for(String item : data) { writer.write(item + DataUtilDefaults.lineTerminator); } writer.flush(); writer.close(); writer = null; } catch (UnsupportedEncodingException e) { throw new DataUtilException(e); } catch (FileNotFoundException e) { throw new DataUtilException(e); } catch (IOException e) { throw new DataUtilException(e); } finally { if(writer != null) { try { writer.close(); } catch (IOException e) { // Intentionally we're doing nothing here } } } return splitFile; }
[ "private", "static", "File", "writePartToFile", "(", "File", "splitDir", ",", "List", "<", "String", ">", "data", ")", "{", "BufferedWriter", "writer", "=", "null", ";", "File", "splitFile", ";", "try", "{", "splitFile", "=", "File", ".", "createTempFile", ...
This method writes a partial input file to a split file @param splitDir split file directory @param data data @return <code>File</code> new split file
[ "This", "method", "writes", "a", "partial", "input", "file", "to", "a", "split", "file" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/files/FileSplitter.java#L124-L153
train
btaz/data-util
src/main/java/com/btaz/util/files/FileSplitter.java
FileSplitter.storageCalculation
private static long storageCalculation(int rows, int lineChars, long totalCharacters) { long size = (long) Math.ceil((rows* ARRAY_LIST_ROW_OVERHEAD + lineChars + totalCharacters) * LIST_CAPACITY_MULTIPLIER); return size; }
java
private static long storageCalculation(int rows, int lineChars, long totalCharacters) { long size = (long) Math.ceil((rows* ARRAY_LIST_ROW_OVERHEAD + lineChars + totalCharacters) * LIST_CAPACITY_MULTIPLIER); return size; }
[ "private", "static", "long", "storageCalculation", "(", "int", "rows", ",", "int", "lineChars", ",", "long", "totalCharacters", ")", "{", "long", "size", "=", "(", "long", ")", "Math", ".", "ceil", "(", "(", "rows", "*", "ARRAY_LIST_ROW_OVERHEAD", "+", "li...
This calculation attempts to calculate how much storage x number of rows may use in an ArrayList assuming that capacity may be up to 1.5 times the actual space used. @param rows rows @param lineChars the amount of new character data we want to add @param totalCharacters total amount of characters already stored @return long a guesstimate for storage required
[ "This", "calculation", "attempts", "to", "calculate", "how", "much", "storage", "x", "number", "of", "rows", "may", "use", "in", "an", "ArrayList", "assuming", "that", "capacity", "may", "be", "up", "to", "1", ".", "5", "times", "the", "actual", "space", ...
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/files/FileSplitter.java#L163-L166
train
Teddy-Zhu/SilentGo
framework/src/main/java/com/silentgo/servlet/oreilly/multipart/MultipartParser.java
MultipartParser.extractBoundary
private String extractBoundary(String line) { // Use lastIndexOf() because IE 4.01 on Win98 has been known to send the // "boundary=" string multiple times. Thanks to David Wall for this fix. int index = line.lastIndexOf("boundary="); if (index == -1) { return null; } String boundary = line.substring(index + 9); // 9 for "boundary=" if (boundary.charAt(0) == '"') { // The boundary is enclosed in quotes, strip them index = boundary.lastIndexOf('"'); boundary = boundary.substring(1, index); } // The real boundary is always preceeded by an extra "--" boundary = "--" + boundary; return boundary; }
java
private String extractBoundary(String line) { // Use lastIndexOf() because IE 4.01 on Win98 has been known to send the // "boundary=" string multiple times. Thanks to David Wall for this fix. int index = line.lastIndexOf("boundary="); if (index == -1) { return null; } String boundary = line.substring(index + 9); // 9 for "boundary=" if (boundary.charAt(0) == '"') { // The boundary is enclosed in quotes, strip them index = boundary.lastIndexOf('"'); boundary = boundary.substring(1, index); } // The real boundary is always preceeded by an extra "--" boundary = "--" + boundary; return boundary; }
[ "private", "String", "extractBoundary", "(", "String", "line", ")", "{", "// Use lastIndexOf() because IE 4.01 on Win98 has been known to send the", "// \"boundary=\" string multiple times. Thanks to David Wall for this fix.", "int", "index", "=", "line", ".", "lastIndexOf", "(", ...
Extracts and returns the boundary token from a line. @return the boundary token.
[ "Extracts", "and", "returns", "the", "boundary", "token", "from", "a", "line", "." ]
27f58b0cafe56b2eb9fc6993efa9ca2b529661e1
https://github.com/Teddy-Zhu/SilentGo/blob/27f58b0cafe56b2eb9fc6993efa9ca2b529661e1/framework/src/main/java/com/silentgo/servlet/oreilly/multipart/MultipartParser.java#L338-L356
train
Teddy-Zhu/SilentGo
framework/src/main/java/com/silentgo/servlet/oreilly/multipart/MultipartParser.java
MultipartParser.extractContentType
private static String extractContentType(String line) throws IOException { // Convert the line to a lowercase string line = line.toLowerCase(); // Get the content type, if any // Note that Opera at least puts extra info after the type, so handle // that. For example: Content-Type: text/plain; name="foo" // Thanks to Leon Poyyayil, leon.poyyayil@trivadis.com, for noticing this. int end = line.indexOf(";"); if (end == -1) { end = line.length(); } return line.substring(13, end).trim(); // "content-type:" is 13 }
java
private static String extractContentType(String line) throws IOException { // Convert the line to a lowercase string line = line.toLowerCase(); // Get the content type, if any // Note that Opera at least puts extra info after the type, so handle // that. For example: Content-Type: text/plain; name="foo" // Thanks to Leon Poyyayil, leon.poyyayil@trivadis.com, for noticing this. int end = line.indexOf(";"); if (end == -1) { end = line.length(); } return line.substring(13, end).trim(); // "content-type:" is 13 }
[ "private", "static", "String", "extractContentType", "(", "String", "line", ")", "throws", "IOException", "{", "// Convert the line to a lowercase string", "line", "=", "line", ".", "toLowerCase", "(", ")", ";", "// Get the content type, if any", "// Note that Opera at leas...
Extracts and returns the content type from a line, or null if the line was empty. @return content type, or null if line was empty. @exception IOException if the line is malformatted.
[ "Extracts", "and", "returns", "the", "content", "type", "from", "a", "line", "or", "null", "if", "the", "line", "was", "empty", "." ]
27f58b0cafe56b2eb9fc6993efa9ca2b529661e1
https://github.com/Teddy-Zhu/SilentGo/blob/27f58b0cafe56b2eb9fc6993efa9ca2b529661e1/framework/src/main/java/com/silentgo/servlet/oreilly/multipart/MultipartParser.java#L436-L450
train
Teddy-Zhu/SilentGo
framework/src/main/java/com/silentgo/servlet/oreilly/multipart/MultipartParser.java
MultipartParser.readLine
private String readLine() throws IOException { StringBuffer sbuf = new StringBuffer(); int result; String line; do { result = in.readLine(buf, 0, buf.length); // does += if (result != -1) { sbuf.append(new String(buf, 0, result, encoding)); } } while (result == buf.length); // loop only if the buffer was filled if (sbuf.length() == 0) { return null; // nothing read, must be at the end of stream } // Cut off the trailing \n or \r\n // It should always be \r\n but IE5 sometimes does just \n // Thanks to Luke Blaikie for helping make this work with \n int len = sbuf.length(); if (len >= 2 && sbuf.charAt(len - 2) == '\r') { sbuf.setLength(len - 2); // cut \r\n } else if (len >= 1 && sbuf.charAt(len - 1) == '\n') { sbuf.setLength(len - 1); // cut \n } return sbuf.toString(); }
java
private String readLine() throws IOException { StringBuffer sbuf = new StringBuffer(); int result; String line; do { result = in.readLine(buf, 0, buf.length); // does += if (result != -1) { sbuf.append(new String(buf, 0, result, encoding)); } } while (result == buf.length); // loop only if the buffer was filled if (sbuf.length() == 0) { return null; // nothing read, must be at the end of stream } // Cut off the trailing \n or \r\n // It should always be \r\n but IE5 sometimes does just \n // Thanks to Luke Blaikie for helping make this work with \n int len = sbuf.length(); if (len >= 2 && sbuf.charAt(len - 2) == '\r') { sbuf.setLength(len - 2); // cut \r\n } else if (len >= 1 && sbuf.charAt(len - 1) == '\n') { sbuf.setLength(len - 1); // cut \n } return sbuf.toString(); }
[ "private", "String", "readLine", "(", ")", "throws", "IOException", "{", "StringBuffer", "sbuf", "=", "new", "StringBuffer", "(", ")", ";", "int", "result", ";", "String", "line", ";", "do", "{", "result", "=", "in", ".", "readLine", "(", "buf", ",", "...
Read the next line of input. @return a String containing the next line of input from the stream, or null to indicate the end of the stream. @exception IOException if an input or output exception has occurred.
[ "Read", "the", "next", "line", "of", "input", "." ]
27f58b0cafe56b2eb9fc6993efa9ca2b529661e1
https://github.com/Teddy-Zhu/SilentGo/blob/27f58b0cafe56b2eb9fc6993efa9ca2b529661e1/framework/src/main/java/com/silentgo/servlet/oreilly/multipart/MultipartParser.java#L459-L486
train
aehrc/ontology-core
ontology-model/src/main/java/au/csiro/ontology/util/SnomedMetadata.java
SnomedMetadata.getNeverGroupedIds
public Set<String> getNeverGroupedIds() { String s = props.getProperty("neverGroupedIds"); if(s == null) return Collections.emptySet(); Set<String> res = new HashSet<String>(); String[] parts = s.split("[,]"); for(String part : parts) { res.add(part); } return res; }
java
public Set<String> getNeverGroupedIds() { String s = props.getProperty("neverGroupedIds"); if(s == null) return Collections.emptySet(); Set<String> res = new HashSet<String>(); String[] parts = s.split("[,]"); for(String part : parts) { res.add(part); } return res; }
[ "public", "Set", "<", "String", ">", "getNeverGroupedIds", "(", ")", "{", "String", "s", "=", "props", ".", "getProperty", "(", "\"neverGroupedIds\"", ")", ";", "if", "(", "s", "==", "null", ")", "return", "Collections", ".", "emptySet", "(", ")", ";", ...
Returns the set of ids of SNOMED roles that should never be placed in a role group. @return Set of ids of SNOMED roles that should never be placed in a role group.
[ "Returns", "the", "set", "of", "ids", "of", "SNOMED", "roles", "that", "should", "never", "be", "placed", "in", "a", "role", "group", "." ]
446aa691119f2bbcb8d184566084b8da7a07a44e
https://github.com/aehrc/ontology-core/blob/446aa691119f2bbcb8d184566084b8da7a07a44e/ontology-model/src/main/java/au/csiro/ontology/util/SnomedMetadata.java#L137-L147
train
aehrc/ontology-core
ontology-model/src/main/java/au/csiro/ontology/util/SnomedMetadata.java
SnomedMetadata.getRightIdentityIds
public Map<String, String> getRightIdentityIds() { String s = props.getProperty("rightIdentityIds"); if(s == null) return Collections.emptyMap(); Map<String, String> res = new HashMap<String, String>(); String[] parts = s.split("[,]"); res.put(parts[0], parts[1]); return res; }
java
public Map<String, String> getRightIdentityIds() { String s = props.getProperty("rightIdentityIds"); if(s == null) return Collections.emptyMap(); Map<String, String> res = new HashMap<String, String>(); String[] parts = s.split("[,]"); res.put(parts[0], parts[1]); return res; }
[ "public", "Map", "<", "String", ",", "String", ">", "getRightIdentityIds", "(", ")", "{", "String", "s", "=", "props", ".", "getProperty", "(", "\"rightIdentityIds\"", ")", ";", "if", "(", "s", "==", "null", ")", "return", "Collections", ".", "emptyMap", ...
Returns the right identity axioms that cannot be represented in RF1 or RF2 formats. An example is direct-substance o has-active-ingredient [ direct-substance. The key of the returned map is the first element in the LHS and the value is the second element in the LHS. The RHS, because it is a right identity axiom, is always the same as the first element in the LHS. @return The right identity axioms.
[ "Returns", "the", "right", "identity", "axioms", "that", "cannot", "be", "represented", "in", "RF1", "or", "RF2", "formats", ".", "An", "example", "is", "direct", "-", "substance", "o", "has", "-", "active", "-", "ingredient", "[", "direct", "-", "substanc...
446aa691119f2bbcb8d184566084b8da7a07a44e
https://github.com/aehrc/ontology-core/blob/446aa691119f2bbcb8d184566084b8da7a07a44e/ontology-model/src/main/java/au/csiro/ontology/util/SnomedMetadata.java#L168-L176
train
eyp/serfj
src/main/java/net/sf/serfj/serializers/Base64Serializer.java
Base64Serializer.serialize
public String serialize(Object object) { ObjectOutputStream oos = null; ByteArrayOutputStream bos = null; try { bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); oos.writeObject(object); return new String(Base64.encodeBase64(bos.toByteArray())); } catch (IOException e) { LOGGER.error("Can't serialize data on Base 64", e); throw new IllegalArgumentException(e); } catch (Exception e) { LOGGER.error("Can't serialize data on Base 64", e); throw new IllegalArgumentException(e); } finally { try { if (bos != null) { bos.close(); } } catch (Exception e) { LOGGER.error("Can't close ObjetInputStream used for serialize data on Base 64", e); } } }
java
public String serialize(Object object) { ObjectOutputStream oos = null; ByteArrayOutputStream bos = null; try { bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); oos.writeObject(object); return new String(Base64.encodeBase64(bos.toByteArray())); } catch (IOException e) { LOGGER.error("Can't serialize data on Base 64", e); throw new IllegalArgumentException(e); } catch (Exception e) { LOGGER.error("Can't serialize data on Base 64", e); throw new IllegalArgumentException(e); } finally { try { if (bos != null) { bos.close(); } } catch (Exception e) { LOGGER.error("Can't close ObjetInputStream used for serialize data on Base 64", e); } } }
[ "public", "String", "serialize", "(", "Object", "object", ")", "{", "ObjectOutputStream", "oos", "=", "null", ";", "ByteArrayOutputStream", "bos", "=", "null", ";", "try", "{", "bos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "oos", "=", "new", "...
Serialize object to an encoded base64 string.
[ "Serialize", "object", "to", "an", "encoded", "base64", "string", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/serializers/Base64Serializer.java#L40-L63
train
eyp/serfj
src/main/java/net/sf/serfj/serializers/Base64Serializer.java
Base64Serializer.deserialize
public Object deserialize(String data) { if ((data == null) || (data.length() == 0)) { return null; } ObjectInputStream ois = null; ByteArrayInputStream bis = null; try { bis = new ByteArrayInputStream(Base64.decodeBase64(data.getBytes())); ois = new ObjectInputStream(bis); return ois.readObject(); } catch (ClassNotFoundException e) { LOGGER.error("Can't deserialize data from Base64", e); throw new IllegalArgumentException(e); } catch (IOException e) { LOGGER.error("Can't deserialize data from Base64", e); throw new IllegalArgumentException(e); } catch (Exception e) { LOGGER.error("Can't deserialize data from Base64", e); throw new IllegalArgumentException(e); } finally { try { if (ois != null) { ois.close(); } } catch (Exception e) { LOGGER.error("Can't close ObjetInputStream used for deserialize data from Base64", e); } } }
java
public Object deserialize(String data) { if ((data == null) || (data.length() == 0)) { return null; } ObjectInputStream ois = null; ByteArrayInputStream bis = null; try { bis = new ByteArrayInputStream(Base64.decodeBase64(data.getBytes())); ois = new ObjectInputStream(bis); return ois.readObject(); } catch (ClassNotFoundException e) { LOGGER.error("Can't deserialize data from Base64", e); throw new IllegalArgumentException(e); } catch (IOException e) { LOGGER.error("Can't deserialize data from Base64", e); throw new IllegalArgumentException(e); } catch (Exception e) { LOGGER.error("Can't deserialize data from Base64", e); throw new IllegalArgumentException(e); } finally { try { if (ois != null) { ois.close(); } } catch (Exception e) { LOGGER.error("Can't close ObjetInputStream used for deserialize data from Base64", e); } } }
[ "public", "Object", "deserialize", "(", "String", "data", ")", "{", "if", "(", "(", "data", "==", "null", ")", "||", "(", "data", ".", "length", "(", ")", "==", "0", ")", ")", "{", "return", "null", ";", "}", "ObjectInputStream", "ois", "=", "null"...
Deserialze base 64 encoded string data to Object.
[ "Deserialze", "base", "64", "encoded", "string", "data", "to", "Object", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/serializers/Base64Serializer.java#L68-L96
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.getMethodIndex
int getMethodIndex(ExecutableElement method) { TypeElement declaringClass = (TypeElement) method.getEnclosingElement(); String fullyQualifiedname = declaringClass.getQualifiedName().toString(); return getRefIndex(Methodref.class, fullyQualifiedname, method.getSimpleName().toString(), Descriptor.getDesriptor(method)); }
java
int getMethodIndex(ExecutableElement method) { TypeElement declaringClass = (TypeElement) method.getEnclosingElement(); String fullyQualifiedname = declaringClass.getQualifiedName().toString(); return getRefIndex(Methodref.class, fullyQualifiedname, method.getSimpleName().toString(), Descriptor.getDesriptor(method)); }
[ "int", "getMethodIndex", "(", "ExecutableElement", "method", ")", "{", "TypeElement", "declaringClass", "=", "(", "TypeElement", ")", "method", ".", "getEnclosingElement", "(", ")", ";", "String", "fullyQualifiedname", "=", "declaringClass", ".", "getQualifiedName", ...
Returns the constant map index to method @param method @return
[ "Returns", "the", "constant", "map", "index", "to", "method" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L234-L239
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.getRefIndex
protected int getRefIndex(Class<? extends Ref> refType, String fullyQualifiedname, String name, String descriptor) { String internalForm = fullyQualifiedname.replace('.', '/'); for (ConstantInfo ci : listConstantInfo(refType)) { Ref mr = (Ref) ci; int classIndex = mr.getClass_index(); Clazz clazz = (Clazz) getConstantInfo(classIndex); String cn = getString(clazz.getName_index()); if (internalForm.equals(cn)) { int nameAndTypeIndex = mr.getName_and_type_index(); NameAndType nat = (NameAndType) getConstantInfo(nameAndTypeIndex); int nameIndex = nat.getName_index(); String str = getString(nameIndex); if (name.equals(str)) { int descriptorIndex = nat.getDescriptor_index(); String descr = getString(descriptorIndex); if (descriptor.equals(descr)) { return constantPoolIndexMap.get(ci); } } } } return -1; }
java
protected int getRefIndex(Class<? extends Ref> refType, String fullyQualifiedname, String name, String descriptor) { String internalForm = fullyQualifiedname.replace('.', '/'); for (ConstantInfo ci : listConstantInfo(refType)) { Ref mr = (Ref) ci; int classIndex = mr.getClass_index(); Clazz clazz = (Clazz) getConstantInfo(classIndex); String cn = getString(clazz.getName_index()); if (internalForm.equals(cn)) { int nameAndTypeIndex = mr.getName_and_type_index(); NameAndType nat = (NameAndType) getConstantInfo(nameAndTypeIndex); int nameIndex = nat.getName_index(); String str = getString(nameIndex); if (name.equals(str)) { int descriptorIndex = nat.getDescriptor_index(); String descr = getString(descriptorIndex); if (descriptor.equals(descr)) { return constantPoolIndexMap.get(ci); } } } } return -1; }
[ "protected", "int", "getRefIndex", "(", "Class", "<", "?", "extends", "Ref", ">", "refType", ",", "String", "fullyQualifiedname", ",", "String", "name", ",", "String", "descriptor", ")", "{", "String", "internalForm", "=", "fullyQualifiedname", ".", "replace", ...
Returns the constant map index to reference @param refType @param fullyQualifiedname @param name @param descriptor @return
[ "Returns", "the", "constant", "map", "index", "to", "reference" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L248-L275
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.getNameIndex
public int getNameIndex(CharSequence name) { for (ConstantInfo ci : listConstantInfo(Utf8.class)) { Utf8 utf8 = (Utf8) ci; String str = utf8.getString(); if (str.contentEquals(name)) { return constantPoolIndexMap.get(ci); } } return -1; }
java
public int getNameIndex(CharSequence name) { for (ConstantInfo ci : listConstantInfo(Utf8.class)) { Utf8 utf8 = (Utf8) ci; String str = utf8.getString(); if (str.contentEquals(name)) { return constantPoolIndexMap.get(ci); } } return -1; }
[ "public", "int", "getNameIndex", "(", "CharSequence", "name", ")", "{", "for", "(", "ConstantInfo", "ci", ":", "listConstantInfo", "(", "Utf8", ".", "class", ")", ")", "{", "Utf8", "utf8", "=", "(", "Utf8", ")", "ci", ";", "String", "str", "=", "utf8",...
Returns the constant map index to name @param name @return
[ "Returns", "the", "constant", "map", "index", "to", "name" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L281-L293
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.getNameAndTypeIndex
public int getNameAndTypeIndex(String name, String descriptor) { for (ConstantInfo ci : listConstantInfo(NameAndType.class)) { NameAndType nat = (NameAndType) ci; int nameIndex = nat.getName_index(); String str = getString(nameIndex); if (name.equals(str)) { int descriptorIndex = nat.getDescriptor_index(); String descr = getString(descriptorIndex); if (descriptor.equals(descr)) { return constantPoolIndexMap.get(ci); } } } return -1; }
java
public int getNameAndTypeIndex(String name, String descriptor) { for (ConstantInfo ci : listConstantInfo(NameAndType.class)) { NameAndType nat = (NameAndType) ci; int nameIndex = nat.getName_index(); String str = getString(nameIndex); if (name.equals(str)) { int descriptorIndex = nat.getDescriptor_index(); String descr = getString(descriptorIndex); if (descriptor.equals(descr)) { return constantPoolIndexMap.get(ci); } } } return -1; }
[ "public", "int", "getNameAndTypeIndex", "(", "String", "name", ",", "String", "descriptor", ")", "{", "for", "(", "ConstantInfo", "ci", ":", "listConstantInfo", "(", "NameAndType", ".", "class", ")", ")", "{", "NameAndType", "nat", "=", "(", "NameAndType", "...
Returns the constant map index to name and type @param name @param descriptor @return
[ "Returns", "the", "constant", "map", "index", "to", "name", "and", "type" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L300-L318
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.getConstantIndex
public final int getConstantIndex(int constant) { for (ConstantInfo ci : listConstantInfo(ConstantInteger.class)) { ConstantInteger ic = (ConstantInteger) ci; if (constant == ic.getConstant()) { return constantPoolIndexMap.get(ci); } } return -1; }
java
public final int getConstantIndex(int constant) { for (ConstantInfo ci : listConstantInfo(ConstantInteger.class)) { ConstantInteger ic = (ConstantInteger) ci; if (constant == ic.getConstant()) { return constantPoolIndexMap.get(ci); } } return -1; }
[ "public", "final", "int", "getConstantIndex", "(", "int", "constant", ")", "{", "for", "(", "ConstantInfo", "ci", ":", "listConstantInfo", "(", "ConstantInteger", ".", "class", ")", ")", "{", "ConstantInteger", "ic", "=", "(", "ConstantInteger", ")", "ci", "...
Returns the constant map index to integer constant @param constant @return
[ "Returns", "the", "constant", "map", "index", "to", "integer", "constant" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L324-L335
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.getIndexedType
Object getIndexedType(int index) { Object ae = indexedElementMap.get(index); if (ae == null) { throw new VerifyError("constant pool at "+index+" not proper type"); } return ae; }
java
Object getIndexedType(int index) { Object ae = indexedElementMap.get(index); if (ae == null) { throw new VerifyError("constant pool at "+index+" not proper type"); } return ae; }
[ "Object", "getIndexedType", "(", "int", "index", ")", "{", "Object", "ae", "=", "indexedElementMap", ".", "get", "(", "index", ")", ";", "if", "(", "ae", "==", "null", ")", "{", "throw", "new", "VerifyError", "(", "\"constant pool at \"", "+", "index", "...
Returns a element from constant map @param index @return
[ "Returns", "a", "element", "from", "constant", "map" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L534-L542
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.getFieldDescription
public String getFieldDescription(int index) { ConstantInfo constantInfo = getConstantInfo(index); if (constantInfo instanceof Fieldref) { Fieldref fr = (Fieldref) getConstantInfo(index); int nt = fr.getName_and_type_index(); NameAndType nat = (NameAndType) getConstantInfo(nt); int ni = nat.getName_index(); int di = nat.getDescriptor_index(); return getString(ni)+" "+getString(di); } return "unknown "+constantInfo; }
java
public String getFieldDescription(int index) { ConstantInfo constantInfo = getConstantInfo(index); if (constantInfo instanceof Fieldref) { Fieldref fr = (Fieldref) getConstantInfo(index); int nt = fr.getName_and_type_index(); NameAndType nat = (NameAndType) getConstantInfo(nt); int ni = nat.getName_index(); int di = nat.getDescriptor_index(); return getString(ni)+" "+getString(di); } return "unknown "+constantInfo; }
[ "public", "String", "getFieldDescription", "(", "int", "index", ")", "{", "ConstantInfo", "constantInfo", "=", "getConstantInfo", "(", "index", ")", ";", "if", "(", "constantInfo", "instanceof", "Fieldref", ")", "{", "Fieldref", "fr", "=", "(", "Fieldref", ")"...
Returns a descriptor to fields at index. @param index @return
[ "Returns", "a", "descriptor", "to", "fields", "at", "index", "." ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L548-L561
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.getMethodDescription
public String getMethodDescription(int index) { ConstantInfo constantInfo = getConstantInfo(index); if (constantInfo instanceof Methodref) { Methodref mr = (Methodref) getConstantInfo(index); int nt = mr.getName_and_type_index(); NameAndType nat = (NameAndType) getConstantInfo(nt); int ni = nat.getName_index(); int di = nat.getDescriptor_index(); return getString(ni)+" "+getString(di); } if (constantInfo instanceof InterfaceMethodref) { InterfaceMethodref mr = (InterfaceMethodref) getConstantInfo(index); int nt = mr.getName_and_type_index(); NameAndType nat = (NameAndType) getConstantInfo(nt); int ni = nat.getName_index(); int di = nat.getDescriptor_index(); return getString(ni)+" "+getString(di); } return "unknown "+constantInfo; }
java
public String getMethodDescription(int index) { ConstantInfo constantInfo = getConstantInfo(index); if (constantInfo instanceof Methodref) { Methodref mr = (Methodref) getConstantInfo(index); int nt = mr.getName_and_type_index(); NameAndType nat = (NameAndType) getConstantInfo(nt); int ni = nat.getName_index(); int di = nat.getDescriptor_index(); return getString(ni)+" "+getString(di); } if (constantInfo instanceof InterfaceMethodref) { InterfaceMethodref mr = (InterfaceMethodref) getConstantInfo(index); int nt = mr.getName_and_type_index(); NameAndType nat = (NameAndType) getConstantInfo(nt); int ni = nat.getName_index(); int di = nat.getDescriptor_index(); return getString(ni)+" "+getString(di); } return "unknown "+constantInfo; }
[ "public", "String", "getMethodDescription", "(", "int", "index", ")", "{", "ConstantInfo", "constantInfo", "=", "getConstantInfo", "(", "index", ")", ";", "if", "(", "constantInfo", "instanceof", "Methodref", ")", "{", "Methodref", "mr", "=", "(", "Methodref", ...
Returns a descriptor to method at index. @param index @return
[ "Returns", "a", "descriptor", "to", "method", "at", "index", "." ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L567-L589
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.getClassDescription
public String getClassDescription(int index) { Clazz cz = (Clazz) getConstantInfo(index); int ni = cz.getName_index(); return getString(ni); }
java
public String getClassDescription(int index) { Clazz cz = (Clazz) getConstantInfo(index); int ni = cz.getName_index(); return getString(ni); }
[ "public", "String", "getClassDescription", "(", "int", "index", ")", "{", "Clazz", "cz", "=", "(", "Clazz", ")", "getConstantInfo", "(", "index", ")", ";", "int", "ni", "=", "cz", ".", "getName_index", "(", ")", ";", "return", "getString", "(", "ni", "...
Returns a descriptor to class at index. @param index @return
[ "Returns", "a", "descriptor", "to", "class", "at", "index", "." ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L595-L600
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.referencesMethod
public boolean referencesMethod(ExecutableElement method) { TypeElement declaringClass = (TypeElement) method.getEnclosingElement(); String fullyQualifiedname = declaringClass.getQualifiedName().toString(); String name = method.getSimpleName().toString(); assert name.indexOf('.') == -1; String descriptor = Descriptor.getDesriptor(method); return getRefIndex(Methodref.class, fullyQualifiedname, name, descriptor) != -1; }
java
public boolean referencesMethod(ExecutableElement method) { TypeElement declaringClass = (TypeElement) method.getEnclosingElement(); String fullyQualifiedname = declaringClass.getQualifiedName().toString(); String name = method.getSimpleName().toString(); assert name.indexOf('.') == -1; String descriptor = Descriptor.getDesriptor(method); return getRefIndex(Methodref.class, fullyQualifiedname, name, descriptor) != -1; }
[ "public", "boolean", "referencesMethod", "(", "ExecutableElement", "method", ")", "{", "TypeElement", "declaringClass", "=", "(", "TypeElement", ")", "method", ".", "getEnclosingElement", "(", ")", ";", "String", "fullyQualifiedname", "=", "declaringClass", ".", "ge...
Return true if class contains method ref to given method @param method @return
[ "Return", "true", "if", "class", "contains", "method", "ref", "to", "given", "method" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L636-L644
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/ClassFile.java
ClassFile.getString
public final String getString(int index) { Utf8 utf8 = (Utf8) getConstantInfo(index); return utf8.getString(); }
java
public final String getString(int index) { Utf8 utf8 = (Utf8) getConstantInfo(index); return utf8.getString(); }
[ "public", "final", "String", "getString", "(", "int", "index", ")", "{", "Utf8", "utf8", "=", "(", "Utf8", ")", "getConstantInfo", "(", "index", ")", ";", "return", "utf8", ".", "getString", "(", ")", ";", "}" ]
Return a constant string at index. @param index @return
[ "Return", "a", "constant", "string", "at", "index", "." ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/ClassFile.java#L687-L691
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/model/El.java
El.getMethod
public static ExecutableElement getMethod(TypeElement typeElement, String name, TypeMirror... parameters) { List<ExecutableElement> allMethods = getAllMethods(typeElement, name, parameters); if (allMethods.isEmpty()) { return null; } else { Collections.sort(allMethods, new SpecificMethodComparator()); return allMethods.get(0); } }
java
public static ExecutableElement getMethod(TypeElement typeElement, String name, TypeMirror... parameters) { List<ExecutableElement> allMethods = getAllMethods(typeElement, name, parameters); if (allMethods.isEmpty()) { return null; } else { Collections.sort(allMethods, new SpecificMethodComparator()); return allMethods.get(0); } }
[ "public", "static", "ExecutableElement", "getMethod", "(", "TypeElement", "typeElement", ",", "String", "name", ",", "TypeMirror", "...", "parameters", ")", "{", "List", "<", "ExecutableElement", ">", "allMethods", "=", "getAllMethods", "(", "typeElement", ",", "n...
Returns the most specific named method in typeElement, or null if such method was not found @param typeElement Class @param name Method name @param parameters Method parameters @return
[ "Returns", "the", "most", "specific", "named", "method", "in", "typeElement", "or", "null", "if", "such", "method", "was", "not", "found" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/model/El.java#L286-L298
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/model/El.java
El.getEffectiveMethods
public static List<? extends ExecutableElement> getEffectiveMethods(TypeElement cls) { List<ExecutableElement> list = new ArrayList<>(); while (cls != null) { for (ExecutableElement method : ElementFilter.methodsIn(cls.getEnclosedElements())) { if (!overrides(list, method)) { list.add(method); } } cls = (TypeElement) Typ.asElement(cls.getSuperclass()); } return list; }
java
public static List<? extends ExecutableElement> getEffectiveMethods(TypeElement cls) { List<ExecutableElement> list = new ArrayList<>(); while (cls != null) { for (ExecutableElement method : ElementFilter.methodsIn(cls.getEnclosedElements())) { if (!overrides(list, method)) { list.add(method); } } cls = (TypeElement) Typ.asElement(cls.getSuperclass()); } return list; }
[ "public", "static", "List", "<", "?", "extends", "ExecutableElement", ">", "getEffectiveMethods", "(", "TypeElement", "cls", ")", "{", "List", "<", "ExecutableElement", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "while", "(", "cls", "!=", "...
Return effective methods for a class. All methods accessible at class are returned. That includes superclass methods which are not override. @param cls @return
[ "Return", "effective", "methods", "for", "a", "class", ".", "All", "methods", "accessible", "at", "class", "are", "returned", ".", "That", "includes", "superclass", "methods", "which", "are", "not", "override", "." ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/model/El.java#L461-L476
train
btaz/data-util
src/main/java/com/btaz/util/collections/Lists.java
Lists.createList
public static <T> List<T> createList(T... args) { ArrayList<T> newList = new ArrayList<T>(); Collections.addAll(newList, args); return newList; }
java
public static <T> List<T> createList(T... args) { ArrayList<T> newList = new ArrayList<T>(); Collections.addAll(newList, args); return newList; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "createList", "(", "T", "...", "args", ")", "{", "ArrayList", "<", "T", ">", "newList", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "Collections", ".", "addAll", "(", "newList", ...
Convenience method for building a list from vararg arguments @param args argument list @param <T> list type @return a new list created from var args
[ "Convenience", "method", "for", "building", "a", "list", "from", "vararg", "arguments" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/collections/Lists.java#L15-L19
train
btaz/data-util
src/main/java/com/btaz/util/collections/Lists.java
Lists.arrayToList
public static <T> List<T> arrayToList(T [] array) { return new ArrayList<T>(Arrays.asList(array)); }
java
public static <T> List<T> arrayToList(T [] array) { return new ArrayList<T>(Arrays.asList(array)); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "arrayToList", "(", "T", "[", "]", "array", ")", "{", "return", "new", "ArrayList", "<", "T", ">", "(", "Arrays", ".", "asList", "(", "array", ")", ")", ";", "}" ]
Convenience method for building a list from an array @param array @param <T> list type @return a new list created from var args
[ "Convenience", "method", "for", "building", "a", "list", "from", "an", "array" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/collections/Lists.java#L27-L29
train
btaz/data-util
src/main/java/com/btaz/util/collections/Lists.java
Lists.subList
public static <T> List<T> subList(List<T> list, Criteria<T> criteria) { ArrayList<T> subList = new ArrayList<T>(); for(T item : list) { if(criteria.meetsCriteria(item)) { subList.add(item); } } return subList; }
java
public static <T> List<T> subList(List<T> list, Criteria<T> criteria) { ArrayList<T> subList = new ArrayList<T>(); for(T item : list) { if(criteria.meetsCriteria(item)) { subList.add(item); } } return subList; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "subList", "(", "List", "<", "T", ">", "list", ",", "Criteria", "<", "T", ">", "criteria", ")", "{", "ArrayList", "<", "T", ">", "subList", "=", "new", "ArrayList", "<", "T", ">", "(", "...
Extract a sub list from another list @param list original list @param criteria criteria used to determine whether or not to extract item @param <T> list type @return {@code List} of sub list items
[ "Extract", "a", "sub", "list", "from", "another", "list" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/collections/Lists.java#L38-L46
train
AdeptInternet/auth-java
saml/src/main/java/org/adeptnet/auth/saml/SAMLClient.java
SAMLClient.generateAuthnRequest
public String generateAuthnRequest(final String requestId) throws SAMLException { final String request = _createAuthnRequest(requestId); try { final byte[] compressed = deflate(request.getBytes("UTF-8")); return DatatypeConverter.printBase64Binary(compressed); } catch (UnsupportedEncodingException e) { throw new SAMLException("Apparently your platform lacks UTF-8. That's too bad.", e); } catch (IOException e) { throw new SAMLException("Unable to compress the AuthnRequest", e); } }
java
public String generateAuthnRequest(final String requestId) throws SAMLException { final String request = _createAuthnRequest(requestId); try { final byte[] compressed = deflate(request.getBytes("UTF-8")); return DatatypeConverter.printBase64Binary(compressed); } catch (UnsupportedEncodingException e) { throw new SAMLException("Apparently your platform lacks UTF-8. That's too bad.", e); } catch (IOException e) { throw new SAMLException("Unable to compress the AuthnRequest", e); } }
[ "public", "String", "generateAuthnRequest", "(", "final", "String", "requestId", ")", "throws", "SAMLException", "{", "final", "String", "request", "=", "_createAuthnRequest", "(", "requestId", ")", ";", "try", "{", "final", "byte", "[", "]", "compressed", "=", ...
Create a new AuthnRequest suitable for sending to an HTTPRedirect binding endpoint on the IdP. The SPConfig will be used to fill in the ACS and issuer, and the IdP will be used to set the destination. @param requestId random generated RequestId @return a deflated, base64-encoded AuthnRequest @throws org.adeptnet.auth.saml.SAMLException
[ "Create", "a", "new", "AuthnRequest", "suitable", "for", "sending", "to", "an", "HTTPRedirect", "binding", "endpoint", "on", "the", "IdP", ".", "The", "SPConfig", "will", "be", "used", "to", "fill", "in", "the", "ACS", "and", "issuer", "and", "the", "IdP",...
644116ed1f50bf899b9cecc5e3682bac7abf7007
https://github.com/AdeptInternet/auth-java/blob/644116ed1f50bf899b9cecc5e3682bac7abf7007/saml/src/main/java/org/adeptnet/auth/saml/SAMLClient.java#L452-L463
train
AdeptInternet/auth-java
saml/src/main/java/org/adeptnet/auth/saml/SAMLClient.java
SAMLClient.validateResponsePOST
public AttributeSet validateResponsePOST(final String _authnResponse) throws SAMLException { final byte[] decoded = DatatypeConverter.parseBase64Binary(_authnResponse); final String authnResponse; try { authnResponse = new String(decoded, "UTF-8"); if (LOG.isTraceEnabled()) { LOG.trace(authnResponse); } } catch (UnsupportedEncodingException e) { throw new SAMLException("UTF-8 is missing, oh well.", e); } final Response response = parseResponse(authnResponse); try { validatePOST(response); } catch (ValidationException e) { throw new SAMLException(e); } return getAttributeSet(response); }
java
public AttributeSet validateResponsePOST(final String _authnResponse) throws SAMLException { final byte[] decoded = DatatypeConverter.parseBase64Binary(_authnResponse); final String authnResponse; try { authnResponse = new String(decoded, "UTF-8"); if (LOG.isTraceEnabled()) { LOG.trace(authnResponse); } } catch (UnsupportedEncodingException e) { throw new SAMLException("UTF-8 is missing, oh well.", e); } final Response response = parseResponse(authnResponse); try { validatePOST(response); } catch (ValidationException e) { throw new SAMLException(e); } return getAttributeSet(response); }
[ "public", "AttributeSet", "validateResponsePOST", "(", "final", "String", "_authnResponse", ")", "throws", "SAMLException", "{", "final", "byte", "[", "]", "decoded", "=", "DatatypeConverter", ".", "parseBase64Binary", "(", "_authnResponse", ")", ";", "final", "Stri...
Check an authnResponse and return the subject if validation succeeds. The NameID from the subject in the first valid assertion is returned along with the attributes. @param _authnResponse a base64-encoded AuthnResponse from the SP @throws SAMLException if validation failed. @return the authenticated subject/attributes as an AttributeSet
[ "Check", "an", "authnResponse", "and", "return", "the", "subject", "if", "validation", "succeeds", ".", "The", "NameID", "from", "the", "subject", "in", "the", "first", "valid", "assertion", "is", "returned", "along", "with", "the", "attributes", "." ]
644116ed1f50bf899b9cecc5e3682bac7abf7007
https://github.com/AdeptInternet/auth-java/blob/644116ed1f50bf899b9cecc5e3682bac7abf7007/saml/src/main/java/org/adeptnet/auth/saml/SAMLClient.java#L520-L541
train
btaz/data-util
src/main/java/com/btaz/util/xml/model/querypath/PathQueryParser.java
PathQueryParser.treeWalker
private void treeWalker(Node node, int level, List<PathQueryMatcher> queryMatchers, List<Node> collector) { MatchType matchType = queryMatchers.get(level).match(level, node); if(matchType == MatchType.NOT_A_MATCH) { // no reason to scan deeper //noinspection UnnecessaryReturnStatement return; } else if(matchType == MatchType.NODE_MATCH) { // we have a match if(level == queryMatchers.size()-1) { // full path match collector.add(node); } else if(node instanceof Element) { // scan deeper Element element = (Element) node; List<Node> childElements = element.getChildElements(); for (Node childElement : childElements) { treeWalker(childElement, level+1, queryMatchers, collector); } } } else { throw new PathQueryException("Unknown MatchType: " + matchType); } }
java
private void treeWalker(Node node, int level, List<PathQueryMatcher> queryMatchers, List<Node> collector) { MatchType matchType = queryMatchers.get(level).match(level, node); if(matchType == MatchType.NOT_A_MATCH) { // no reason to scan deeper //noinspection UnnecessaryReturnStatement return; } else if(matchType == MatchType.NODE_MATCH) { // we have a match if(level == queryMatchers.size()-1) { // full path match collector.add(node); } else if(node instanceof Element) { // scan deeper Element element = (Element) node; List<Node> childElements = element.getChildElements(); for (Node childElement : childElements) { treeWalker(childElement, level+1, queryMatchers, collector); } } } else { throw new PathQueryException("Unknown MatchType: " + matchType); } }
[ "private", "void", "treeWalker", "(", "Node", "node", ",", "int", "level", ",", "List", "<", "PathQueryMatcher", ">", "queryMatchers", ",", "List", "<", "Node", ">", "collector", ")", "{", "MatchType", "matchType", "=", "queryMatchers", ".", "get", "(", "l...
Recursive BFS tree walker @param node current node
[ "Recursive", "BFS", "tree", "walker" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/xml/model/querypath/PathQueryParser.java#L135-L157
train
eyp/serfj
src/main/java/net/sf/serfj/util/UrlUtils.java
UrlUtils.capitalize
public String capitalize(String string) { if (string == null || string.length() < 1) { return ""; } return string.substring(0, 1).toUpperCase() + string.substring(1); }
java
public String capitalize(String string) { if (string == null || string.length() < 1) { return ""; } return string.substring(0, 1).toUpperCase() + string.substring(1); }
[ "public", "String", "capitalize", "(", "String", "string", ")", "{", "if", "(", "string", "==", "null", "||", "string", ".", "length", "(", ")", "<", "1", ")", "{", "return", "\"\"", ";", "}", "return", "string", ".", "substring", "(", "0", ",", "1...
Changes the first character to uppercase. @param string String. @return Same string with first character in uppercase.
[ "Changes", "the", "first", "character", "to", "uppercase", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/util/UrlUtils.java#L118-L123
train
eyp/serfj
src/main/java/net/sf/serfj/util/UrlUtils.java
UrlUtils.singularize
public String singularize(String noun) { String singular = noun; if (singulars.get(noun) != null) { singular = singulars.get(noun); } else if (noun.matches(".*is$")) { // Singular of *is => *es singular = noun.substring(0, noun.length() - 2) + "es"; } else if (noun.matches(".*ies$")) { // Singular of *ies => *y singular = noun.substring(0, noun.length() - 3) + "y"; } else if (noun.matches(".*ves$")) { // Singular of *ves => *f singular = noun.substring(0, noun.length() - 3) + "f"; } else if (noun.matches(".*es$")) { if (noun.matches(".*les$")) { // Singular of *les => singular = noun.substring(0, noun.length() - 1); } else { // Singular of *es => singular = noun.substring(0, noun.length() - 2); } } else if (noun.matches(".*s$")) { // Singular of *s => singular = noun.substring(0, noun.length() - 1); } return singular; }
java
public String singularize(String noun) { String singular = noun; if (singulars.get(noun) != null) { singular = singulars.get(noun); } else if (noun.matches(".*is$")) { // Singular of *is => *es singular = noun.substring(0, noun.length() - 2) + "es"; } else if (noun.matches(".*ies$")) { // Singular of *ies => *y singular = noun.substring(0, noun.length() - 3) + "y"; } else if (noun.matches(".*ves$")) { // Singular of *ves => *f singular = noun.substring(0, noun.length() - 3) + "f"; } else if (noun.matches(".*es$")) { if (noun.matches(".*les$")) { // Singular of *les => singular = noun.substring(0, noun.length() - 1); } else { // Singular of *es => singular = noun.substring(0, noun.length() - 2); } } else if (noun.matches(".*s$")) { // Singular of *s => singular = noun.substring(0, noun.length() - 1); } return singular; }
[ "public", "String", "singularize", "(", "String", "noun", ")", "{", "String", "singular", "=", "noun", ";", "if", "(", "singulars", ".", "get", "(", "noun", ")", "!=", "null", ")", "{", "singular", "=", "singulars", ".", "get", "(", "noun", ")", ";",...
Gets the singular of a plural. @param noun Name. @return if the name was at singular, it does anything. If the name was a plural, returns its singular.
[ "Gets", "the", "singular", "of", "a", "plural", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/util/UrlUtils.java#L143-L169
train
eyp/serfj
src/main/java/net/sf/serfj/util/UrlUtils.java
UrlUtils.getExtension
public String getExtension(String url) { int dotIndex = url.lastIndexOf('.'); String extension = null; if (dotIndex > 0) { extension = url.substring(dotIndex + 1); } return extension; }
java
public String getExtension(String url) { int dotIndex = url.lastIndexOf('.'); String extension = null; if (dotIndex > 0) { extension = url.substring(dotIndex + 1); } return extension; }
[ "public", "String", "getExtension", "(", "String", "url", ")", "{", "int", "dotIndex", "=", "url", ".", "lastIndexOf", "(", "'", "'", ")", ";", "String", "extension", "=", "null", ";", "if", "(", "dotIndex", ">", "0", ")", "{", "extension", "=", "url...
Gets the extension used in the URL, if any. @param url An URl without query string params.. @return an extension, or null if there isn't any.
[ "Gets", "the", "extension", "used", "in", "the", "URL", "if", "any", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/util/UrlUtils.java#L178-L185
train
btaz/data-util
src/main/java/com/btaz/util/writer/HtmlTableWriter.java
HtmlTableWriter.write
public void write(String... columns) throws DataUtilException { if(columns.length != tableColumns) { throw new DataUtilException("Invalid column count. Expected " + tableColumns + " but found: " + columns.length); } try { if(currentRow == 0) { // capture header row this.headerRowColumns = columns; writeTop(); writeRow(headerRowColumns); } else if(maxRowsPerPage > 1 && currentRow % maxRowsPerPage == 0) { writeBottom(true); currentPageNumber = (currentRow/maxRowsPerPage) + 1; writeTop(); writeRow(headerRowColumns); currentRow += 1; writeRow(columns); } else { writeRow(columns); } currentRow += 1; } catch (Exception e) { throw new DataUtilException(e); } }
java
public void write(String... columns) throws DataUtilException { if(columns.length != tableColumns) { throw new DataUtilException("Invalid column count. Expected " + tableColumns + " but found: " + columns.length); } try { if(currentRow == 0) { // capture header row this.headerRowColumns = columns; writeTop(); writeRow(headerRowColumns); } else if(maxRowsPerPage > 1 && currentRow % maxRowsPerPage == 0) { writeBottom(true); currentPageNumber = (currentRow/maxRowsPerPage) + 1; writeTop(); writeRow(headerRowColumns); currentRow += 1; writeRow(columns); } else { writeRow(columns); } currentRow += 1; } catch (Exception e) { throw new DataUtilException(e); } }
[ "public", "void", "write", "(", "String", "...", "columns", ")", "throws", "DataUtilException", "{", "if", "(", "columns", ".", "length", "!=", "tableColumns", ")", "{", "throw", "new", "DataUtilException", "(", "\"Invalid column count. Expected \"", "+", "tableCo...
Write a row to the table. The first row will be the header row @param columns columns @throws DataUtilException exception
[ "Write", "a", "row", "to", "the", "table", ".", "The", "first", "row", "will", "be", "the", "header", "row" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/writer/HtmlTableWriter.java#L96-L121
train
btaz/data-util
src/main/java/com/btaz/util/writer/HtmlTableWriter.java
HtmlTableWriter.writeRow
private void writeRow(String... columns) throws IOException { StringBuilder html = new StringBuilder(); html.append("<tr>"); for(String data : columns) { html.append("<td>").append(data).append("</td>"); } html.append("</tr>\n"); writer.write(html.toString()); }
java
private void writeRow(String... columns) throws IOException { StringBuilder html = new StringBuilder(); html.append("<tr>"); for(String data : columns) { html.append("<td>").append(data).append("</td>"); } html.append("</tr>\n"); writer.write(html.toString()); }
[ "private", "void", "writeRow", "(", "String", "...", "columns", ")", "throws", "IOException", "{", "StringBuilder", "html", "=", "new", "StringBuilder", "(", ")", ";", "html", ".", "append", "(", "\"<tr>\"", ")", ";", "for", "(", "String", "data", ":", "...
Write data to file @param columns column data @throws IOException exception
[ "Write", "data", "to", "file" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/writer/HtmlTableWriter.java#L128-L136
train
btaz/data-util
src/main/java/com/btaz/util/writer/HtmlTableWriter.java
HtmlTableWriter.writeTop
private void writeTop() throws IOException { // setup output HTML file File outputFile = new File(outputDirectory, createFilename(currentPageNumber)); writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(outputFile, false), Charset.forName(encoding))); // write header Map<String,Object> map = new HashMap<String,Object>(); map.put("pageTitle", pageTitle); if(pageHeader != null && pageHeader.length() > 0) { map.put("header", "<h1>" + pageHeader + "</h1>"); } else { map.put("header",""); } if(pageDescription != null && pageDescription.length() > 0) { map.put("description", "<p>" + pageDescription + "</p>"); } else { map.put("description", ""); } String template = Template.readResourceAsStream("com/btaz/util/templates/html-table-header.ftl"); String output = Template.transform(template, map); writer.write(output); }
java
private void writeTop() throws IOException { // setup output HTML file File outputFile = new File(outputDirectory, createFilename(currentPageNumber)); writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(outputFile, false), Charset.forName(encoding))); // write header Map<String,Object> map = new HashMap<String,Object>(); map.put("pageTitle", pageTitle); if(pageHeader != null && pageHeader.length() > 0) { map.put("header", "<h1>" + pageHeader + "</h1>"); } else { map.put("header",""); } if(pageDescription != null && pageDescription.length() > 0) { map.put("description", "<p>" + pageDescription + "</p>"); } else { map.put("description", ""); } String template = Template.readResourceAsStream("com/btaz/util/templates/html-table-header.ftl"); String output = Template.transform(template, map); writer.write(output); }
[ "private", "void", "writeTop", "(", ")", "throws", "IOException", "{", "// setup output HTML file", "File", "outputFile", "=", "new", "File", "(", "outputDirectory", ",", "createFilename", "(", "currentPageNumber", ")", ")", ";", "writer", "=", "new", "BufferedWri...
Write the top part of the HTML document @throws IOException exception
[ "Write", "the", "top", "part", "of", "the", "HTML", "document" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/writer/HtmlTableWriter.java#L142-L165
train
btaz/data-util
src/main/java/com/btaz/util/writer/HtmlTableWriter.java
HtmlTableWriter.writeBottom
private void writeBottom(boolean hasNext) throws IOException { String template = Template.readResourceAsStream("com/btaz/util/templates/html-table-footer.ftl"); Map<String,Object> map = new HashMap<String,Object>(); String prev = " "; String next = ""; if(currentPageNumber > 1) { prev = "<a href=\"" + createFilename(1) + "\">First</a> &nbsp; " + "<a href=\"" + createFilename(currentPageNumber-1) + "\">Previous</a> &nbsp; "; } if(hasNext) { next = "<a href=\"" + createFilename(currentPageNumber+1) + "\">Next</a>"; } map.put("pageNavigation", prev + next); template = Template.transform(template, map); writer.write(template); writer.close(); writer = null; }
java
private void writeBottom(boolean hasNext) throws IOException { String template = Template.readResourceAsStream("com/btaz/util/templates/html-table-footer.ftl"); Map<String,Object> map = new HashMap<String,Object>(); String prev = " "; String next = ""; if(currentPageNumber > 1) { prev = "<a href=\"" + createFilename(1) + "\">First</a> &nbsp; " + "<a href=\"" + createFilename(currentPageNumber-1) + "\">Previous</a> &nbsp; "; } if(hasNext) { next = "<a href=\"" + createFilename(currentPageNumber+1) + "\">Next</a>"; } map.put("pageNavigation", prev + next); template = Template.transform(template, map); writer.write(template); writer.close(); writer = null; }
[ "private", "void", "writeBottom", "(", "boolean", "hasNext", ")", "throws", "IOException", "{", "String", "template", "=", "Template", ".", "readResourceAsStream", "(", "\"com/btaz/util/templates/html-table-footer.ftl\"", ")", ";", "Map", "<", "String", ",", "Object",...
Write bottom part of the HTML page @param hasNext has next, true if there's supposed to be another page following this one
[ "Write", "bottom", "part", "of", "the", "HTML", "page" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/writer/HtmlTableWriter.java#L171-L188
train
btaz/data-util
src/main/java/com/btaz/util/writer/HtmlTableWriter.java
HtmlTableWriter.close
public void close() throws DataUtilException { // render footer try { if(writer != null) { writeBottom(false); } } catch (IOException e) { throw new DataUtilException("Failed to close the HTML table file", e); } }
java
public void close() throws DataUtilException { // render footer try { if(writer != null) { writeBottom(false); } } catch (IOException e) { throw new DataUtilException("Failed to close the HTML table file", e); } }
[ "public", "void", "close", "(", ")", "throws", "DataUtilException", "{", "// render footer", "try", "{", "if", "(", "writer", "!=", "null", ")", "{", "writeBottom", "(", "false", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", ...
Close the HTML table and resources @throws DataUtilException exception
[ "Close", "the", "HTML", "table", "and", "resources" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/writer/HtmlTableWriter.java#L209-L218
train
sahasbhop/formatted-log
formatted-log/src/main/java/com/github/sahasbhop/flog/FLog.java
FLog.setEnableFileLog
public static void setEnableFileLog(boolean enable, String path, String fileName) { sEnableFileLog = enable; if (enable && path != null && fileName != null) { sLogFilePath = path.trim(); sLogFileName = fileName.trim(); if (!sLogFilePath.endsWith("/")) { sLogFilePath = sLogFilePath + "/"; } } }
java
public static void setEnableFileLog(boolean enable, String path, String fileName) { sEnableFileLog = enable; if (enable && path != null && fileName != null) { sLogFilePath = path.trim(); sLogFileName = fileName.trim(); if (!sLogFilePath.endsWith("/")) { sLogFilePath = sLogFilePath + "/"; } } }
[ "public", "static", "void", "setEnableFileLog", "(", "boolean", "enable", ",", "String", "path", ",", "String", "fileName", ")", "{", "sEnableFileLog", "=", "enable", ";", "if", "(", "enable", "&&", "path", "!=", "null", "&&", "fileName", "!=", "null", ")"...
Enable writing debugging log to a target file @param enable enabling a file log @param path directory path to create and save a log file @param fileName target log file name
[ "Enable", "writing", "debugging", "log", "to", "a", "target", "file" ]
0a3952df6b68fbfa0bbb2c0ea0a8bf9ea26ea6e3
https://github.com/sahasbhop/formatted-log/blob/0a3952df6b68fbfa0bbb2c0ea0a8bf9ea26ea6e3/formatted-log/src/main/java/com/github/sahasbhop/flog/FLog.java#L75-L86
train
btaz/data-util
src/main/java/com/btaz/util/tf/Strings.java
Strings.buildList
public static List<String> buildList(String... args) { List<String> newList = new ArrayList<String>(); Collections.addAll(newList, args); return newList; }
java
public static List<String> buildList(String... args) { List<String> newList = new ArrayList<String>(); Collections.addAll(newList, args); return newList; }
[ "public", "static", "List", "<", "String", ">", "buildList", "(", "String", "...", "args", ")", "{", "List", "<", "String", ">", "newList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "Collections", ".", "addAll", "(", "newList", ",", ...
This method builds a list of string object from a variable argument list as input @param args variable argument list @return {@code List} of {@code String} objects
[ "This", "method", "builds", "a", "list", "of", "string", "object", "from", "a", "variable", "argument", "list", "as", "input" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/tf/Strings.java#L17-L21
train
btaz/data-util
src/main/java/com/btaz/util/tf/Strings.java
Strings.asCommaSeparatedValues
public static String asCommaSeparatedValues(String... args) { List<String> newList = new ArrayList<String>(); Collections.addAll(newList, args); return Strings.asTokenSeparatedValues(",", newList); }
java
public static String asCommaSeparatedValues(String... args) { List<String> newList = new ArrayList<String>(); Collections.addAll(newList, args); return Strings.asTokenSeparatedValues(",", newList); }
[ "public", "static", "String", "asCommaSeparatedValues", "(", "String", "...", "args", ")", "{", "List", "<", "String", ">", "newList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "Collections", ".", "addAll", "(", "newList", ",", "args", ...
This method converts a collection of strings to a comma separated list of strings @param args list of string arguments @return {@code String} new comma separated string
[ "This", "method", "converts", "a", "collection", "of", "strings", "to", "a", "comma", "separated", "list", "of", "strings" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/tf/Strings.java#L37-L41
train
btaz/data-util
src/main/java/com/btaz/util/tf/Strings.java
Strings.asTokenSeparatedValues
public static String asTokenSeparatedValues(String token, Collection<String> strings) { StringBuilder newString = new StringBuilder(); boolean first = true; for(String str : strings) { if(! first) { newString.append(token); } first = false; newString.append(str); } return newString.toString(); }
java
public static String asTokenSeparatedValues(String token, Collection<String> strings) { StringBuilder newString = new StringBuilder(); boolean first = true; for(String str : strings) { if(! first) { newString.append(token); } first = false; newString.append(str); } return newString.toString(); }
[ "public", "static", "String", "asTokenSeparatedValues", "(", "String", "token", ",", "Collection", "<", "String", ">", "strings", ")", "{", "StringBuilder", "newString", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "first", "=", "true", ";", "for", ...
This method converts a collection of strings to a token separated list of strings @param strings Collection of strings @return {@code String} new token separated string
[ "This", "method", "converts", "a", "collection", "of", "strings", "to", "a", "token", "separated", "list", "of", "strings" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/tf/Strings.java#L79-L90
train
passwordmaker/java-passwordmaker-lib
src/main/java/org/daveware/passwordmaker/AccountManager.java
AccountManager.generatePassword
public SecureCharArray generatePassword(CharSequence masterPassword, String inputText) { return generatePassword(masterPassword, inputText, null); }
java
public SecureCharArray generatePassword(CharSequence masterPassword, String inputText) { return generatePassword(masterPassword, inputText, null); }
[ "public", "SecureCharArray", "generatePassword", "(", "CharSequence", "masterPassword", ",", "String", "inputText", ")", "{", "return", "generatePassword", "(", "masterPassword", ",", "inputText", ",", "null", ")", ";", "}" ]
Same as the other version with username being sent null. @param masterPassword master password to use @param inputText the input text @return the generated password @see #generatePassword(CharSequence, String, String)
[ "Same", "as", "the", "other", "version", "with", "username", "being", "sent", "null", "." ]
18c22fca7dd9a47f08161425b85a5bd257afbb2b
https://github.com/passwordmaker/java-passwordmaker-lib/blob/18c22fca7dd9a47f08161425b85a5bd257afbb2b/src/main/java/org/daveware/passwordmaker/AccountManager.java#L71-L73
train
passwordmaker/java-passwordmaker-lib
src/main/java/org/daveware/passwordmaker/AccountManager.java
AccountManager.generatePassword
public SecureUTF8String generatePassword(CharSequence masterPassword, String inputText, String username) { SecureUTF8String securedMasterPassword; if ( ! (masterPassword instanceof SecureUTF8String) ) { securedMasterPassword = new SecureUTF8String(masterPassword.toString()); } else { securedMasterPassword = (SecureUTF8String)masterPassword; } SecureUTF8String result = null; try { Account accountToUse = getAccountForInputText(inputText); // use the one that takes a username if the username isn't null if ( username != null ) result = pwm.makePassword(securedMasterPassword, accountToUse, inputText, username); else result = pwm.makePassword(securedMasterPassword, accountToUse, inputText); } catch (Exception e) { e.printStackTrace(); } if ( result != null ) { return result; } return new SecureUTF8String(); }
java
public SecureUTF8String generatePassword(CharSequence masterPassword, String inputText, String username) { SecureUTF8String securedMasterPassword; if ( ! (masterPassword instanceof SecureUTF8String) ) { securedMasterPassword = new SecureUTF8String(masterPassword.toString()); } else { securedMasterPassword = (SecureUTF8String)masterPassword; } SecureUTF8String result = null; try { Account accountToUse = getAccountForInputText(inputText); // use the one that takes a username if the username isn't null if ( username != null ) result = pwm.makePassword(securedMasterPassword, accountToUse, inputText, username); else result = pwm.makePassword(securedMasterPassword, accountToUse, inputText); } catch (Exception e) { e.printStackTrace(); } if ( result != null ) { return result; } return new SecureUTF8String(); }
[ "public", "SecureUTF8String", "generatePassword", "(", "CharSequence", "masterPassword", ",", "String", "inputText", ",", "String", "username", ")", "{", "SecureUTF8String", "securedMasterPassword", ";", "if", "(", "!", "(", "masterPassword", "instanceof", "SecureUTF8St...
Generate the password based on the masterPassword from the matching account from the inputtext @param masterPassword - the masterpassword to use @param inputText - the input text // url to use to find the account and generate the password @param username - (optional) the username to override the account's username unless its nil @return the generated password based on the matching account
[ "Generate", "the", "password", "based", "on", "the", "masterPassword", "from", "the", "matching", "account", "from", "the", "inputtext" ]
18c22fca7dd9a47f08161425b85a5bd257afbb2b
https://github.com/passwordmaker/java-passwordmaker-lib/blob/18c22fca7dd9a47f08161425b85a5bd257afbb2b/src/main/java/org/daveware/passwordmaker/AccountManager.java#L84-L106
train
passwordmaker/java-passwordmaker-lib
src/main/java/org/daveware/passwordmaker/AccountManager.java
AccountManager.getAccountForInputText
public Account getAccountForInputText(String inputText) { if ( selectedProfile != null ) return selectedProfile; Account account = pwmProfiles.findAccountByUrl(inputText); if ( account == null ) return getDefaultAccount(); return account; }
java
public Account getAccountForInputText(String inputText) { if ( selectedProfile != null ) return selectedProfile; Account account = pwmProfiles.findAccountByUrl(inputText); if ( account == null ) return getDefaultAccount(); return account; }
[ "public", "Account", "getAccountForInputText", "(", "String", "inputText", ")", "{", "if", "(", "selectedProfile", "!=", "null", ")", "return", "selectedProfile", ";", "Account", "account", "=", "pwmProfiles", ".", "findAccountByUrl", "(", "inputText", ")", ";", ...
Public for testing
[ "Public", "for", "testing" ]
18c22fca7dd9a47f08161425b85a5bd257afbb2b
https://github.com/passwordmaker/java-passwordmaker-lib/blob/18c22fca7dd9a47f08161425b85a5bd257afbb2b/src/main/java/org/daveware/passwordmaker/AccountManager.java#L109-L114
train
passwordmaker/java-passwordmaker-lib
src/main/java/org/daveware/passwordmaker/AccountManager.java
AccountManager.decodeFavoritesUrls
public void decodeFavoritesUrls(String encodedUrlList, boolean clearFirst) { int start = 0; int end = encodedUrlList.length(); if ( encodedUrlList.startsWith("<") ) start++; if ( encodedUrlList.endsWith(">") ) end--; encodedUrlList = encodedUrlList.substring(start, end); if ( clearFirst ) favoriteUrls.clear(); for (String url : Splitter.on(">,<").omitEmptyStrings().split(encodedUrlList) ) { favoriteUrls.add(url); } }
java
public void decodeFavoritesUrls(String encodedUrlList, boolean clearFirst) { int start = 0; int end = encodedUrlList.length(); if ( encodedUrlList.startsWith("<") ) start++; if ( encodedUrlList.endsWith(">") ) end--; encodedUrlList = encodedUrlList.substring(start, end); if ( clearFirst ) favoriteUrls.clear(); for (String url : Splitter.on(">,<").omitEmptyStrings().split(encodedUrlList) ) { favoriteUrls.add(url); } }
[ "public", "void", "decodeFavoritesUrls", "(", "String", "encodedUrlList", ",", "boolean", "clearFirst", ")", "{", "int", "start", "=", "0", ";", "int", "end", "=", "encodedUrlList", ".", "length", "(", ")", ";", "if", "(", "encodedUrlList", ".", "startsWith"...
Decodes a list of favorites urls from a series of &lt;url1&gt;,&lt;url2&gt;... Will then put them into the list of favorites, optionally clearing first @param encodedUrlList - String encoded version of the list @param clearFirst - clear the list of favorites first
[ "Decodes", "a", "list", "of", "favorites", "urls", "from", "a", "series", "of", "&lt", ";", "url1&gt", ";", "&lt", ";", "url2&gt", ";", "..." ]
18c22fca7dd9a47f08161425b85a5bd257afbb2b
https://github.com/passwordmaker/java-passwordmaker-lib/blob/18c22fca7dd9a47f08161425b85a5bd257afbb2b/src/main/java/org/daveware/passwordmaker/AccountManager.java#L232-L242
train
passwordmaker/java-passwordmaker-lib
src/main/java/org/daveware/passwordmaker/AccountManager.java
AccountManager.setCurrentPasswordHashPassword
public void setCurrentPasswordHashPassword(String newPassword) { this.passwordSalt = UUID.randomUUID().toString(); try { this.currentPasswordHash = pwm.makePassword(new SecureUTF8String(newPassword), masterPwdHashAccount, getPasswordSalt()); } catch (Exception ignored) {} setStorePasswordHash(true); }
java
public void setCurrentPasswordHashPassword(String newPassword) { this.passwordSalt = UUID.randomUUID().toString(); try { this.currentPasswordHash = pwm.makePassword(new SecureUTF8String(newPassword), masterPwdHashAccount, getPasswordSalt()); } catch (Exception ignored) {} setStorePasswordHash(true); }
[ "public", "void", "setCurrentPasswordHashPassword", "(", "String", "newPassword", ")", "{", "this", ".", "passwordSalt", "=", "UUID", ".", "randomUUID", "(", ")", ".", "toString", "(", ")", ";", "try", "{", "this", ".", "currentPasswordHash", "=", "pwm", "."...
This will salt and hash the password to store @param newPassword - the new password
[ "This", "will", "salt", "and", "hash", "the", "password", "to", "store" ]
18c22fca7dd9a47f08161425b85a5bd257afbb2b
https://github.com/passwordmaker/java-passwordmaker-lib/blob/18c22fca7dd9a47f08161425b85a5bd257afbb2b/src/main/java/org/daveware/passwordmaker/AccountManager.java#L272-L280
train
eyp/serfj
src/main/java/net/sf/serfj/UrlInspector.java
UrlInspector.isMainId
private Boolean isMainId(String id, String resource, String lastElement) { Boolean isMainId = false; if (id == null) { if (!utils.singularize(utils.cleanURL(lastElement)).equals(resource) && resource == null) { isMainId = true; } } return isMainId; }
java
private Boolean isMainId(String id, String resource, String lastElement) { Boolean isMainId = false; if (id == null) { if (!utils.singularize(utils.cleanURL(lastElement)).equals(resource) && resource == null) { isMainId = true; } } return isMainId; }
[ "private", "Boolean", "isMainId", "(", "String", "id", ",", "String", "resource", ",", "String", "lastElement", ")", "{", "Boolean", "isMainId", "=", "false", ";", "if", "(", "id", "==", "null", ")", "{", "if", "(", "!", "utils", ".", "singularize", "(...
Checks if is the main id, or it is a secondary id. @param id Current id. @param resource Current resource. @param lastElement Last element of the URL. @return true if is the main id, false otherwise.
[ "Checks", "if", "is", "the", "main", "id", "or", "it", "is", "a", "secondary", "id", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/UrlInspector.java#L117-L125
train
eyp/serfj
src/main/java/net/sf/serfj/UrlInspector.java
UrlInspector.isResource
Boolean isResource(String resource) { Boolean isResource = false; if (!utils.isIdentifier(resource)) { try { String clazz = getControllerClass(resource); if (clazz != null) { Class.forName(clazz); isResource = true; } } catch (ClassNotFoundException e) { // It isn't a resource because there isn't a controller for it } } return isResource; }
java
Boolean isResource(String resource) { Boolean isResource = false; if (!utils.isIdentifier(resource)) { try { String clazz = getControllerClass(resource); if (clazz != null) { Class.forName(clazz); isResource = true; } } catch (ClassNotFoundException e) { // It isn't a resource because there isn't a controller for it } } return isResource; }
[ "Boolean", "isResource", "(", "String", "resource", ")", "{", "Boolean", "isResource", "=", "false", ";", "if", "(", "!", "utils", ".", "isIdentifier", "(", "resource", ")", ")", "{", "try", "{", "String", "clazz", "=", "getControllerClass", "(", "resource...
Checks if a string represents a resource or not. If there is a class which could be instantiated then is a resource, elsewhere it isn't @param resource String that coulb be a resource. @return true if chunk is a resource.
[ "Checks", "if", "a", "string", "represents", "a", "resource", "or", "not", ".", "If", "there", "is", "a", "class", "which", "could", "be", "instantiated", "then", "is", "a", "resource", "elsewhere", "it", "isn", "t" ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/UrlInspector.java#L192-L206
train
eyp/serfj
src/main/java/net/sf/serfj/UrlInspector.java
UrlInspector.getControllerClass
String getControllerClass(String resource) { ControllerFinder finder = new ControllerFinder(config); String controllerClass = finder.findResource(resource); LOGGER.debug("Controller class: {}", controllerClass); return controllerClass; }
java
String getControllerClass(String resource) { ControllerFinder finder = new ControllerFinder(config); String controllerClass = finder.findResource(resource); LOGGER.debug("Controller class: {}", controllerClass); return controllerClass; }
[ "String", "getControllerClass", "(", "String", "resource", ")", "{", "ControllerFinder", "finder", "=", "new", "ControllerFinder", "(", "config", ")", ";", "String", "controllerClass", "=", "finder", ".", "findResource", "(", "resource", ")", ";", "LOGGER", ".",...
Gets controller class for a resource. @param resource Resource that will managed by the controller class. @return The fully qualified name of the controller class for this resource and extension.
[ "Gets", "controller", "class", "for", "a", "resource", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/UrlInspector.java#L216-L221
train
eyp/serfj
src/main/java/net/sf/serfj/UrlInspector.java
UrlInspector.getSerializerClass
protected String getSerializerClass(String resource, String urlLastElement) { String serializerClass = null; String extension = this.utils.getExtension(urlLastElement); if (extension != null) { SerializerFinder finder = new SerializerFinder(config, extension); serializerClass = finder.findResource(resource); } return serializerClass; }
java
protected String getSerializerClass(String resource, String urlLastElement) { String serializerClass = null; String extension = this.utils.getExtension(urlLastElement); if (extension != null) { SerializerFinder finder = new SerializerFinder(config, extension); serializerClass = finder.findResource(resource); } return serializerClass; }
[ "protected", "String", "getSerializerClass", "(", "String", "resource", ",", "String", "urlLastElement", ")", "{", "String", "serializerClass", "=", "null", ";", "String", "extension", "=", "this", ".", "utils", ".", "getExtension", "(", "urlLastElement", ")", "...
Gets serializer class for a resource. If the last part of the URL has an extension, then could be a Serializer class to render the result in a specific way. If the extension is .xml it hopes that a ResourceNameXmlSerializer exists to render the resource as Xml. The extension can be anything. @param resource Resource that will managed by the controller class. @param urlLastElement Last element of the URL analyzed. @return The fully qualified name of the serializer class for this resource and extension.
[ "Gets", "serializer", "class", "for", "a", "resource", ".", "If", "the", "last", "part", "of", "the", "URL", "has", "an", "extension", "then", "could", "be", "a", "Serializer", "class", "to", "render", "the", "result", "in", "a", "specific", "way", ".", ...
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/UrlInspector.java#L237-L245
train
btaz/data-util
src/main/java/com/btaz/util/files/FileCat.java
FileCat.concatenate
public static void concatenate(List<File> files, File concatenatedFile) { BufferedWriter writer; try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(concatenatedFile.getAbsoluteFile(), false), DataUtilDefaults.charSet)); FileInputStream inputStream; for(File input : files) { inputStream = new FileInputStream(input); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); String line; while((line = reader.readLine()) != null) { writer.write(line + DataUtilDefaults.lineTerminator); } inputStream.close(); } writer.flush(); writer.close(); } catch (UnsupportedEncodingException e) { throw new DataUtilException(e); } catch (FileNotFoundException e) { throw new DataUtilException(e); } catch (IOException e) { throw new DataUtilException(e); } }
java
public static void concatenate(List<File> files, File concatenatedFile) { BufferedWriter writer; try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(concatenatedFile.getAbsoluteFile(), false), DataUtilDefaults.charSet)); FileInputStream inputStream; for(File input : files) { inputStream = new FileInputStream(input); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); String line; while((line = reader.readLine()) != null) { writer.write(line + DataUtilDefaults.lineTerminator); } inputStream.close(); } writer.flush(); writer.close(); } catch (UnsupportedEncodingException e) { throw new DataUtilException(e); } catch (FileNotFoundException e) { throw new DataUtilException(e); } catch (IOException e) { throw new DataUtilException(e); } }
[ "public", "static", "void", "concatenate", "(", "List", "<", "File", ">", "files", ",", "File", "concatenatedFile", ")", "{", "BufferedWriter", "writer", ";", "try", "{", "writer", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "new", "...
This method will concatenate one or more files @param files files to concatenate @param concatenatedFile concatenated output file
[ "This", "method", "will", "concatenate", "one", "or", "more", "files" ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/files/FileCat.java#L18-L44
train
Teddy-Zhu/SilentGo
framework/src/main/java/com/silentgo/servlet/http/HttpStatus.java
HttpStatus.getMessage
public static String getMessage(int code) { Code codeEnum = getCode(code); if (codeEnum != null) { return codeEnum.getMessage(); } else { return Integer.toString(code); } }
java
public static String getMessage(int code) { Code codeEnum = getCode(code); if (codeEnum != null) { return codeEnum.getMessage(); } else { return Integer.toString(code); } }
[ "public", "static", "String", "getMessage", "(", "int", "code", ")", "{", "Code", "codeEnum", "=", "getCode", "(", "code", ")", ";", "if", "(", "codeEnum", "!=", "null", ")", "{", "return", "codeEnum", ".", "getMessage", "(", ")", ";", "}", "else", "...
Get the status message for a specific code. @param code the code to look up @return the specific message, or the code number itself if code does not match known list.
[ "Get", "the", "status", "message", "for", "a", "specific", "code", "." ]
27f58b0cafe56b2eb9fc6993efa9ca2b529661e1
https://github.com/Teddy-Zhu/SilentGo/blob/27f58b0cafe56b2eb9fc6993efa9ca2b529661e1/framework/src/main/java/com/silentgo/servlet/http/HttpStatus.java#L342-L353
train
passwordmaker/java-passwordmaker-lib
src/main/java/org/daveware/passwordmaker/AlgorithmType.java
AlgorithmType.fromRdfString
public static Pair<AlgorithmType, Boolean> fromRdfString(String str, boolean convert) throws IncompatibleException { // default if (str.length() == 0) return pair(MD5, true); // Search the list of registered algorithms for (AlgorithmType algoType : TYPES) { String name = algoType.rdfName.toLowerCase(); String hmacName = algoType.rdfHmacName.toLowerCase(); if (str.compareTo(name) == 0 || str.compareTo(hmacName) == 0) return pair(algoType, true); } if (str.compareTo("md5-v0.6") == 0 || str.compareTo("hmac-md5-v0.6") == 0) return pair(AlgorithmType.MD5, false); // TODO: full support for all invalid types should be present as well as allowing the account to exist and be modified. if ( convert && str.compareTo("hmac-sha256") == 0) { return pair(AlgorithmType.SHA256, true); } if (str.compareTo("hmac-sha256") == 0) throw new IncompatibleException("Original hmac-sha256-v1.5.1 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"HMAC-SHA256\" in the PasswordMaker settings."); if (str.compareTo("md5-v0.6") == 0) throw new IncompatibleException("Original md5-v0.6 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"MD5\" in the PasswordMaker settings."); if (str.compareTo("hmac-md5-v0.6") == 0) throw new IncompatibleException("Original hmac-md5-v0.6 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"HMAC-MD5\" in the PasswordMaker settings."); throw new IncompatibleException(String.format("Invalid algorithm type '%1s'", str)); }
java
public static Pair<AlgorithmType, Boolean> fromRdfString(String str, boolean convert) throws IncompatibleException { // default if (str.length() == 0) return pair(MD5, true); // Search the list of registered algorithms for (AlgorithmType algoType : TYPES) { String name = algoType.rdfName.toLowerCase(); String hmacName = algoType.rdfHmacName.toLowerCase(); if (str.compareTo(name) == 0 || str.compareTo(hmacName) == 0) return pair(algoType, true); } if (str.compareTo("md5-v0.6") == 0 || str.compareTo("hmac-md5-v0.6") == 0) return pair(AlgorithmType.MD5, false); // TODO: full support for all invalid types should be present as well as allowing the account to exist and be modified. if ( convert && str.compareTo("hmac-sha256") == 0) { return pair(AlgorithmType.SHA256, true); } if (str.compareTo("hmac-sha256") == 0) throw new IncompatibleException("Original hmac-sha256-v1.5.1 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"HMAC-SHA256\" in the PasswordMaker settings."); if (str.compareTo("md5-v0.6") == 0) throw new IncompatibleException("Original md5-v0.6 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"MD5\" in the PasswordMaker settings."); if (str.compareTo("hmac-md5-v0.6") == 0) throw new IncompatibleException("Original hmac-md5-v0.6 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"HMAC-MD5\" in the PasswordMaker settings."); throw new IncompatibleException(String.format("Invalid algorithm type '%1s'", str)); }
[ "public", "static", "Pair", "<", "AlgorithmType", ",", "Boolean", ">", "fromRdfString", "(", "String", "str", ",", "boolean", "convert", ")", "throws", "IncompatibleException", "{", "// default", "if", "(", "str", ".", "length", "(", ")", "==", "0", ")", "...
Converts a string to an algorithm type. @param str The algorithm type. Valid values are: md4, md5, sha1, sha256, rmd160. Any of those valid types can be prefixed with "hmac-". @param convert - if the broken version of sha256 is found, just replace with non-broken version, instead of throwing @return The algorithm type. @throws IncompatibleException upon invalid algorithm string.
[ "Converts", "a", "string", "to", "an", "algorithm", "type", "." ]
18c22fca7dd9a47f08161425b85a5bd257afbb2b
https://github.com/passwordmaker/java-passwordmaker-lib/blob/18c22fca7dd9a47f08161425b85a5bd257afbb2b/src/main/java/org/daveware/passwordmaker/AlgorithmType.java#L88-L128
train
pierre/ning-service-skeleton
jdbi/src/main/java/com/ning/jetty/jdbi/log/Slf4jLogging.java
Slf4jLogging.log
@Override protected void log(final String msg) { if (config.getLogLevel().equals(LogLevel.DEBUG)) { logger.debug(msg); } else if (config.getLogLevel().equals(LogLevel.TRACE)) { logger.trace(msg); } else if (config.getLogLevel().equals(LogLevel.INFO)) { logger.info(msg); } else if (config.getLogLevel().equals(LogLevel.WARN)) { logger.warn(msg); } else if (config.getLogLevel().equals(LogLevel.ERROR)) { logger.error(msg); } }
java
@Override protected void log(final String msg) { if (config.getLogLevel().equals(LogLevel.DEBUG)) { logger.debug(msg); } else if (config.getLogLevel().equals(LogLevel.TRACE)) { logger.trace(msg); } else if (config.getLogLevel().equals(LogLevel.INFO)) { logger.info(msg); } else if (config.getLogLevel().equals(LogLevel.WARN)) { logger.warn(msg); } else if (config.getLogLevel().equals(LogLevel.ERROR)) { logger.error(msg); } }
[ "@", "Override", "protected", "void", "log", "(", "final", "String", "msg", ")", "{", "if", "(", "config", ".", "getLogLevel", "(", ")", ".", "equals", "(", "LogLevel", ".", "DEBUG", ")", ")", "{", "logger", ".", "debug", "(", "msg", ")", ";", "}",...
Log the statement passed in @param msg the message to log
[ "Log", "the", "statement", "passed", "in" ]
766369c8c975d262ede212e81d89b65c589090b7
https://github.com/pierre/ning-service-skeleton/blob/766369c8c975d262ede212e81d89b65c589090b7/jdbi/src/main/java/com/ning/jetty/jdbi/log/Slf4jLogging.java#L53-L66
train
eyp/serfj
src/main/java/net/sf/serfj/client/Client.java
Client.getRequest
public Object getRequest(String restUrl, Map<String, String> params) throws IOException, WebServiceException { HttpURLConnection conn = null; try { // Make the URL urlString = new StringBuilder(this.host).append(restUrl); urlString.append(this.makeParamsString(params, true)); LOGGER.debug("Doing HTTP request: GET [{}]", urlString.toString()); // Connection configuration // Proxy proxy = DEBUG_HTTP ? new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8008)) : Proxy.NO_PROXY; URL url = new URL(urlString.toString()); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(HttpMethod.GET.name()); conn.setRequestProperty("Connection", "Keep-Alive"); // Gets the response return this.readResponse(restUrl, conn); } catch (WebServiceException e) { LOGGER.debug("WebServiceException catched. Request error", e); throw e; } catch (IOException e) { LOGGER.debug("IOException catched. Request error", e); throw e; } catch (Exception e) { LOGGER.debug("Exception catched, throwing a new IOException. Request error", e); throw new IOException(e.getLocalizedMessage()); } finally { if (conn != null) { conn.disconnect(); } } }
java
public Object getRequest(String restUrl, Map<String, String> params) throws IOException, WebServiceException { HttpURLConnection conn = null; try { // Make the URL urlString = new StringBuilder(this.host).append(restUrl); urlString.append(this.makeParamsString(params, true)); LOGGER.debug("Doing HTTP request: GET [{}]", urlString.toString()); // Connection configuration // Proxy proxy = DEBUG_HTTP ? new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8008)) : Proxy.NO_PROXY; URL url = new URL(urlString.toString()); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(HttpMethod.GET.name()); conn.setRequestProperty("Connection", "Keep-Alive"); // Gets the response return this.readResponse(restUrl, conn); } catch (WebServiceException e) { LOGGER.debug("WebServiceException catched. Request error", e); throw e; } catch (IOException e) { LOGGER.debug("IOException catched. Request error", e); throw e; } catch (Exception e) { LOGGER.debug("Exception catched, throwing a new IOException. Request error", e); throw new IOException(e.getLocalizedMessage()); } finally { if (conn != null) { conn.disconnect(); } } }
[ "public", "Object", "getRequest", "(", "String", "restUrl", ",", "Map", "<", "String", ",", "String", ">", "params", ")", "throws", "IOException", ",", "WebServiceException", "{", "HttpURLConnection", "conn", "=", "null", ";", "try", "{", "// Make the URL", "u...
Do a GET HTTP request to the given REST-URL. @param restUrl REST URL. @param params Parameters for adding to the query string. @throws IOException if the request go bad.
[ "Do", "a", "GET", "HTTP", "request", "to", "the", "given", "REST", "-", "URL", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/client/Client.java#L88-L118
train
eyp/serfj
src/main/java/net/sf/serfj/client/Client.java
Client.putRequest
public Object putRequest(String restUrl, Map<String, String> params) throws IOException, WebServiceException { return this.postRequest(HttpMethod.PUT, restUrl, params); }
java
public Object putRequest(String restUrl, Map<String, String> params) throws IOException, WebServiceException { return this.postRequest(HttpMethod.PUT, restUrl, params); }
[ "public", "Object", "putRequest", "(", "String", "restUrl", ",", "Map", "<", "String", ",", "String", ">", "params", ")", "throws", "IOException", ",", "WebServiceException", "{", "return", "this", ".", "postRequest", "(", "HttpMethod", ".", "PUT", ",", "res...
Do a PUT HTTP request to the given REST-URL. @param restUrl REST URL. @param params Parameters for adding to the query string. @throws IOException if the request go bad.
[ "Do", "a", "PUT", "HTTP", "request", "to", "the", "given", "REST", "-", "URL", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/client/Client.java#L144-L146
train
eyp/serfj
src/main/java/net/sf/serfj/client/Client.java
Client.deleteRequest
public Object deleteRequest(String restUrl, Map<String, String> params) throws IOException, WebServiceException { return this.postRequest(HttpMethod.DELETE, restUrl, params); }
java
public Object deleteRequest(String restUrl, Map<String, String> params) throws IOException, WebServiceException { return this.postRequest(HttpMethod.DELETE, restUrl, params); }
[ "public", "Object", "deleteRequest", "(", "String", "restUrl", ",", "Map", "<", "String", ",", "String", ">", "params", ")", "throws", "IOException", ",", "WebServiceException", "{", "return", "this", ".", "postRequest", "(", "HttpMethod", ".", "DELETE", ",", ...
Do a DELETE HTTP request to the given REST-URL. @param restUrl REST URL. @param params Parameters for adding to the query string. @throws IOException if the request go bad.
[ "Do", "a", "DELETE", "HTTP", "request", "to", "the", "given", "REST", "-", "URL", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/client/Client.java#L158-L160
train
eyp/serfj
src/main/java/net/sf/serfj/client/Client.java
Client.makeParamsString
private String makeParamsString(Map<String, String> params, boolean isGet) { StringBuilder url = new StringBuilder(); if (params != null) { boolean first = true; for (Map.Entry<String, String> entry : params.entrySet()) { if (first) { if (isGet) { url.append("?"); } first = false; } else { url.append("&"); } try { // Hay que codificar los valores de los parametros para que // las llamadas REST se hagan correctamente if (entry.getValue() != null) { url.append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue(), CHARSET)); } else { LOGGER.debug("WARN - Param {} is null", entry.getKey()); url.append(entry.getKey()).append("=").append(""); } } catch (UnsupportedEncodingException ex) { // Esta excepcion saltaria si la codificacion no estuviese // soportada, pero UTF-8 siempre esta soportada. LOGGER.error(ex.getLocalizedMessage()); } } } return url.toString(); }
java
private String makeParamsString(Map<String, String> params, boolean isGet) { StringBuilder url = new StringBuilder(); if (params != null) { boolean first = true; for (Map.Entry<String, String> entry : params.entrySet()) { if (first) { if (isGet) { url.append("?"); } first = false; } else { url.append("&"); } try { // Hay que codificar los valores de los parametros para que // las llamadas REST se hagan correctamente if (entry.getValue() != null) { url.append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue(), CHARSET)); } else { LOGGER.debug("WARN - Param {} is null", entry.getKey()); url.append(entry.getKey()).append("=").append(""); } } catch (UnsupportedEncodingException ex) { // Esta excepcion saltaria si la codificacion no estuviese // soportada, pero UTF-8 siempre esta soportada. LOGGER.error(ex.getLocalizedMessage()); } } } return url.toString(); }
[ "private", "String", "makeParamsString", "(", "Map", "<", "String", ",", "String", ">", "params", ",", "boolean", "isGet", ")", "{", "StringBuilder", "url", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "params", "!=", "null", ")", "{", "boolean...
Adds params to a query string. It will encode params' values to not get errors in the connection. @param params Parameters and their values. @param isGet Indicates a GET request. A GET request has to mark the first parameter with the '?' symbol. In a POST request it doesn't have to do it. @return a string with the parameters. This string can be appended to a query string, or written to an OutputStream.
[ "Adds", "params", "to", "a", "query", "string", ".", "It", "will", "encode", "params", "values", "to", "not", "get", "errors", "in", "the", "connection", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/client/Client.java#L281-L311
train
eyp/serfj
src/main/java/net/sf/serfj/client/Client.java
Client.deserialize
private Object deserialize(String serializedObject, String extension) throws IOException { LOGGER.debug("Deserializing object [{}] to [{}]", serializedObject, extension); SerializerFinder finder = new SerializerFinder(extension); String serializerClass = finder.findResource(null); if (serializerClass == null) { LOGGER.warn("Serializer not found for extension [{}]", extension); return null; } else { try { LOGGER.debug("Deserializing using {}", serializerClass); Class<?> clazz = Class.forName(serializerClass); Method deserializeMethod = clazz.getMethod("deserialize", new Class[] { String.class }); LOGGER.debug("Calling {}.deserialize", serializerClass); return deserializeMethod.invoke(clazz.newInstance(), serializedObject); } catch (Exception e) { LOGGER.debug(e.getLocalizedMessage(), e); LOGGER.debug("Can't deserialize object with {} serializer", serializerClass); throw new IOException(e.getLocalizedMessage()); } } }
java
private Object deserialize(String serializedObject, String extension) throws IOException { LOGGER.debug("Deserializing object [{}] to [{}]", serializedObject, extension); SerializerFinder finder = new SerializerFinder(extension); String serializerClass = finder.findResource(null); if (serializerClass == null) { LOGGER.warn("Serializer not found for extension [{}]", extension); return null; } else { try { LOGGER.debug("Deserializing using {}", serializerClass); Class<?> clazz = Class.forName(serializerClass); Method deserializeMethod = clazz.getMethod("deserialize", new Class[] { String.class }); LOGGER.debug("Calling {}.deserialize", serializerClass); return deserializeMethod.invoke(clazz.newInstance(), serializedObject); } catch (Exception e) { LOGGER.debug(e.getLocalizedMessage(), e); LOGGER.debug("Can't deserialize object with {} serializer", serializerClass); throw new IOException(e.getLocalizedMessage()); } } }
[ "private", "Object", "deserialize", "(", "String", "serializedObject", ",", "String", "extension", ")", "throws", "IOException", "{", "LOGGER", ".", "debug", "(", "\"Deserializing object [{}] to [{}]\"", ",", "serializedObject", ",", "extension", ")", ";", "Serializer...
Deserializes a serialized object that came within the response after a REST call. @param serializedObject Serialized object. @param extension URL's extension (json, 64, xml, etc...). @return a deserialized object. @throws IOException if object can't be deserialized.
[ "Deserializes", "a", "serialized", "object", "that", "came", "within", "the", "response", "after", "a", "REST", "call", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/client/Client.java#L325-L345
train
fcrepo4-labs/fcrepo4-client
fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java
HttpHelper.execute
public HttpResponse execute( final HttpUriRequest request ) throws IOException, ReadOnlyException { if ( readOnly ) { switch ( request.getMethod().toLowerCase() ) { case "copy": case "delete": case "move": case "patch": case "post": case "put": throw new ReadOnlyException(); default: break; } } return httpClient.execute(request, httpContext); }
java
public HttpResponse execute( final HttpUriRequest request ) throws IOException, ReadOnlyException { if ( readOnly ) { switch ( request.getMethod().toLowerCase() ) { case "copy": case "delete": case "move": case "patch": case "post": case "put": throw new ReadOnlyException(); default: break; } } return httpClient.execute(request, httpContext); }
[ "public", "HttpResponse", "execute", "(", "final", "HttpUriRequest", "request", ")", "throws", "IOException", ",", "ReadOnlyException", "{", "if", "(", "readOnly", ")", "{", "switch", "(", "request", ".", "getMethod", "(", ")", ".", "toLowerCase", "(", ")", ...
Execute a request for a subclass. @param request request to be executed @return response containing response to request @throws IOException @throws ReadOnlyException
[ "Execute", "a", "request", "for", "a", "subclass", "." ]
21eaf27200c5b2542095f6ebb9dd8ec865b95bbd
https://github.com/fcrepo4-labs/fcrepo4-client/blob/21eaf27200c5b2542095f6ebb9dd8ec865b95bbd/fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java#L173-L184
train
fcrepo4-labs/fcrepo4-client
fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java
HttpHelper.queryString
private static String queryString( final Map<String, List<String>> params ) { final StringBuilder builder = new StringBuilder(); if (params != null && params.size() > 0) { for (final Iterator<String> it = params.keySet().iterator(); it.hasNext(); ) { final String key = it.next(); final List<String> values = params.get(key); for (final String value : values) { try { builder.append(key + "=" + URLEncoder.encode(value, "UTF-8") + "&"); } catch (final UnsupportedEncodingException e) { builder.append(key + "=" + value + "&"); } } } return builder.length() > 0 ? "?" + builder.substring(0, builder.length() - 1) : ""; } return ""; }
java
private static String queryString( final Map<String, List<String>> params ) { final StringBuilder builder = new StringBuilder(); if (params != null && params.size() > 0) { for (final Iterator<String> it = params.keySet().iterator(); it.hasNext(); ) { final String key = it.next(); final List<String> values = params.get(key); for (final String value : values) { try { builder.append(key + "=" + URLEncoder.encode(value, "UTF-8") + "&"); } catch (final UnsupportedEncodingException e) { builder.append(key + "=" + value + "&"); } } } return builder.length() > 0 ? "?" + builder.substring(0, builder.length() - 1) : ""; } return ""; }
[ "private", "static", "String", "queryString", "(", "final", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "params", ")", "{", "final", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "params", "!=", "null"...
Encode URL parameters as a query string. @param params Query parameters
[ "Encode", "URL", "parameters", "as", "a", "query", "string", "." ]
21eaf27200c5b2542095f6ebb9dd8ec865b95bbd
https://github.com/fcrepo4-labs/fcrepo4-client/blob/21eaf27200c5b2542095f6ebb9dd8ec865b95bbd/fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java#L190-L207
train
fcrepo4-labs/fcrepo4-client
fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java
HttpHelper.createGetMethod
public HttpGet createGetMethod(final String path, final Map<String, List<String>> params) { return new HttpGet(repositoryURL + path + queryString(params)); }
java
public HttpGet createGetMethod(final String path, final Map<String, List<String>> params) { return new HttpGet(repositoryURL + path + queryString(params)); }
[ "public", "HttpGet", "createGetMethod", "(", "final", "String", "path", ",", "final", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "params", ")", "{", "return", "new", "HttpGet", "(", "repositoryURL", "+", "path", "+", "queryString", "(", ...
Create GET method with list of parameters @param path Resource path, relative to repository baseURL @param params Query parameters @return GET method
[ "Create", "GET", "method", "with", "list", "of", "parameters" ]
21eaf27200c5b2542095f6ebb9dd8ec865b95bbd
https://github.com/fcrepo4-labs/fcrepo4-client/blob/21eaf27200c5b2542095f6ebb9dd8ec865b95bbd/fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java#L224-L226
train
fcrepo4-labs/fcrepo4-client
fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java
HttpHelper.createPatchMethod
public HttpPatch createPatchMethod(final String path, final String sparqlUpdate) throws FedoraException { if ( isBlank(sparqlUpdate) ) { throw new FedoraException("SPARQL Update command must not be blank"); } final HttpPatch patch = new HttpPatch(repositoryURL + path); patch.setEntity( new ByteArrayEntity(sparqlUpdate.getBytes()) ); patch.setHeader("Content-Type", contentTypeSPARQLUpdate); return patch; }
java
public HttpPatch createPatchMethod(final String path, final String sparqlUpdate) throws FedoraException { if ( isBlank(sparqlUpdate) ) { throw new FedoraException("SPARQL Update command must not be blank"); } final HttpPatch patch = new HttpPatch(repositoryURL + path); patch.setEntity( new ByteArrayEntity(sparqlUpdate.getBytes()) ); patch.setHeader("Content-Type", contentTypeSPARQLUpdate); return patch; }
[ "public", "HttpPatch", "createPatchMethod", "(", "final", "String", "path", ",", "final", "String", "sparqlUpdate", ")", "throws", "FedoraException", "{", "if", "(", "isBlank", "(", "sparqlUpdate", ")", ")", "{", "throw", "new", "FedoraException", "(", "\"SPARQL...
Create a request to update triples with SPARQL Update. @param path The datastream path. @param sparqlUpdate SPARQL Update command. @return created patch based on parameters @throws FedoraException
[ "Create", "a", "request", "to", "update", "triples", "with", "SPARQL", "Update", "." ]
21eaf27200c5b2542095f6ebb9dd8ec865b95bbd
https://github.com/fcrepo4-labs/fcrepo4-client/blob/21eaf27200c5b2542095f6ebb9dd8ec865b95bbd/fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java#L244-L253
train
fcrepo4-labs/fcrepo4-client
fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java
HttpHelper.createPostMethod
public HttpPost createPostMethod(final String path, final Map<String, List<String>> params) { return new HttpPost(repositoryURL + path + queryString(params)); }
java
public HttpPost createPostMethod(final String path, final Map<String, List<String>> params) { return new HttpPost(repositoryURL + path + queryString(params)); }
[ "public", "HttpPost", "createPostMethod", "(", "final", "String", "path", ",", "final", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "params", ")", "{", "return", "new", "HttpPost", "(", "repositoryURL", "+", "path", "+", "queryString", "(",...
Create POST method with list of parameters @param path Resource path, relative to repository baseURL @param params Query parameters @return PUT method
[ "Create", "POST", "method", "with", "list", "of", "parameters" ]
21eaf27200c5b2542095f6ebb9dd8ec865b95bbd
https://github.com/fcrepo4-labs/fcrepo4-client/blob/21eaf27200c5b2542095f6ebb9dd8ec865b95bbd/fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java#L261-L263
train
fcrepo4-labs/fcrepo4-client
fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java
HttpHelper.createPutMethod
public HttpPut createPutMethod(final String path, final Map<String, List<String>> params) { return new HttpPut(repositoryURL + path + queryString(params)); }
java
public HttpPut createPutMethod(final String path, final Map<String, List<String>> params) { return new HttpPut(repositoryURL + path + queryString(params)); }
[ "public", "HttpPut", "createPutMethod", "(", "final", "String", "path", ",", "final", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "params", ")", "{", "return", "new", "HttpPut", "(", "repositoryURL", "+", "path", "+", "queryString", "(", ...
Create PUT method with list of parameters @param path Resource path, relative to repository baseURL @param params Query parameters @return PUT method
[ "Create", "PUT", "method", "with", "list", "of", "parameters" ]
21eaf27200c5b2542095f6ebb9dd8ec865b95bbd
https://github.com/fcrepo4-labs/fcrepo4-client/blob/21eaf27200c5b2542095f6ebb9dd8ec865b95bbd/fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java#L271-L273
train
fcrepo4-labs/fcrepo4-client
fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java
HttpHelper.createTriplesPutMethod
public HttpPut createTriplesPutMethod(final String path, final InputStream updatedProperties, final String contentType) throws FedoraException { if ( updatedProperties == null ) { throw new FedoraException("updatedProperties must not be null"); } else if ( isBlank(contentType) ) { throw new FedoraException("contentType must not be blank"); } final HttpPut put = new HttpPut(repositoryURL + path); put.setEntity( new InputStreamEntity(updatedProperties) ); put.setHeader("Content-Type", contentType); return put; }
java
public HttpPut createTriplesPutMethod(final String path, final InputStream updatedProperties, final String contentType) throws FedoraException { if ( updatedProperties == null ) { throw new FedoraException("updatedProperties must not be null"); } else if ( isBlank(contentType) ) { throw new FedoraException("contentType must not be blank"); } final HttpPut put = new HttpPut(repositoryURL + path); put.setEntity( new InputStreamEntity(updatedProperties) ); put.setHeader("Content-Type", contentType); return put; }
[ "public", "HttpPut", "createTriplesPutMethod", "(", "final", "String", "path", ",", "final", "InputStream", "updatedProperties", ",", "final", "String", "contentType", ")", "throws", "FedoraException", "{", "if", "(", "updatedProperties", "==", "null", ")", "{", "...
Create a request to update triples. @param path The datastream path. @param updatedProperties InputStream containing RDF. @param contentType Content type of the RDF in updatedProperties (e.g., "text/rdf+n3" or "application/rdf+xml"). @return PUT method @throws FedoraException
[ "Create", "a", "request", "to", "update", "triples", "." ]
21eaf27200c5b2542095f6ebb9dd8ec865b95bbd
https://github.com/fcrepo4-labs/fcrepo4-client/blob/21eaf27200c5b2542095f6ebb9dd8ec865b95bbd/fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java#L318-L330
train
fcrepo4-labs/fcrepo4-client
fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java
HttpHelper.createCopyMethod
public HttpCopy createCopyMethod(final String sourcePath, final String destinationPath) { return new HttpCopy(repositoryURL + sourcePath, repositoryURL + destinationPath); }
java
public HttpCopy createCopyMethod(final String sourcePath, final String destinationPath) { return new HttpCopy(repositoryURL + sourcePath, repositoryURL + destinationPath); }
[ "public", "HttpCopy", "createCopyMethod", "(", "final", "String", "sourcePath", ",", "final", "String", "destinationPath", ")", "{", "return", "new", "HttpCopy", "(", "repositoryURL", "+", "sourcePath", ",", "repositoryURL", "+", "destinationPath", ")", ";", "}" ]
Create COPY method @param sourcePath Source path, relative to repository baseURL @param destinationPath Destination path, relative to repository baseURL @return COPY method
[ "Create", "COPY", "method" ]
21eaf27200c5b2542095f6ebb9dd8ec865b95bbd
https://github.com/fcrepo4-labs/fcrepo4-client/blob/21eaf27200c5b2542095f6ebb9dd8ec865b95bbd/fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java#L401-L403
train
fcrepo4-labs/fcrepo4-client
fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java
HttpHelper.createMoveMethod
public HttpMove createMoveMethod(final String sourcePath, final String destinationPath) { return new HttpMove(repositoryURL + sourcePath, repositoryURL + destinationPath); }
java
public HttpMove createMoveMethod(final String sourcePath, final String destinationPath) { return new HttpMove(repositoryURL + sourcePath, repositoryURL + destinationPath); }
[ "public", "HttpMove", "createMoveMethod", "(", "final", "String", "sourcePath", ",", "final", "String", "destinationPath", ")", "{", "return", "new", "HttpMove", "(", "repositoryURL", "+", "sourcePath", ",", "repositoryURL", "+", "destinationPath", ")", ";", "}" ]
Create MOVE method @param sourcePath Source path, relative to repository baseURL @param destinationPath Destination path, relative to repository baseURL @return MOVE method
[ "Create", "MOVE", "method" ]
21eaf27200c5b2542095f6ebb9dd8ec865b95bbd
https://github.com/fcrepo4-labs/fcrepo4-client/blob/21eaf27200c5b2542095f6ebb9dd8ec865b95bbd/fcrepo-client-impl/src/main/java/org/fcrepo/client/utils/HttpHelper.java#L411-L413
train
passwordmaker/java-passwordmaker-lib
src/main/java/org/daveware/passwordmaker/LeetEncoder.java
LeetEncoder.leetConvert
public static void leetConvert(LeetLevel level, SecureCharArray message) throws Exception { // pre-allocate an array that is 4 times the size of the message. I don't // see anything in the leet-table that is larger than 3 characters, but I'm // using 4-characters to calcualte the size just in case. This is to avoid // a bunch of array resizes. SecureCharArray ret = new SecureCharArray(message.size() * 4); char[] messageBytes = message.getData(); // Reference to message's data char[] retBytes = ret.getData(); // Reference to ret's data int currentRetByte = 0; // Index of current ret byte if (level.compareTo(LeetLevel.LEVEL1) >= 0 && level.compareTo(LeetLevel.LEVEL9) <= 0) { for (char messageByte : messageBytes) { char b = Character.toLowerCase(messageByte); if (b >= 'a' && b <= 'z') { for (int j = 0; j < LEVELS[level.getLevel() - 1][b - 'a'].length(); j++) retBytes[currentRetByte++] = LEVELS[level.getLevel() - 1][b - 'a'].charAt(j); } else { retBytes[currentRetByte++] = b; } } } // Resize the array to the length that we actually filled it, then replace // the original message and erase the buffer we built up. ret.resize(currentRetByte, true); message.replace(ret); ret.erase(); }
java
public static void leetConvert(LeetLevel level, SecureCharArray message) throws Exception { // pre-allocate an array that is 4 times the size of the message. I don't // see anything in the leet-table that is larger than 3 characters, but I'm // using 4-characters to calcualte the size just in case. This is to avoid // a bunch of array resizes. SecureCharArray ret = new SecureCharArray(message.size() * 4); char[] messageBytes = message.getData(); // Reference to message's data char[] retBytes = ret.getData(); // Reference to ret's data int currentRetByte = 0; // Index of current ret byte if (level.compareTo(LeetLevel.LEVEL1) >= 0 && level.compareTo(LeetLevel.LEVEL9) <= 0) { for (char messageByte : messageBytes) { char b = Character.toLowerCase(messageByte); if (b >= 'a' && b <= 'z') { for (int j = 0; j < LEVELS[level.getLevel() - 1][b - 'a'].length(); j++) retBytes[currentRetByte++] = LEVELS[level.getLevel() - 1][b - 'a'].charAt(j); } else { retBytes[currentRetByte++] = b; } } } // Resize the array to the length that we actually filled it, then replace // the original message and erase the buffer we built up. ret.resize(currentRetByte, true); message.replace(ret); ret.erase(); }
[ "public", "static", "void", "leetConvert", "(", "LeetLevel", "level", ",", "SecureCharArray", "message", ")", "throws", "Exception", "{", "// pre-allocate an array that is 4 times the size of the message. I don't", "// see anything in the leet-table that is larger than 3 characters, b...
Converts a SecureCharArray into a new SecureCharArray with any applicable characters converted to leet-speak. @param level What level of leet to use. Each leet corresponds to a different leet lookup table. @param message The array to convert. @throws Exception upon sizing error.
[ "Converts", "a", "SecureCharArray", "into", "a", "new", "SecureCharArray", "with", "any", "applicable", "characters", "converted", "to", "leet", "-", "speak", "." ]
18c22fca7dd9a47f08161425b85a5bd257afbb2b
https://github.com/passwordmaker/java-passwordmaker-lib/blob/18c22fca7dd9a47f08161425b85a5bd257afbb2b/src/main/java/org/daveware/passwordmaker/LeetEncoder.java#L67-L95
train
eyp/serfj
src/main/java/net/sf/serfj/config/SystemConfig.java
SystemConfig.getValue
public String getValue(final ConfigParam param) { if (param == null) { return null; } // Buscamos en las variables del sistema Object obj = System.getProperty(param.getName()); // Si no, se busca en el fichero de configuracion if (obj == null) { obj = this.props.get(param.getName()); } // Si tampoco esta ahi, y es un valor que tenga un valor por defecto, // se devuelve el valor por defecto if (obj == null) { log.warn("Property [{}] not found", param.getName()); obj = param.getDefaultValue(); } // Se devuelve el valor del parametro return (String) obj; }
java
public String getValue(final ConfigParam param) { if (param == null) { return null; } // Buscamos en las variables del sistema Object obj = System.getProperty(param.getName()); // Si no, se busca en el fichero de configuracion if (obj == null) { obj = this.props.get(param.getName()); } // Si tampoco esta ahi, y es un valor que tenga un valor por defecto, // se devuelve el valor por defecto if (obj == null) { log.warn("Property [{}] not found", param.getName()); obj = param.getDefaultValue(); } // Se devuelve el valor del parametro return (String) obj; }
[ "public", "String", "getValue", "(", "final", "ConfigParam", "param", ")", "{", "if", "(", "param", "==", "null", ")", "{", "return", "null", ";", "}", "// Buscamos en las variables del sistema", "Object", "obj", "=", "System", ".", "getProperty", "(", "param"...
Devuelve el valor del parametro de configuracion que se recibe. Si el valor es null y el parametro tiene un valor por defecto, entonces este valor es el que se devuelve. @param param - Parametro del que se quiere obtener el valor. @return el valor del parametro.
[ "Devuelve", "el", "valor", "del", "parametro", "de", "configuracion", "que", "se", "recibe", ".", "Si", "el", "valor", "es", "null", "y", "el", "parametro", "tiene", "un", "valor", "por", "defecto", "entonces", "este", "valor", "es", "el", "que", "se", "...
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/config/SystemConfig.java#L110-L128
train
eyp/serfj
src/main/java/net/sf/serfj/config/SystemConfig.java
SystemConfig.init
private void init() throws ConfigFileIOException { this.props = new Properties(); log.info("Reading config file: {}", this.configFile); boolean ok = true; try { // El fichero esta en el CLASSPATH this.props.load(SystemConfig.class.getResourceAsStream(this.configFile)); } catch (Exception e) { log.warn("File not found in the Classpath"); try { this.props.load(new FileInputStream(this.configFile)); } catch (IOException ioe) { log.error("Can't open file: {}", ioe.getLocalizedMessage()); ok = false; ioe.printStackTrace(); throw new ConfigFileIOException(ioe.getLocalizedMessage()); } } if (ok) { log.info("Configuration loaded successfully"); if (log.isDebugEnabled()) { log.debug(this.toString()); } } }
java
private void init() throws ConfigFileIOException { this.props = new Properties(); log.info("Reading config file: {}", this.configFile); boolean ok = true; try { // El fichero esta en el CLASSPATH this.props.load(SystemConfig.class.getResourceAsStream(this.configFile)); } catch (Exception e) { log.warn("File not found in the Classpath"); try { this.props.load(new FileInputStream(this.configFile)); } catch (IOException ioe) { log.error("Can't open file: {}", ioe.getLocalizedMessage()); ok = false; ioe.printStackTrace(); throw new ConfigFileIOException(ioe.getLocalizedMessage()); } } if (ok) { log.info("Configuration loaded successfully"); if (log.isDebugEnabled()) { log.debug(this.toString()); } } }
[ "private", "void", "init", "(", ")", "throws", "ConfigFileIOException", "{", "this", ".", "props", "=", "new", "Properties", "(", ")", ";", "log", ".", "info", "(", "\"Reading config file: {}\"", ",", "this", ".", "configFile", ")", ";", "boolean", "ok", "...
Inicializa la configuracion.
[ "Inicializa", "la", "configuracion", "." ]
e617592af6f24e59ea58443f2785c44aa2312189
https://github.com/eyp/serfj/blob/e617592af6f24e59ea58443f2785c44aa2312189/src/main/java/net/sf/serfj/config/SystemConfig.java#L164-L188
train
btaz/data-util
src/main/java/com/btaz/util/files/SortController.java
SortController.sortFile
public static void sortFile(File sortDir, File inputFile, File outputFile, Comparator<String> comparator, boolean skipHeader) { sortFile(sortDir, inputFile, outputFile, comparator, skipHeader, DEFAULT_MAX_BYTES, MERGE_FACTOR); }
java
public static void sortFile(File sortDir, File inputFile, File outputFile, Comparator<String> comparator, boolean skipHeader) { sortFile(sortDir, inputFile, outputFile, comparator, skipHeader, DEFAULT_MAX_BYTES, MERGE_FACTOR); }
[ "public", "static", "void", "sortFile", "(", "File", "sortDir", ",", "File", "inputFile", ",", "File", "outputFile", ",", "Comparator", "<", "String", ">", "comparator", ",", "boolean", "skipHeader", ")", "{", "sortFile", "(", "sortDir", ",", "inputFile", ",...
Sort a file, write sorted data to output file. Use the default max bytes size and the default merge factor. @param inputFile input file @param outputFile output file @param comparator comparator used to sort rows
[ "Sort", "a", "file", "write", "sorted", "data", "to", "output", "file", ".", "Use", "the", "default", "max", "bytes", "size", "and", "the", "default", "merge", "factor", "." ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/files/SortController.java#L26-L29
train
btaz/data-util
src/main/java/com/btaz/util/files/SortController.java
SortController.sortFile
public static void sortFile(File sortDir, File inputFile, File outputFile, Comparator<String> comparator, boolean skipHeader, long maxBytes, int mergeFactor) { // validation if(comparator == null) { comparator = Lexical.ascending(); } // steps List<File> splitFiles = split(sortDir, inputFile, maxBytes, skipHeader); List<File> sortedFiles = sort(sortDir, splitFiles, comparator); merge(sortDir, sortedFiles, outputFile, comparator, mergeFactor); }
java
public static void sortFile(File sortDir, File inputFile, File outputFile, Comparator<String> comparator, boolean skipHeader, long maxBytes, int mergeFactor) { // validation if(comparator == null) { comparator = Lexical.ascending(); } // steps List<File> splitFiles = split(sortDir, inputFile, maxBytes, skipHeader); List<File> sortedFiles = sort(sortDir, splitFiles, comparator); merge(sortDir, sortedFiles, outputFile, comparator, mergeFactor); }
[ "public", "static", "void", "sortFile", "(", "File", "sortDir", ",", "File", "inputFile", ",", "File", "outputFile", ",", "Comparator", "<", "String", ">", "comparator", ",", "boolean", "skipHeader", ",", "long", "maxBytes", ",", "int", "mergeFactor", ")", "...
Sort a file, write sorted data to output file. @param inputFile input file @param outputFile output file @param comparator comparator used to sort rows
[ "Sort", "a", "file", "write", "sorted", "data", "to", "output", "file", "." ]
f01de64854c456a88a31ffbe8bac6d605151b496
https://github.com/btaz/data-util/blob/f01de64854c456a88a31ffbe8bac6d605151b496/src/main/java/com/btaz/util/files/SortController.java#L37-L48
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/Assembler.java
Assembler.setWideIndex
public void setWideIndex(boolean wideIndex) { this.wideIndex = wideIndex; if (types != null) { for (TypeASM t : types.values()) { Assembler as = (Assembler) t; as.setWideIndex(wideIndex); } } }
java
public void setWideIndex(boolean wideIndex) { this.wideIndex = wideIndex; if (types != null) { for (TypeASM t : types.values()) { Assembler as = (Assembler) t; as.setWideIndex(wideIndex); } } }
[ "public", "void", "setWideIndex", "(", "boolean", "wideIndex", ")", "{", "this", ".", "wideIndex", "=", "wideIndex", ";", "if", "(", "types", "!=", "null", ")", "{", "for", "(", "TypeASM", "t", ":", "types", ".", "values", "(", ")", ")", "{", "Assemb...
Set goto and jsr to use wide index @param wideIndex
[ "Set", "goto", "and", "jsr", "to", "use", "wide", "index" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/Assembler.java#L106-L117
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/Assembler.java
Assembler.fixAddress
public void fixAddress(String name) throws IOException { Label label = labels.get(name); if (label == null) { label = new Label(name); labels.put(name, label); } int pos = position(); label.setAddress(pos); labelMap.put(pos, label); }
java
public void fixAddress(String name) throws IOException { Label label = labels.get(name); if (label == null) { label = new Label(name); labels.put(name, label); } int pos = position(); label.setAddress(pos); labelMap.put(pos, label); }
[ "public", "void", "fixAddress", "(", "String", "name", ")", "throws", "IOException", "{", "Label", "label", "=", "labels", ".", "get", "(", "name", ")", ";", "if", "(", "label", "==", "null", ")", "{", "label", "=", "new", "Label", "(", "name", ")", ...
Fixes address here for object @param name @throws IOException
[ "Fixes", "address", "here", "for", "object" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/Assembler.java#L124-L135
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/Assembler.java
Assembler.createBranch
public Branch createBranch(String name) throws IOException { Label label = labels.get(name); if (label == null) { label = new Label(name); labels.put(name, label); } return label.createBranch(position()); }
java
public Branch createBranch(String name) throws IOException { Label label = labels.get(name); if (label == null) { label = new Label(name); labels.put(name, label); } return label.createBranch(position()); }
[ "public", "Branch", "createBranch", "(", "String", "name", ")", "throws", "IOException", "{", "Label", "label", "=", "labels", ".", "get", "(", "name", ")", ";", "if", "(", "label", "==", "null", ")", "{", "label", "=", "new", "Label", "(", "name", "...
Creates a branch for possibly unknown address @param name @return @throws IOException
[ "Creates", "a", "branch", "for", "possibly", "unknown", "address" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/Assembler.java#L159-L168
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/Assembler.java
Assembler.ifeq
public void ifeq(String target) throws IOException { if (wideIndex) { out.writeByte(NOT_IFEQ); out.writeShort(WIDEFIXOFFSET); Branch branch = createBranch(target); out.writeByte(GOTO_W); out.writeInt(branch); } else { Branch branch = createBranch(target); out.writeOpCode(IFEQ); out.writeShort(branch); } }
java
public void ifeq(String target) throws IOException { if (wideIndex) { out.writeByte(NOT_IFEQ); out.writeShort(WIDEFIXOFFSET); Branch branch = createBranch(target); out.writeByte(GOTO_W); out.writeInt(branch); } else { Branch branch = createBranch(target); out.writeOpCode(IFEQ); out.writeShort(branch); } }
[ "public", "void", "ifeq", "(", "String", "target", ")", "throws", "IOException", "{", "if", "(", "wideIndex", ")", "{", "out", ".", "writeByte", "(", "NOT_IFEQ", ")", ";", "out", ".", "writeShort", "(", "WIDEFIXOFFSET", ")", ";", "Branch", "branch", "=",...
eq succeeds if and only if value == 0 @param target @throws IOException
[ "eq", "succeeds", "if", "and", "only", "if", "value", "==", "0" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/Assembler.java#L998-L1014
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/Assembler.java
Assembler.ifne
public void ifne(String target) throws IOException { if (wideIndex) { out.writeByte(NOT_IFNE); out.writeShort(WIDEFIXOFFSET); Branch branch = createBranch(target); out.writeByte(GOTO_W); out.writeInt(branch); } else { Branch branch = createBranch(target); out.writeOpCode(IFNE); out.writeShort(branch); } }
java
public void ifne(String target) throws IOException { if (wideIndex) { out.writeByte(NOT_IFNE); out.writeShort(WIDEFIXOFFSET); Branch branch = createBranch(target); out.writeByte(GOTO_W); out.writeInt(branch); } else { Branch branch = createBranch(target); out.writeOpCode(IFNE); out.writeShort(branch); } }
[ "public", "void", "ifne", "(", "String", "target", ")", "throws", "IOException", "{", "if", "(", "wideIndex", ")", "{", "out", ".", "writeByte", "(", "NOT_IFNE", ")", ";", "out", ".", "writeShort", "(", "WIDEFIXOFFSET", ")", ";", "Branch", "branch", "=",...
ne succeeds if and only if value != 0 @param target @throws IOException
[ "ne", "succeeds", "if", "and", "only", "if", "value", "!", "=", "0" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/Assembler.java#L1021-L1037
train
tvesalainen/bcc
src/main/java/org/vesalainen/bcc/Assembler.java
Assembler.iflt
public void iflt(String target) throws IOException { if (wideIndex) { out.writeByte(NOT_IFLT); out.writeShort(WIDEFIXOFFSET); Branch branch = createBranch(target); out.writeByte(GOTO_W); out.writeInt(branch); } else { Branch branch = createBranch(target); out.writeOpCode(IFLT); out.writeShort(branch); } }
java
public void iflt(String target) throws IOException { if (wideIndex) { out.writeByte(NOT_IFLT); out.writeShort(WIDEFIXOFFSET); Branch branch = createBranch(target); out.writeByte(GOTO_W); out.writeInt(branch); } else { Branch branch = createBranch(target); out.writeOpCode(IFLT); out.writeShort(branch); } }
[ "public", "void", "iflt", "(", "String", "target", ")", "throws", "IOException", "{", "if", "(", "wideIndex", ")", "{", "out", ".", "writeByte", "(", "NOT_IFLT", ")", ";", "out", ".", "writeShort", "(", "WIDEFIXOFFSET", ")", ";", "Branch", "branch", "=",...
lt succeeds if and only if value &lt; 0 @param target @throws IOException
[ "lt", "succeeds", "if", "and", "only", "if", "value", "&lt", ";", "0" ]
4e84e313018d487f1a8cca3952d71bc21e77d16b
https://github.com/tvesalainen/bcc/blob/4e84e313018d487f1a8cca3952d71bc21e77d16b/src/main/java/org/vesalainen/bcc/Assembler.java#L1044-L1060
train