id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
1,100
cdapio/tigon
tigon-sql/src/main/java/co/cask/tigon/sql/manager/ProcessInitiator.java
ProcessInitiator.startGSEXIT
public void startGSEXIT() throws IOException { List<HubDataSink> dataSinks = hubDataStore.getHubDataSinks(); for (HubDataSink hubDataSink : dataSinks) { List<String> com = Lists.newArrayList(); com.add(getHostPort(hubDataStore.getHubAddress())); com.add(hubDataStore.getInstanceName()); com.add(hubDataSink.getFTAName()); com.add(hubDataSink.getName()); ExternalProgramExecutor executorService = new ExternalProgramExecutor( "GSEXIT", new File(binLocation, "GSEXIT"), com.toArray(new String[com.size()])); gsExitExecutor.add(executorService); LOG.info("Starting GSEXIT : {}", executorService); executorService.startAndWait(); } }
java
public void startGSEXIT() throws IOException { List<HubDataSink> dataSinks = hubDataStore.getHubDataSinks(); for (HubDataSink hubDataSink : dataSinks) { List<String> com = Lists.newArrayList(); com.add(getHostPort(hubDataStore.getHubAddress())); com.add(hubDataStore.getInstanceName()); com.add(hubDataSink.getFTAName()); com.add(hubDataSink.getName()); ExternalProgramExecutor executorService = new ExternalProgramExecutor( "GSEXIT", new File(binLocation, "GSEXIT"), com.toArray(new String[com.size()])); gsExitExecutor.add(executorService); LOG.info("Starting GSEXIT : {}", executorService); executorService.startAndWait(); } }
[ "public", "void", "startGSEXIT", "(", ")", "throws", "IOException", "{", "List", "<", "HubDataSink", ">", "dataSinks", "=", "hubDataStore", ".", "getHubDataSinks", "(", ")", ";", "for", "(", "HubDataSink", "hubDataSink", ":", "dataSinks", ")", "{", "List", "<", "String", ">", "com", "=", "Lists", ".", "newArrayList", "(", ")", ";", "com", ".", "add", "(", "getHostPort", "(", "hubDataStore", ".", "getHubAddress", "(", ")", ")", ")", ";", "com", ".", "add", "(", "hubDataStore", ".", "getInstanceName", "(", ")", ")", ";", "com", ".", "add", "(", "hubDataSink", ".", "getFTAName", "(", ")", ")", ";", "com", ".", "add", "(", "hubDataSink", ".", "getName", "(", ")", ")", ";", "ExternalProgramExecutor", "executorService", "=", "new", "ExternalProgramExecutor", "(", "\"GSEXIT\"", ",", "new", "File", "(", "binLocation", ",", "\"GSEXIT\"", ")", ",", "com", ".", "toArray", "(", "new", "String", "[", "com", ".", "size", "(", ")", "]", ")", ")", ";", "gsExitExecutor", ".", "add", "(", "executorService", ")", ";", "LOG", ".", "info", "(", "\"Starting GSEXIT : {}\"", ",", "executorService", ")", ";", "executorService", ".", "startAndWait", "(", ")", ";", "}", "}" ]
Starts GSEXIT processes. @throws IOException
[ "Starts", "GSEXIT", "processes", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-sql/src/main/java/co/cask/tigon/sql/manager/ProcessInitiator.java#L132-L146
1,101
cdapio/tigon
tigon-api/src/main/java/co/cask/tigon/internal/specification/PropertyFieldExtractor.java
PropertyFieldExtractor.getStringValue
private String getStringValue(Object instance, Field field) throws IllegalAccessException { Class<?> fieldType = field.getType(); // Only support primitive type, boxed type, String and Enum Preconditions.checkArgument( fieldType.isPrimitive() || Primitives.isWrapperType(fieldType) || String.class.equals(fieldType) || fieldType.isEnum(), "Unsupported property type %s of field %s in class %s.", fieldType.getName(), field.getName(), field.getDeclaringClass().getName() ); if (!field.isAccessible()) { field.setAccessible(true); } Object value = field.get(instance); if (value == null) { return null; } // Key name is "className.fieldName". return fieldType.isEnum() ? ((Enum<?>) value).name() : value.toString(); }
java
private String getStringValue(Object instance, Field field) throws IllegalAccessException { Class<?> fieldType = field.getType(); // Only support primitive type, boxed type, String and Enum Preconditions.checkArgument( fieldType.isPrimitive() || Primitives.isWrapperType(fieldType) || String.class.equals(fieldType) || fieldType.isEnum(), "Unsupported property type %s of field %s in class %s.", fieldType.getName(), field.getName(), field.getDeclaringClass().getName() ); if (!field.isAccessible()) { field.setAccessible(true); } Object value = field.get(instance); if (value == null) { return null; } // Key name is "className.fieldName". return fieldType.isEnum() ? ((Enum<?>) value).name() : value.toString(); }
[ "private", "String", "getStringValue", "(", "Object", "instance", ",", "Field", "field", ")", "throws", "IllegalAccessException", "{", "Class", "<", "?", ">", "fieldType", "=", "field", ".", "getType", "(", ")", ";", "// Only support primitive type, boxed type, String and Enum", "Preconditions", ".", "checkArgument", "(", "fieldType", ".", "isPrimitive", "(", ")", "||", "Primitives", ".", "isWrapperType", "(", "fieldType", ")", "||", "String", ".", "class", ".", "equals", "(", "fieldType", ")", "||", "fieldType", ".", "isEnum", "(", ")", ",", "\"Unsupported property type %s of field %s in class %s.\"", ",", "fieldType", ".", "getName", "(", ")", ",", "field", ".", "getName", "(", ")", ",", "field", ".", "getDeclaringClass", "(", ")", ".", "getName", "(", ")", ")", ";", "if", "(", "!", "field", ".", "isAccessible", "(", ")", ")", "{", "field", ".", "setAccessible", "(", "true", ")", ";", "}", "Object", "value", "=", "field", ".", "get", "(", "instance", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "// Key name is \"className.fieldName\".", "return", "fieldType", ".", "isEnum", "(", ")", "?", "(", "(", "Enum", "<", "?", ">", ")", "value", ")", ".", "name", "(", ")", ":", "value", ".", "toString", "(", ")", ";", "}" ]
Gets the value of the field in the given instance as String. Currently only allows primitive types, boxed types, String and Enum.
[ "Gets", "the", "value", "of", "the", "field", "in", "the", "given", "instance", "as", "String", ".", "Currently", "only", "allows", "primitive", "types", "boxed", "types", "String", "and", "Enum", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-api/src/main/java/co/cask/tigon/internal/specification/PropertyFieldExtractor.java#L64-L85
1,102
cdapio/tigon
tigon-flow/src/main/java/co/cask/tigon/internal/app/SchemaFinder.java
SchemaFinder.checkSchema
public static boolean checkSchema(Set<Schema> output, Set<Schema> input) { return findSchema(output, input) != null; }
java
public static boolean checkSchema(Set<Schema> output, Set<Schema> input) { return findSchema(output, input) != null; }
[ "public", "static", "boolean", "checkSchema", "(", "Set", "<", "Schema", ">", "output", ",", "Set", "<", "Schema", ">", "input", ")", "{", "return", "findSchema", "(", "output", ",", "input", ")", "!=", "null", ";", "}" ]
Given two schema's checks if there exists compatibility or equality. @param output Set of output {@link Schema}. @param input Set of input {@link Schema}. @return true if and only if they are equal or compatible with constraints
[ "Given", "two", "schema", "s", "checks", "if", "there", "exists", "compatibility", "or", "equality", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-flow/src/main/java/co/cask/tigon/internal/app/SchemaFinder.java#L37-L39
1,103
cdapio/tigon
tigon-queue/src/main/java/co/cask/tigon/data/queue/QueueEntry.java
QueueEntry.serializeEmptyHashKeys
private static byte[] serializeEmptyHashKeys() { try { // we don't synchronize here: the worst thing that go wrong here is repeated assignment to the same value ByteArrayOutputStream bos = new ByteArrayOutputStream(); Encoder encoder = new BinaryEncoder(bos); encoder.writeInt(0); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException("encoding empty hash keys went wrong - bailing out: " + e.getMessage(), e); } }
java
private static byte[] serializeEmptyHashKeys() { try { // we don't synchronize here: the worst thing that go wrong here is repeated assignment to the same value ByteArrayOutputStream bos = new ByteArrayOutputStream(); Encoder encoder = new BinaryEncoder(bos); encoder.writeInt(0); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException("encoding empty hash keys went wrong - bailing out: " + e.getMessage(), e); } }
[ "private", "static", "byte", "[", "]", "serializeEmptyHashKeys", "(", ")", "{", "try", "{", "// we don't synchronize here: the worst thing that go wrong here is repeated assignment to the same value", "ByteArrayOutputStream", "bos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "Encoder", "encoder", "=", "new", "BinaryEncoder", "(", "bos", ")", ";", "encoder", ".", "writeInt", "(", "0", ")", ";", "return", "bos", ".", "toByteArray", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"encoding empty hash keys went wrong - bailing out: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
many entries will have no hash keys. Serialize that once and for good
[ "many", "entries", "will", "have", "no", "hash", "keys", ".", "Serialize", "that", "once", "and", "for", "good" ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-queue/src/main/java/co/cask/tigon/data/queue/QueueEntry.java#L75-L85
1,104
cdapio/tigon
tigon-common/src/main/java/co/cask/tigon/io/BufferedEncoder.java
BufferedEncoder.writeRaw
public Encoder writeRaw(byte[] rawBytes, int off, int len) throws IOException { output.write(rawBytes, off, len); return this; }
java
public Encoder writeRaw(byte[] rawBytes, int off, int len) throws IOException { output.write(rawBytes, off, len); return this; }
[ "public", "Encoder", "writeRaw", "(", "byte", "[", "]", "rawBytes", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "output", ".", "write", "(", "rawBytes", ",", "off", ",", "len", ")", ";", "return", "this", ";", "}" ]
Writes raw bytes to the buffer without encoding. @param rawBytes The bytes to write. @param off Offset to start in the byte array. @param len Number of bytes to write starting from the offset.
[ "Writes", "raw", "bytes", "to", "the", "buffer", "without", "encoding", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-common/src/main/java/co/cask/tigon/io/BufferedEncoder.java#L74-L77
1,105
cdapio/tigon
tigon-yarn/src/main/java/co/cask/tigon/lang/ClassLoaders.java
ClassLoaders.getAPIClassPath
private static ClassPath getAPIClassPath() throws IOException { ClassLoader classLoader = Flow.class.getClassLoader(); String resourceName = Flow.class.getName().replace('.', '/') + ".class"; URL url = classLoader.getResource(resourceName); if (url == null) { throw new IOException("Resource not found for " + resourceName); } try { URI classPathURI = getClassPathURL(resourceName, url).toURI(); return ClassPath.from(classPathURI, classLoader); } catch (URISyntaxException e) { throw new IOException(e); } }
java
private static ClassPath getAPIClassPath() throws IOException { ClassLoader classLoader = Flow.class.getClassLoader(); String resourceName = Flow.class.getName().replace('.', '/') + ".class"; URL url = classLoader.getResource(resourceName); if (url == null) { throw new IOException("Resource not found for " + resourceName); } try { URI classPathURI = getClassPathURL(resourceName, url).toURI(); return ClassPath.from(classPathURI, classLoader); } catch (URISyntaxException e) { throw new IOException(e); } }
[ "private", "static", "ClassPath", "getAPIClassPath", "(", ")", "throws", "IOException", "{", "ClassLoader", "classLoader", "=", "Flow", ".", "class", ".", "getClassLoader", "(", ")", ";", "String", "resourceName", "=", "Flow", ".", "class", ".", "getName", "(", ")", ".", "replace", "(", "'", "'", ",", "'", "'", ")", "+", "\".class\"", ";", "URL", "url", "=", "classLoader", ".", "getResource", "(", "resourceName", ")", ";", "if", "(", "url", "==", "null", ")", "{", "throw", "new", "IOException", "(", "\"Resource not found for \"", "+", "resourceName", ")", ";", "}", "try", "{", "URI", "classPathURI", "=", "getClassPathURL", "(", "resourceName", ",", "url", ")", ".", "toURI", "(", ")", ";", "return", "ClassPath", ".", "from", "(", "classPathURI", ",", "classLoader", ")", ";", "}", "catch", "(", "URISyntaxException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "}" ]
Gathers all resources for api classes.
[ "Gathers", "all", "resources", "for", "api", "classes", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-yarn/src/main/java/co/cask/tigon/lang/ClassLoaders.java#L134-L148
1,106
cdapio/tigon
tigon-yarn/src/main/java/co/cask/tigon/lang/ClassLoaders.java
ClassLoaders.getClassPathURL
private static URL getClassPathURL(String resourceName, URL resourceURL) { try { if ("file".equals(resourceURL.getProtocol())) { String path = resourceURL.getFile(); // Compute the directory container the class. int endIdx = path.length() - resourceName.length(); if (endIdx > 1) { // If it is not the root directory, return the end index to remove the trailing '/'. endIdx--; } return new URL("file", "", -1, path.substring(0, endIdx)); } if ("jar".equals(resourceURL.getProtocol())) { String path = resourceURL.getFile(); return URI.create(path.substring(0, path.indexOf("!/"))).toURL(); } } catch (MalformedURLException e) { throw Throwables.propagate(e); } throw new IllegalStateException("Unsupported class URL: " + resourceURL); }
java
private static URL getClassPathURL(String resourceName, URL resourceURL) { try { if ("file".equals(resourceURL.getProtocol())) { String path = resourceURL.getFile(); // Compute the directory container the class. int endIdx = path.length() - resourceName.length(); if (endIdx > 1) { // If it is not the root directory, return the end index to remove the trailing '/'. endIdx--; } return new URL("file", "", -1, path.substring(0, endIdx)); } if ("jar".equals(resourceURL.getProtocol())) { String path = resourceURL.getFile(); return URI.create(path.substring(0, path.indexOf("!/"))).toURL(); } } catch (MalformedURLException e) { throw Throwables.propagate(e); } throw new IllegalStateException("Unsupported class URL: " + resourceURL); }
[ "private", "static", "URL", "getClassPathURL", "(", "String", "resourceName", ",", "URL", "resourceURL", ")", "{", "try", "{", "if", "(", "\"file\"", ".", "equals", "(", "resourceURL", ".", "getProtocol", "(", ")", ")", ")", "{", "String", "path", "=", "resourceURL", ".", "getFile", "(", ")", ";", "// Compute the directory container the class.", "int", "endIdx", "=", "path", ".", "length", "(", ")", "-", "resourceName", ".", "length", "(", ")", ";", "if", "(", "endIdx", ">", "1", ")", "{", "// If it is not the root directory, return the end index to remove the trailing '/'.", "endIdx", "--", ";", "}", "return", "new", "URL", "(", "\"file\"", ",", "\"\"", ",", "-", "1", ",", "path", ".", "substring", "(", "0", ",", "endIdx", ")", ")", ";", "}", "if", "(", "\"jar\"", ".", "equals", "(", "resourceURL", ".", "getProtocol", "(", ")", ")", ")", "{", "String", "path", "=", "resourceURL", ".", "getFile", "(", ")", ";", "return", "URI", ".", "create", "(", "path", ".", "substring", "(", "0", ",", "path", ".", "indexOf", "(", "\"!/\"", ")", ")", ")", ".", "toURL", "(", ")", ";", "}", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "throw", "Throwables", ".", "propagate", "(", "e", ")", ";", "}", "throw", "new", "IllegalStateException", "(", "\"Unsupported class URL: \"", "+", "resourceURL", ")", ";", "}" ]
Find the classpath that contains the given resource.
[ "Find", "the", "classpath", "that", "contains", "the", "given", "resource", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-yarn/src/main/java/co/cask/tigon/lang/ClassLoaders.java#L153-L173
1,107
cdapio/tigon
tigon-queue/src/main/java/co/cask/tigon/data/transaction/queue/hbase/HBaseQueueClientFactory.java
HBaseQueueClientFactory.ensureTableExists
private HBaseQueueAdmin ensureTableExists(QueueName queueName) throws IOException { HBaseQueueAdmin admin = queueAdmin; try { if (!admin.exists(queueName)) { admin.create(queueName); } } catch (Exception e) { throw new IOException("Failed to open table " + admin.getActualTableName(queueName), e); } return admin; }
java
private HBaseQueueAdmin ensureTableExists(QueueName queueName) throws IOException { HBaseQueueAdmin admin = queueAdmin; try { if (!admin.exists(queueName)) { admin.create(queueName); } } catch (Exception e) { throw new IOException("Failed to open table " + admin.getActualTableName(queueName), e); } return admin; }
[ "private", "HBaseQueueAdmin", "ensureTableExists", "(", "QueueName", "queueName", ")", "throws", "IOException", "{", "HBaseQueueAdmin", "admin", "=", "queueAdmin", ";", "try", "{", "if", "(", "!", "admin", ".", "exists", "(", "queueName", ")", ")", "{", "admin", ".", "create", "(", "queueName", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IOException", "(", "\"Failed to open table \"", "+", "admin", ".", "getActualTableName", "(", "queueName", ")", ",", "e", ")", ";", "}", "return", "admin", ";", "}" ]
Helper method to select the queue or stream admin, and to ensure it's table exists. @param queueName name of the queue to be opened. @return the queue admin for that queue. @throws java.io.IOException
[ "Helper", "method", "to", "select", "the", "queue", "or", "stream", "admin", "and", "to", "ensure", "it", "s", "table", "exists", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-queue/src/main/java/co/cask/tigon/data/transaction/queue/hbase/HBaseQueueClientFactory.java#L88-L98
1,108
cdapio/tigon
tigon-sql/src/main/java/co/cask/tigon/sql/util/GDATFormatUtil.java
GDATFormatUtil.getSerializedSchema
public static String getSerializedSchema(String gdatHeader) { /*Format : GDAT\nVERSION:4\nSCHEMALENGTH:123\n FTA {\n STREAM <name> {\n <list of fields>\n }\n <query text>\n } */ int startBracketIndex = gdatHeader.indexOf("{"); startBracketIndex = gdatHeader.indexOf("{", startBracketIndex + 1); int endBracketIndex = gdatHeader.indexOf("}"); Preconditions.checkArgument(endBracketIndex > startBracketIndex); return gdatHeader.substring(startBracketIndex + 1, endBracketIndex); }
java
public static String getSerializedSchema(String gdatHeader) { /*Format : GDAT\nVERSION:4\nSCHEMALENGTH:123\n FTA {\n STREAM <name> {\n <list of fields>\n }\n <query text>\n } */ int startBracketIndex = gdatHeader.indexOf("{"); startBracketIndex = gdatHeader.indexOf("{", startBracketIndex + 1); int endBracketIndex = gdatHeader.indexOf("}"); Preconditions.checkArgument(endBracketIndex > startBracketIndex); return gdatHeader.substring(startBracketIndex + 1, endBracketIndex); }
[ "public", "static", "String", "getSerializedSchema", "(", "String", "gdatHeader", ")", "{", "/*Format :\n GDAT\\nVERSION:4\\nSCHEMALENGTH:123\\n\n FTA {\\n\n STREAM <name> {\\n\n <list of fields>\\n\n }\\n\n <query text>\\n\n }\n */", "int", "startBracketIndex", "=", "gdatHeader", ".", "indexOf", "(", "\"{\"", ")", ";", "startBracketIndex", "=", "gdatHeader", ".", "indexOf", "(", "\"{\"", ",", "startBracketIndex", "+", "1", ")", ";", "int", "endBracketIndex", "=", "gdatHeader", ".", "indexOf", "(", "\"}\"", ")", ";", "Preconditions", ".", "checkArgument", "(", "endBracketIndex", ">", "startBracketIndex", ")", ";", "return", "gdatHeader", ".", "substring", "(", "startBracketIndex", "+", "1", ",", "endBracketIndex", ")", ";", "}" ]
Given a gdatHeader extract serialized Schema String.
[ "Given", "a", "gdatHeader", "extract", "serialized", "Schema", "String", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-sql/src/main/java/co/cask/tigon/sql/util/GDATFormatUtil.java#L91-L106
1,109
cdapio/tigon
tigon-sql/src/main/java/co/cask/tigon/sql/util/MetaInformationParser.java
MetaInformationParser.getHFTACount
public static int getHFTACount(File fileLocation) { Document qtree = getQTree(fileLocation); int count; count = qtree.getElementsByTagName("HFTA").getLength(); return count; }
java
public static int getHFTACount(File fileLocation) { Document qtree = getQTree(fileLocation); int count; count = qtree.getElementsByTagName("HFTA").getLength(); return count; }
[ "public", "static", "int", "getHFTACount", "(", "File", "fileLocation", ")", "{", "Document", "qtree", "=", "getQTree", "(", "fileLocation", ")", ";", "int", "count", ";", "count", "=", "qtree", ".", "getElementsByTagName", "(", "\"HFTA\"", ")", ".", "getLength", "(", ")", ";", "return", "count", ";", "}" ]
This method returns the number of HFTA processes to be instantiated by parsing the qtree.xml file @param fileLocation Directory that contains the qtree.xml file @return The number of HFTA processes to be instantiated @throws IOException
[ "This", "method", "returns", "the", "number", "of", "HFTA", "processes", "to", "be", "instantiated", "by", "parsing", "the", "qtree", ".", "xml", "file" ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-sql/src/main/java/co/cask/tigon/sql/util/MetaInformationParser.java#L115-L120
1,110
cdapio/tigon
tigon-queue/src/main/java/co/cask/tigon/data/transaction/queue/hbase/HBaseConsumerState.java
HBaseConsumerState.delete
public Delete delete(Delete delete) { delete.deleteColumns(QueueEntryRow.COLUMN_FAMILY, consumerStateColumn); return delete; }
java
public Delete delete(Delete delete) { delete.deleteColumns(QueueEntryRow.COLUMN_FAMILY, consumerStateColumn); return delete; }
[ "public", "Delete", "delete", "(", "Delete", "delete", ")", "{", "delete", ".", "deleteColumns", "(", "QueueEntryRow", ".", "COLUMN_FAMILY", ",", "consumerStateColumn", ")", ";", "return", "delete", ";", "}" ]
Adds a delete of this consumer state to the given Delete object.
[ "Adds", "a", "delete", "of", "this", "consumer", "state", "to", "the", "given", "Delete", "object", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-queue/src/main/java/co/cask/tigon/data/transaction/queue/hbase/HBaseConsumerState.java#L112-L115
1,111
cdapio/tigon
tigon-sql/src/main/java/co/cask/tigon/sql/io/POJOCreator.java
POJOCreator.decode
public Object decode(Decoder decoder) throws IOException { try { return outputGenerator.read(decoder, schema); } catch (IOException e) { LOG.error("Cannot instantiate object of type {}", outputClass.getName(), e); throw e; } }
java
public Object decode(Decoder decoder) throws IOException { try { return outputGenerator.read(decoder, schema); } catch (IOException e) { LOG.error("Cannot instantiate object of type {}", outputClass.getName(), e); throw e; } }
[ "public", "Object", "decode", "(", "Decoder", "decoder", ")", "throws", "IOException", "{", "try", "{", "return", "outputGenerator", ".", "read", "(", "decoder", ",", "schema", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOG", ".", "error", "(", "\"Cannot instantiate object of type {}\"", ",", "outputClass", ".", "getName", "(", ")", ",", "e", ")", ";", "throw", "e", ";", "}", "}" ]
This function is called for each incoming byte record. @param decoder The decoder that encapsulates the byte[] data record @return Map of method and the input parameter objects @throws java.io.IOException if the {@link co.cask.tigon.internal.io.ReflectionDatumReader} cannot decode incoming data record
[ "This", "function", "is", "called", "for", "each", "incoming", "byte", "record", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-sql/src/main/java/co/cask/tigon/sql/io/POJOCreator.java#L63-L70
1,112
cdapio/tigon
tigon-flow/src/main/java/co/cask/tigon/internal/app/runtime/flow/FlowProgramRunner.java
FlowProgramRunner.createFlowlets
private Table<String, Integer, ProgramController> createFlowlets(Program program, RunId runId, FlowSpecification flowSpec) { Table<String, Integer, ProgramController> flowlets = HashBasedTable.create(); try { for (Map.Entry<String, FlowletDefinition> entry : flowSpec.getFlowlets().entrySet()) { int instanceCount = entry.getValue().getInstances(); for (int instanceId = 0; instanceId < instanceCount; instanceId++) { flowlets.put(entry.getKey(), instanceId, startFlowlet(program, createFlowletOptions(entry.getKey(), instanceId, instanceCount, runId))); } } } catch (Throwable t) { try { // Need to stop all started flowlets Futures.successfulAsList(Iterables.transform(flowlets.values(), new Function<ProgramController, ListenableFuture<?>>() { @Override public ListenableFuture<?> apply(ProgramController controller) { return controller.stop(); } })).get(); } catch (Exception e) { LOG.error("Fail to stop all flowlets on failure."); } throw Throwables.propagate(t); } return flowlets; }
java
private Table<String, Integer, ProgramController> createFlowlets(Program program, RunId runId, FlowSpecification flowSpec) { Table<String, Integer, ProgramController> flowlets = HashBasedTable.create(); try { for (Map.Entry<String, FlowletDefinition> entry : flowSpec.getFlowlets().entrySet()) { int instanceCount = entry.getValue().getInstances(); for (int instanceId = 0; instanceId < instanceCount; instanceId++) { flowlets.put(entry.getKey(), instanceId, startFlowlet(program, createFlowletOptions(entry.getKey(), instanceId, instanceCount, runId))); } } } catch (Throwable t) { try { // Need to stop all started flowlets Futures.successfulAsList(Iterables.transform(flowlets.values(), new Function<ProgramController, ListenableFuture<?>>() { @Override public ListenableFuture<?> apply(ProgramController controller) { return controller.stop(); } })).get(); } catch (Exception e) { LOG.error("Fail to stop all flowlets on failure."); } throw Throwables.propagate(t); } return flowlets; }
[ "private", "Table", "<", "String", ",", "Integer", ",", "ProgramController", ">", "createFlowlets", "(", "Program", "program", ",", "RunId", "runId", ",", "FlowSpecification", "flowSpec", ")", "{", "Table", "<", "String", ",", "Integer", ",", "ProgramController", ">", "flowlets", "=", "HashBasedTable", ".", "create", "(", ")", ";", "try", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "FlowletDefinition", ">", "entry", ":", "flowSpec", ".", "getFlowlets", "(", ")", ".", "entrySet", "(", ")", ")", "{", "int", "instanceCount", "=", "entry", ".", "getValue", "(", ")", ".", "getInstances", "(", ")", ";", "for", "(", "int", "instanceId", "=", "0", ";", "instanceId", "<", "instanceCount", ";", "instanceId", "++", ")", "{", "flowlets", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "instanceId", ",", "startFlowlet", "(", "program", ",", "createFlowletOptions", "(", "entry", ".", "getKey", "(", ")", ",", "instanceId", ",", "instanceCount", ",", "runId", ")", ")", ")", ";", "}", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "try", "{", "// Need to stop all started flowlets", "Futures", ".", "successfulAsList", "(", "Iterables", ".", "transform", "(", "flowlets", ".", "values", "(", ")", ",", "new", "Function", "<", "ProgramController", ",", "ListenableFuture", "<", "?", ">", ">", "(", ")", "{", "@", "Override", "public", "ListenableFuture", "<", "?", ">", "apply", "(", "ProgramController", "controller", ")", "{", "return", "controller", ".", "stop", "(", ")", ";", "}", "}", ")", ")", ".", "get", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"Fail to stop all flowlets on failure.\"", ")", ";", "}", "throw", "Throwables", ".", "propagate", "(", "t", ")", ";", "}", "return", "flowlets", ";", "}" ]
Starts all flowlets in the flow program. @param program Program to run @param flowSpec The {@link FlowSpecification}. @return A {@link com.google.common.collect.Table} with row as flowlet id, column as instance id, cell as the {@link ProgramController} for the flowlet.
[ "Starts", "all", "flowlets", "in", "the", "flow", "program", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-flow/src/main/java/co/cask/tigon/internal/app/runtime/flow/FlowProgramRunner.java#L115-L143
1,113
cdapio/tigon
tigon-sql/src/main/java/co/cask/tigon/sql/flowlet/AbstractInputFlowlet.java
AbstractInputFlowlet.initialize
@Override public final void initialize(FlowletContext ctx) throws Exception { super.initialize(ctx); portsAnnouncementList = Lists.newArrayList(); DefaultInputFlowletConfigurer configurer = new DefaultInputFlowletConfigurer(this); create(configurer); InputFlowletSpecification spec = configurer.createInputFlowletSpec(); dataIngestionPortsMap = Maps.newHashMap(); int httpPort = 0; if (ctx.getRuntimeArguments().get(Constants.HTTP_PORT) != null) { httpPort = Integer.parseInt(ctx.getRuntimeArguments().get(Constants.HTTP_PORT)); } dataIngestionPortsMap.put(Constants.HTTP_PORT, httpPort); for (String inputName : spec.getInputSchemas().keySet()) { int tcpPort = 0; if (ctx.getRuntimeArguments().get(Constants.TCP_INGESTION_PORT_PREFIX + inputName) != null) { tcpPort = Integer.parseInt(ctx.getRuntimeArguments().get(Constants.TCP_INGESTION_PORT_PREFIX + inputName)); } dataIngestionPortsMap.put(Constants.TCP_INGESTION_PORT_PREFIX + inputName, tcpPort); } // Setup temporary directory structure tmpFolder = Files.createTempDir(); File baseDir = new File(tmpFolder, "baseDir"); baseDir.mkdirs(); InputFlowletConfiguration inputFlowletConfiguration = new LocalInputFlowletConfiguration(baseDir, spec); File binDir = inputFlowletConfiguration.createStreamEngineProcesses(); healthInspector = new HealthInspector(this); metricsRecorder = new MetricsRecorder(metrics); //Initiating AbstractInputFlowlet Components recordQueue = new GDATRecordQueue(); //Initiating Netty TCP I/O ports inputFlowletService = new InputFlowletService(binDir, spec, healthInspector, metricsRecorder, recordQueue, dataIngestionPortsMap, this); inputFlowletService.startAndWait(); //Starting health monitor service healthInspector.startAndWait(); //Initializing methodsDriver Map<String, StreamSchema> schemaMap = MetaInformationParser.getSchemaMap(new File(binDir.toURI())); methodsDriver = new MethodsDriver(this, schemaMap); //Initialize stopwatch and retry counter stopwatch = new Stopwatch(); retryCounter = 0; }
java
@Override public final void initialize(FlowletContext ctx) throws Exception { super.initialize(ctx); portsAnnouncementList = Lists.newArrayList(); DefaultInputFlowletConfigurer configurer = new DefaultInputFlowletConfigurer(this); create(configurer); InputFlowletSpecification spec = configurer.createInputFlowletSpec(); dataIngestionPortsMap = Maps.newHashMap(); int httpPort = 0; if (ctx.getRuntimeArguments().get(Constants.HTTP_PORT) != null) { httpPort = Integer.parseInt(ctx.getRuntimeArguments().get(Constants.HTTP_PORT)); } dataIngestionPortsMap.put(Constants.HTTP_PORT, httpPort); for (String inputName : spec.getInputSchemas().keySet()) { int tcpPort = 0; if (ctx.getRuntimeArguments().get(Constants.TCP_INGESTION_PORT_PREFIX + inputName) != null) { tcpPort = Integer.parseInt(ctx.getRuntimeArguments().get(Constants.TCP_INGESTION_PORT_PREFIX + inputName)); } dataIngestionPortsMap.put(Constants.TCP_INGESTION_PORT_PREFIX + inputName, tcpPort); } // Setup temporary directory structure tmpFolder = Files.createTempDir(); File baseDir = new File(tmpFolder, "baseDir"); baseDir.mkdirs(); InputFlowletConfiguration inputFlowletConfiguration = new LocalInputFlowletConfiguration(baseDir, spec); File binDir = inputFlowletConfiguration.createStreamEngineProcesses(); healthInspector = new HealthInspector(this); metricsRecorder = new MetricsRecorder(metrics); //Initiating AbstractInputFlowlet Components recordQueue = new GDATRecordQueue(); //Initiating Netty TCP I/O ports inputFlowletService = new InputFlowletService(binDir, spec, healthInspector, metricsRecorder, recordQueue, dataIngestionPortsMap, this); inputFlowletService.startAndWait(); //Starting health monitor service healthInspector.startAndWait(); //Initializing methodsDriver Map<String, StreamSchema> schemaMap = MetaInformationParser.getSchemaMap(new File(binDir.toURI())); methodsDriver = new MethodsDriver(this, schemaMap); //Initialize stopwatch and retry counter stopwatch = new Stopwatch(); retryCounter = 0; }
[ "@", "Override", "public", "final", "void", "initialize", "(", "FlowletContext", "ctx", ")", "throws", "Exception", "{", "super", ".", "initialize", "(", "ctx", ")", ";", "portsAnnouncementList", "=", "Lists", ".", "newArrayList", "(", ")", ";", "DefaultInputFlowletConfigurer", "configurer", "=", "new", "DefaultInputFlowletConfigurer", "(", "this", ")", ";", "create", "(", "configurer", ")", ";", "InputFlowletSpecification", "spec", "=", "configurer", ".", "createInputFlowletSpec", "(", ")", ";", "dataIngestionPortsMap", "=", "Maps", ".", "newHashMap", "(", ")", ";", "int", "httpPort", "=", "0", ";", "if", "(", "ctx", ".", "getRuntimeArguments", "(", ")", ".", "get", "(", "Constants", ".", "HTTP_PORT", ")", "!=", "null", ")", "{", "httpPort", "=", "Integer", ".", "parseInt", "(", "ctx", ".", "getRuntimeArguments", "(", ")", ".", "get", "(", "Constants", ".", "HTTP_PORT", ")", ")", ";", "}", "dataIngestionPortsMap", ".", "put", "(", "Constants", ".", "HTTP_PORT", ",", "httpPort", ")", ";", "for", "(", "String", "inputName", ":", "spec", ".", "getInputSchemas", "(", ")", ".", "keySet", "(", ")", ")", "{", "int", "tcpPort", "=", "0", ";", "if", "(", "ctx", ".", "getRuntimeArguments", "(", ")", ".", "get", "(", "Constants", ".", "TCP_INGESTION_PORT_PREFIX", "+", "inputName", ")", "!=", "null", ")", "{", "tcpPort", "=", "Integer", ".", "parseInt", "(", "ctx", ".", "getRuntimeArguments", "(", ")", ".", "get", "(", "Constants", ".", "TCP_INGESTION_PORT_PREFIX", "+", "inputName", ")", ")", ";", "}", "dataIngestionPortsMap", ".", "put", "(", "Constants", ".", "TCP_INGESTION_PORT_PREFIX", "+", "inputName", ",", "tcpPort", ")", ";", "}", "// Setup temporary directory structure", "tmpFolder", "=", "Files", ".", "createTempDir", "(", ")", ";", "File", "baseDir", "=", "new", "File", "(", "tmpFolder", ",", "\"baseDir\"", ")", ";", "baseDir", ".", "mkdirs", "(", ")", ";", "InputFlowletConfiguration", "inputFlowletConfiguration", "=", "new", "LocalInputFlowletConfiguration", "(", "baseDir", ",", "spec", ")", ";", "File", "binDir", "=", "inputFlowletConfiguration", ".", "createStreamEngineProcesses", "(", ")", ";", "healthInspector", "=", "new", "HealthInspector", "(", "this", ")", ";", "metricsRecorder", "=", "new", "MetricsRecorder", "(", "metrics", ")", ";", "//Initiating AbstractInputFlowlet Components", "recordQueue", "=", "new", "GDATRecordQueue", "(", ")", ";", "//Initiating Netty TCP I/O ports", "inputFlowletService", "=", "new", "InputFlowletService", "(", "binDir", ",", "spec", ",", "healthInspector", ",", "metricsRecorder", ",", "recordQueue", ",", "dataIngestionPortsMap", ",", "this", ")", ";", "inputFlowletService", ".", "startAndWait", "(", ")", ";", "//Starting health monitor service", "healthInspector", ".", "startAndWait", "(", ")", ";", "//Initializing methodsDriver", "Map", "<", "String", ",", "StreamSchema", ">", "schemaMap", "=", "MetaInformationParser", ".", "getSchemaMap", "(", "new", "File", "(", "binDir", ".", "toURI", "(", ")", ")", ")", ";", "methodsDriver", "=", "new", "MethodsDriver", "(", "this", ",", "schemaMap", ")", ";", "//Initialize stopwatch and retry counter", "stopwatch", "=", "new", "Stopwatch", "(", ")", ";", "retryCounter", "=", "0", ";", "}" ]
This method initializes all the components required to setup the SQL Compiler environment.
[ "This", "method", "initializes", "all", "the", "components", "required", "to", "setup", "the", "SQL", "Compiler", "environment", "." ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-sql/src/main/java/co/cask/tigon/sql/flowlet/AbstractInputFlowlet.java#L184-L235
1,114
cdapio/tigon
tigon-sql/src/main/java/co/cask/tigon/sql/flowlet/AbstractInputFlowlet.java
AbstractInputFlowlet.processGDATRecords
@Tick(delay = 200L, unit = TimeUnit.MILLISECONDS) protected void processGDATRecords() throws InvocationTargetException, IllegalAccessException { stopwatch.reset(); stopwatch.start(); while (!recordQueue.isEmpty()) { // Time since start of processing in Seconds long elapsedTime = stopwatch.elapsedTime(TimeUnit.SECONDS); if (elapsedTime >= Constants.TICKER_TIMEOUT) { break; } Map.Entry<String, GDATDecoder> record = recordQueue.getNext(); methodsDriver.invokeMethods(record.getKey(), record.getValue()); } stopwatch.stop(); }
java
@Tick(delay = 200L, unit = TimeUnit.MILLISECONDS) protected void processGDATRecords() throws InvocationTargetException, IllegalAccessException { stopwatch.reset(); stopwatch.start(); while (!recordQueue.isEmpty()) { // Time since start of processing in Seconds long elapsedTime = stopwatch.elapsedTime(TimeUnit.SECONDS); if (elapsedTime >= Constants.TICKER_TIMEOUT) { break; } Map.Entry<String, GDATDecoder> record = recordQueue.getNext(); methodsDriver.invokeMethods(record.getKey(), record.getValue()); } stopwatch.stop(); }
[ "@", "Tick", "(", "delay", "=", "200L", ",", "unit", "=", "TimeUnit", ".", "MILLISECONDS", ")", "protected", "void", "processGDATRecords", "(", ")", "throws", "InvocationTargetException", ",", "IllegalAccessException", "{", "stopwatch", ".", "reset", "(", ")", ";", "stopwatch", ".", "start", "(", ")", ";", "while", "(", "!", "recordQueue", ".", "isEmpty", "(", ")", ")", "{", "// Time since start of processing in Seconds", "long", "elapsedTime", "=", "stopwatch", ".", "elapsedTime", "(", "TimeUnit", ".", "SECONDS", ")", ";", "if", "(", "elapsedTime", ">=", "Constants", ".", "TICKER_TIMEOUT", ")", "{", "break", ";", "}", "Map", ".", "Entry", "<", "String", ",", "GDATDecoder", ">", "record", "=", "recordQueue", ".", "getNext", "(", ")", ";", "methodsDriver", ".", "invokeMethods", "(", "record", ".", "getKey", "(", ")", ",", "record", ".", "getValue", "(", ")", ")", ";", "}", "stopwatch", ".", "stop", "(", ")", ";", "}" ]
This process method consumes the records queued in dataManager and invokes the associated "process" methods for each output query
[ "This", "process", "method", "consumes", "the", "records", "queued", "in", "dataManager", "and", "invokes", "the", "associated", "process", "methods", "for", "each", "output", "query" ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-sql/src/main/java/co/cask/tigon/sql/flowlet/AbstractInputFlowlet.java#L241-L255
1,115
cdapio/tigon
tigon-sql/src/main/java/co/cask/tigon/sql/flowlet/AbstractInputFlowlet.java
AbstractInputFlowlet.notifyFailure
@Override public void notifyFailure(Set<String> errorProcessNames) { if (errorProcessNames != null) { LOG.warn("Missing pings from : " + errorProcessNames.toString()); } else { LOG.warn("No heartbeats registered"); } healthInspector.stopAndWait(); healthInspector = new HealthInspector(this); inputFlowletService.restartService(healthInspector); healthInspector.startAndWait(); }
java
@Override public void notifyFailure(Set<String> errorProcessNames) { if (errorProcessNames != null) { LOG.warn("Missing pings from : " + errorProcessNames.toString()); } else { LOG.warn("No heartbeats registered"); } healthInspector.stopAndWait(); healthInspector = new HealthInspector(this); inputFlowletService.restartService(healthInspector); healthInspector.startAndWait(); }
[ "@", "Override", "public", "void", "notifyFailure", "(", "Set", "<", "String", ">", "errorProcessNames", ")", "{", "if", "(", "errorProcessNames", "!=", "null", ")", "{", "LOG", ".", "warn", "(", "\"Missing pings from : \"", "+", "errorProcessNames", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "LOG", ".", "warn", "(", "\"No heartbeats registered\"", ")", ";", "}", "healthInspector", ".", "stopAndWait", "(", ")", ";", "healthInspector", "=", "new", "HealthInspector", "(", "this", ")", ";", "inputFlowletService", ".", "restartService", "(", "healthInspector", ")", ";", "healthInspector", ".", "startAndWait", "(", ")", ";", "}" ]
ProcessMonitor callback function Restarts SQL Compiler processes
[ "ProcessMonitor", "callback", "function", "Restarts", "SQL", "Compiler", "processes" ]
5be6dffd7c79519d1211bb08f75be7dcfbbad392
https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-sql/src/main/java/co/cask/tigon/sql/flowlet/AbstractInputFlowlet.java#L303-L314
1,116
cketti/ckChangeLog
ckChangeLog/src/main/java/de/cketti/library/changelog/ChangeLog.java
ChangeLog.updateVersionInPreferences
protected void updateVersionInPreferences() { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences.Editor editor = sp.edit(); editor.putInt(VERSION_KEY, mCurrentVersionCode); // TODO: Update preferences from a background thread editor.commit(); }
java
protected void updateVersionInPreferences() { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences.Editor editor = sp.edit(); editor.putInt(VERSION_KEY, mCurrentVersionCode); // TODO: Update preferences from a background thread editor.commit(); }
[ "protected", "void", "updateVersionInPreferences", "(", ")", "{", "SharedPreferences", "sp", "=", "PreferenceManager", ".", "getDefaultSharedPreferences", "(", "mContext", ")", ";", "SharedPreferences", ".", "Editor", "editor", "=", "sp", ".", "edit", "(", ")", ";", "editor", ".", "putInt", "(", "VERSION_KEY", ",", "mCurrentVersionCode", ")", ";", "// TODO: Update preferences from a background thread", "editor", ".", "commit", "(", ")", ";", "}" ]
Write current version code to the preferences.
[ "Write", "current", "version", "code", "to", "the", "preferences", "." ]
e9a81ad3e043357e80922aa7c149241af73223d3
https://github.com/cketti/ckChangeLog/blob/e9a81ad3e043357e80922aa7c149241af73223d3/ckChangeLog/src/main/java/de/cketti/library/changelog/ChangeLog.java#L326-L333
1,117
cketti/ckChangeLog
ckChangeLog/src/main/java/de/cketti/library/changelog/ChangeLog.java
ChangeLog.getChangeLog
public List<ReleaseItem> getChangeLog(boolean full) { SparseArray<ReleaseItem> masterChangelog = getMasterChangeLog(full); SparseArray<ReleaseItem> changelog = getLocalizedChangeLog(full); List<ReleaseItem> mergedChangeLog = new ArrayList<ReleaseItem>(masterChangelog.size()); for (int i = 0, len = masterChangelog.size(); i < len; i++) { int key = masterChangelog.keyAt(i); // Use release information from localized change log and fall back to the master file // if necessary. ReleaseItem release = changelog.get(key, masterChangelog.get(key)); mergedChangeLog.add(release); } Collections.sort(mergedChangeLog, getChangeLogComparator()); return mergedChangeLog; }
java
public List<ReleaseItem> getChangeLog(boolean full) { SparseArray<ReleaseItem> masterChangelog = getMasterChangeLog(full); SparseArray<ReleaseItem> changelog = getLocalizedChangeLog(full); List<ReleaseItem> mergedChangeLog = new ArrayList<ReleaseItem>(masterChangelog.size()); for (int i = 0, len = masterChangelog.size(); i < len; i++) { int key = masterChangelog.keyAt(i); // Use release information from localized change log and fall back to the master file // if necessary. ReleaseItem release = changelog.get(key, masterChangelog.get(key)); mergedChangeLog.add(release); } Collections.sort(mergedChangeLog, getChangeLogComparator()); return mergedChangeLog; }
[ "public", "List", "<", "ReleaseItem", ">", "getChangeLog", "(", "boolean", "full", ")", "{", "SparseArray", "<", "ReleaseItem", ">", "masterChangelog", "=", "getMasterChangeLog", "(", "full", ")", ";", "SparseArray", "<", "ReleaseItem", ">", "changelog", "=", "getLocalizedChangeLog", "(", "full", ")", ";", "List", "<", "ReleaseItem", ">", "mergedChangeLog", "=", "new", "ArrayList", "<", "ReleaseItem", ">", "(", "masterChangelog", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ",", "len", "=", "masterChangelog", ".", "size", "(", ")", ";", "i", "<", "len", ";", "i", "++", ")", "{", "int", "key", "=", "masterChangelog", ".", "keyAt", "(", "i", ")", ";", "// Use release information from localized change log and fall back to the master file", "// if necessary.", "ReleaseItem", "release", "=", "changelog", ".", "get", "(", "key", ",", "masterChangelog", ".", "get", "(", "key", ")", ")", ";", "mergedChangeLog", ".", "add", "(", "release", ")", ";", "}", "Collections", ".", "sort", "(", "mergedChangeLog", ",", "getChangeLogComparator", "(", ")", ")", ";", "return", "mergedChangeLog", ";", "}" ]
Returns the merged change log. @param full If this is {@code true} the full change log is returned. Otherwise only changes for versions newer than the last version are returned. @return A sorted {@code List} containing {@link ReleaseItem}s representing the (partial) change log. @see #getChangeLogComparator()
[ "Returns", "the", "merged", "change", "log", "." ]
e9a81ad3e043357e80922aa7c149241af73223d3
https://github.com/cketti/ckChangeLog/blob/e9a81ad3e043357e80922aa7c149241af73223d3/ckChangeLog/src/main/java/de/cketti/library/changelog/ChangeLog.java#L403-L423
1,118
cketti/ckChangeLog
ckChangeLog/src/main/java/de/cketti/library/changelog/ChangeLog.java
ChangeLog.readChangeLogFromResource
protected final SparseArray<ReleaseItem> readChangeLogFromResource(int resId, boolean full) { XmlResourceParser xml = mContext.getResources().getXml(resId); try { return readChangeLog(xml, full); } finally { xml.close(); } }
java
protected final SparseArray<ReleaseItem> readChangeLogFromResource(int resId, boolean full) { XmlResourceParser xml = mContext.getResources().getXml(resId); try { return readChangeLog(xml, full); } finally { xml.close(); } }
[ "protected", "final", "SparseArray", "<", "ReleaseItem", ">", "readChangeLogFromResource", "(", "int", "resId", ",", "boolean", "full", ")", "{", "XmlResourceParser", "xml", "=", "mContext", ".", "getResources", "(", ")", ".", "getXml", "(", "resId", ")", ";", "try", "{", "return", "readChangeLog", "(", "xml", ",", "full", ")", ";", "}", "finally", "{", "xml", ".", "close", "(", ")", ";", "}", "}" ]
Read change log from XML resource file. @param resId Resource ID of the XML file to read the change log from. @param full If this is {@code true} the full change log is returned. Otherwise only changes for versions newer than the last version are returned. @return A {@code SparseArray} containing {@link ReleaseItem}s representing the (partial) change log.
[ "Read", "change", "log", "from", "XML", "resource", "file", "." ]
e9a81ad3e043357e80922aa7c149241af73223d3
https://github.com/cketti/ckChangeLog/blob/e9a81ad3e043357e80922aa7c149241af73223d3/ckChangeLog/src/main/java/de/cketti/library/changelog/ChangeLog.java#L455-L462
1,119
cketti/ckChangeLog
ckChangeLog/src/main/java/de/cketti/library/changelog/ChangeLog.java
ChangeLog.readChangeLog
protected SparseArray<ReleaseItem> readChangeLog(XmlPullParser xml, boolean full) { SparseArray<ReleaseItem> result = new SparseArray<ReleaseItem>(); try { int eventType = xml.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && xml.getName().equals(ReleaseTag.NAME)) { if (parseReleaseTag(xml, full, result)) { // Stop reading more elements if this entry is not newer than the last // version. break; } } eventType = xml.next(); } } catch (XmlPullParserException e) { Log.e(LOG_TAG, e.getMessage(), e); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } return result; }
java
protected SparseArray<ReleaseItem> readChangeLog(XmlPullParser xml, boolean full) { SparseArray<ReleaseItem> result = new SparseArray<ReleaseItem>(); try { int eventType = xml.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && xml.getName().equals(ReleaseTag.NAME)) { if (parseReleaseTag(xml, full, result)) { // Stop reading more elements if this entry is not newer than the last // version. break; } } eventType = xml.next(); } } catch (XmlPullParserException e) { Log.e(LOG_TAG, e.getMessage(), e); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } return result; }
[ "protected", "SparseArray", "<", "ReleaseItem", ">", "readChangeLog", "(", "XmlPullParser", "xml", ",", "boolean", "full", ")", "{", "SparseArray", "<", "ReleaseItem", ">", "result", "=", "new", "SparseArray", "<", "ReleaseItem", ">", "(", ")", ";", "try", "{", "int", "eventType", "=", "xml", ".", "getEventType", "(", ")", ";", "while", "(", "eventType", "!=", "XmlPullParser", ".", "END_DOCUMENT", ")", "{", "if", "(", "eventType", "==", "XmlPullParser", ".", "START_TAG", "&&", "xml", ".", "getName", "(", ")", ".", "equals", "(", "ReleaseTag", ".", "NAME", ")", ")", "{", "if", "(", "parseReleaseTag", "(", "xml", ",", "full", ",", "result", ")", ")", "{", "// Stop reading more elements if this entry is not newer than the last", "// version.", "break", ";", "}", "}", "eventType", "=", "xml", ".", "next", "(", ")", ";", "}", "}", "catch", "(", "XmlPullParserException", "e", ")", "{", "Log", ".", "e", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "Log", ".", "e", "(", "LOG_TAG", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "return", "result", ";", "}" ]
Read the change log from an XML file. @param xml The {@code XmlPullParser} instance used to read the change log. @param full If {@code true} the full change log is read. Otherwise only the changes since the last (saved) version are read. @return A {@code SparseArray} mapping the version codes to release information.
[ "Read", "the", "change", "log", "from", "an", "XML", "file", "." ]
e9a81ad3e043357e80922aa7c149241af73223d3
https://github.com/cketti/ckChangeLog/blob/e9a81ad3e043357e80922aa7c149241af73223d3/ckChangeLog/src/main/java/de/cketti/library/changelog/ChangeLog.java#L475-L497
1,120
tony19/named-regexp
src/main/java/com/google/code/regexp/Matcher.java
Matcher.orderedGroups
public List<String> orderedGroups() { int groupCount = groupCount(); List<String> groups = new ArrayList<String>(groupCount); for (int i = 1; i <= groupCount; i++) { groups.add(group(i)); } return groups; }
java
public List<String> orderedGroups() { int groupCount = groupCount(); List<String> groups = new ArrayList<String>(groupCount); for (int i = 1; i <= groupCount; i++) { groups.add(group(i)); } return groups; }
[ "public", "List", "<", "String", ">", "orderedGroups", "(", ")", "{", "int", "groupCount", "=", "groupCount", "(", ")", ";", "List", "<", "String", ">", "groups", "=", "new", "ArrayList", "<", "String", ">", "(", "groupCount", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "groupCount", ";", "i", "++", ")", "{", "groups", ".", "add", "(", "group", "(", "i", ")", ")", ";", "}", "return", "groups", ";", "}" ]
Gets a list of the matches in the order in which they occur in a matching input string @return the matches
[ "Gets", "a", "list", "of", "the", "matches", "in", "the", "order", "in", "which", "they", "occur", "in", "a", "matching", "input", "string" ]
cfccef2f69b5a5ed7e37cfa879d1623dc1213def
https://github.com/tony19/named-regexp/blob/cfccef2f69b5a5ed7e37cfa879d1623dc1213def/src/main/java/com/google/code/regexp/Matcher.java#L257-L264
1,121
tony19/named-regexp
src/main/java/com/google/code/regexp/Matcher.java
Matcher.group
public String group(String groupName) { int idx = groupIndex(groupName); if (idx < 0) { throw new IndexOutOfBoundsException("No group \"" + groupName + "\""); } return group(idx); }
java
public String group(String groupName) { int idx = groupIndex(groupName); if (idx < 0) { throw new IndexOutOfBoundsException("No group \"" + groupName + "\""); } return group(idx); }
[ "public", "String", "group", "(", "String", "groupName", ")", "{", "int", "idx", "=", "groupIndex", "(", "groupName", ")", ";", "if", "(", "idx", "<", "0", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", "\"No group \\\"\"", "+", "groupName", "+", "\"\\\"\"", ")", ";", "}", "return", "group", "(", "idx", ")", ";", "}" ]
Returns the input subsequence captured by the named group during the previous match operation. @param groupName name of the capture group @return the subsequence @throws IndexOutOfBoundsException if group name not found
[ "Returns", "the", "input", "subsequence", "captured", "by", "the", "named", "group", "during", "the", "previous", "match", "operation", "." ]
cfccef2f69b5a5ed7e37cfa879d1623dc1213def
https://github.com/tony19/named-regexp/blob/cfccef2f69b5a5ed7e37cfa879d1623dc1213def/src/main/java/com/google/code/regexp/Matcher.java#L274-L280
1,122
tony19/named-regexp
src/main/java/com/google/code/regexp/Matcher.java
Matcher.namedGroups
public List<Map<String, String>> namedGroups() { List<Map<String, String>> result = new ArrayList<Map<String, String>>(); List<String> groupNames = parentPattern.groupNames(); if (groupNames.isEmpty()) { return result; } int nextIndex = 0; while (matcher.find(nextIndex)) { Map<String, String> matches = new LinkedHashMap<String, String>(); for (String groupName : groupNames) { String groupValue = matcher.group(groupIndex(groupName)); matches.put(groupName, groupValue); nextIndex = matcher.end(); } result.add(matches); } return result; }
java
public List<Map<String, String>> namedGroups() { List<Map<String, String>> result = new ArrayList<Map<String, String>>(); List<String> groupNames = parentPattern.groupNames(); if (groupNames.isEmpty()) { return result; } int nextIndex = 0; while (matcher.find(nextIndex)) { Map<String, String> matches = new LinkedHashMap<String, String>(); for (String groupName : groupNames) { String groupValue = matcher.group(groupIndex(groupName)); matches.put(groupName, groupValue); nextIndex = matcher.end(); } result.add(matches); } return result; }
[ "public", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "namedGroups", "(", ")", "{", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "result", "=", "new", "ArrayList", "<", "Map", "<", "String", ",", "String", ">", ">", "(", ")", ";", "List", "<", "String", ">", "groupNames", "=", "parentPattern", ".", "groupNames", "(", ")", ";", "if", "(", "groupNames", ".", "isEmpty", "(", ")", ")", "{", "return", "result", ";", "}", "int", "nextIndex", "=", "0", ";", "while", "(", "matcher", ".", "find", "(", "nextIndex", ")", ")", "{", "Map", "<", "String", ",", "String", ">", "matches", "=", "new", "LinkedHashMap", "<", "String", ",", "String", ">", "(", ")", ";", "for", "(", "String", "groupName", ":", "groupNames", ")", "{", "String", "groupValue", "=", "matcher", ".", "group", "(", "groupIndex", "(", "groupName", ")", ")", ";", "matches", ".", "put", "(", "groupName", ",", "groupValue", ")", ";", "nextIndex", "=", "matcher", ".", "end", "(", ")", ";", "}", "result", ".", "add", "(", "matches", ")", ";", "}", "return", "result", ";", "}" ]
Finds all named groups that exist in the input string. This resets the matcher and attempts to match the input against the pre-specified pattern. @return a list of maps, each containing name-value matches (empty if no match found). Example: pattern: (?&lt;dote&gt;\d+).(?&lt;day&gt;\w+) input: 1 Sun foo bar 2 Mon foo output: [{"date":"1", "day":"Sun"}, {"date":"2", "day":"Mon"}]
[ "Finds", "all", "named", "groups", "that", "exist", "in", "the", "input", "string", ".", "This", "resets", "the", "matcher", "and", "attempts", "to", "match", "the", "input", "against", "the", "pre", "-", "specified", "pattern", "." ]
cfccef2f69b5a5ed7e37cfa879d1623dc1213def
https://github.com/tony19/named-regexp/blob/cfccef2f69b5a5ed7e37cfa879d1623dc1213def/src/main/java/com/google/code/regexp/Matcher.java#L295-L316
1,123
tony19/named-regexp
src/main/java/com/google/code/regexp/Pattern.java
Pattern.groupNames
public List<String> groupNames() { if (groupNames == null) { groupNames = new ArrayList<String>(groupInfo.keySet()); } return Collections.unmodifiableList(groupNames); }
java
public List<String> groupNames() { if (groupNames == null) { groupNames = new ArrayList<String>(groupInfo.keySet()); } return Collections.unmodifiableList(groupNames); }
[ "public", "List", "<", "String", ">", "groupNames", "(", ")", "{", "if", "(", "groupNames", "==", "null", ")", "{", "groupNames", "=", "new", "ArrayList", "<", "String", ">", "(", "groupInfo", ".", "keySet", "(", ")", ")", ";", "}", "return", "Collections", ".", "unmodifiableList", "(", "groupNames", ")", ";", "}" ]
Gets the names of all capture groups @return the list of names
[ "Gets", "the", "names", "of", "all", "capture", "groups" ]
cfccef2f69b5a5ed7e37cfa879d1623dc1213def
https://github.com/tony19/named-regexp/blob/cfccef2f69b5a5ed7e37cfa879d1623dc1213def/src/main/java/com/google/code/regexp/Pattern.java#L231-L236
1,124
tony19/named-regexp
src/main/java/com/google/code/regexp/Pattern.java
Pattern.groupInfoMatches
private boolean groupInfoMatches(Map<String, List<GroupInfo>> a, Map<String, List<GroupInfo>> b) { if (a == null && b == null) { return true; } boolean isMatch = false; if (a != null && b != null) { if (a.isEmpty() && b.isEmpty()) { isMatch = true; } else if (a.size() == b.size()) { for (Entry<String, List<GroupInfo>> entry : a.entrySet()) { List<GroupInfo> otherList = b.get(entry.getKey()); isMatch = (otherList != null); if (!isMatch) { break; } List<GroupInfo> thisList = entry.getValue(); isMatch = otherList.containsAll(thisList) && thisList.containsAll(otherList); if (!isMatch) { break; } } } } return isMatch; }
java
private boolean groupInfoMatches(Map<String, List<GroupInfo>> a, Map<String, List<GroupInfo>> b) { if (a == null && b == null) { return true; } boolean isMatch = false; if (a != null && b != null) { if (a.isEmpty() && b.isEmpty()) { isMatch = true; } else if (a.size() == b.size()) { for (Entry<String, List<GroupInfo>> entry : a.entrySet()) { List<GroupInfo> otherList = b.get(entry.getKey()); isMatch = (otherList != null); if (!isMatch) { break; } List<GroupInfo> thisList = entry.getValue(); isMatch = otherList.containsAll(thisList) && thisList.containsAll(otherList); if (!isMatch) { break; } } } } return isMatch; }
[ "private", "boolean", "groupInfoMatches", "(", "Map", "<", "String", ",", "List", "<", "GroupInfo", ">", ">", "a", ",", "Map", "<", "String", ",", "List", "<", "GroupInfo", ">", ">", "b", ")", "{", "if", "(", "a", "==", "null", "&&", "b", "==", "null", ")", "{", "return", "true", ";", "}", "boolean", "isMatch", "=", "false", ";", "if", "(", "a", "!=", "null", "&&", "b", "!=", "null", ")", "{", "if", "(", "a", ".", "isEmpty", "(", ")", "&&", "b", ".", "isEmpty", "(", ")", ")", "{", "isMatch", "=", "true", ";", "}", "else", "if", "(", "a", ".", "size", "(", ")", "==", "b", ".", "size", "(", ")", ")", "{", "for", "(", "Entry", "<", "String", ",", "List", "<", "GroupInfo", ">", ">", "entry", ":", "a", ".", "entrySet", "(", ")", ")", "{", "List", "<", "GroupInfo", ">", "otherList", "=", "b", ".", "get", "(", "entry", ".", "getKey", "(", ")", ")", ";", "isMatch", "=", "(", "otherList", "!=", "null", ")", ";", "if", "(", "!", "isMatch", ")", "{", "break", ";", "}", "List", "<", "GroupInfo", ">", "thisList", "=", "entry", ".", "getValue", "(", ")", ";", "isMatch", "=", "otherList", ".", "containsAll", "(", "thisList", ")", "&&", "thisList", ".", "containsAll", "(", "otherList", ")", ";", "if", "(", "!", "isMatch", ")", "{", "break", ";", "}", "}", "}", "}", "return", "isMatch", ";", "}" ]
Compares the keys and values of two group-info maps @param a the first map to compare @param b the other map to compare @return {@code true} if the first map contains all of the other map's keys and values; {@code false} otherwise
[ "Compares", "the", "keys", "and", "values", "of", "two", "group", "-", "info", "maps" ]
cfccef2f69b5a5ed7e37cfa879d1623dc1213def
https://github.com/tony19/named-regexp/blob/cfccef2f69b5a5ed7e37cfa879d1623dc1213def/src/main/java/com/google/code/regexp/Pattern.java#L619-L645
1,125
KlausBrunner/solarpositioning
src/main/java/net/e175/klaus/solarpositioning/SPA.java
SPA.limitHprime
private static double limitHprime(double hPrime) { hPrime /= 360.0; final double limited = 360.0 * (hPrime - floor(hPrime)); if (limited < -180.0) { return limited + 360.0; } else if (limited > 180.0) { return limited - 360.0; } else { return limited; } }
java
private static double limitHprime(double hPrime) { hPrime /= 360.0; final double limited = 360.0 * (hPrime - floor(hPrime)); if (limited < -180.0) { return limited + 360.0; } else if (limited > 180.0) { return limited - 360.0; } else { return limited; } }
[ "private", "static", "double", "limitHprime", "(", "double", "hPrime", ")", "{", "hPrime", "/=", "360.0", ";", "final", "double", "limited", "=", "360.0", "*", "(", "hPrime", "-", "floor", "(", "hPrime", ")", ")", ";", "if", "(", "limited", "<", "-", "180.0", ")", "{", "return", "limited", "+", "360.0", ";", "}", "else", "if", "(", "limited", ">", "180.0", ")", "{", "return", "limited", "-", "360.0", ";", "}", "else", "{", "return", "limited", ";", "}", "}" ]
limit H' values according to A.2.11
[ "limit", "H", "values", "according", "to", "A", ".", "2", ".", "11" ]
25db9b5e966ea325d88bb3b374103f104de256de
https://github.com/KlausBrunner/solarpositioning/blob/25db9b5e966ea325d88bb3b374103f104de256de/src/main/java/net/e175/klaus/solarpositioning/SPA.java#L324-L335
1,126
jeevatkm/spring-extensions
src/main/java/com/myjeeva/spring/security/util/CrossDomainMapperImpl.java
CrossDomainMapperImpl.lookupHttpCrossDomain
public String lookupHttpCrossDomain(String httpsDomainName) { Iterator iter = crossDomainMappings.keySet().iterator(); while (iter.hasNext()) { String httpDomainName = (String) iter.next(); if (crossDomainMappings.get(httpDomainName).equals(httpsDomainName)) { return httpDomainName; } } return null; }
java
public String lookupHttpCrossDomain(String httpsDomainName) { Iterator iter = crossDomainMappings.keySet().iterator(); while (iter.hasNext()) { String httpDomainName = (String) iter.next(); if (crossDomainMappings.get(httpDomainName).equals(httpsDomainName)) { return httpDomainName; } } return null; }
[ "public", "String", "lookupHttpCrossDomain", "(", "String", "httpsDomainName", ")", "{", "Iterator", "iter", "=", "crossDomainMappings", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "String", "httpDomainName", "=", "(", "String", ")", "iter", ".", "next", "(", ")", ";", "if", "(", "crossDomainMappings", ".", "get", "(", "httpDomainName", ")", ".", "equals", "(", "httpsDomainName", ")", ")", "{", "return", "httpDomainName", ";", "}", "}", "return", "null", ";", "}" ]
returns the HTTP domain Name
[ "returns", "the", "HTTP", "domain", "Name" ]
55d46a98518f45aa56a2cd8ca838149ee3904372
https://github.com/jeevatkm/spring-extensions/blob/55d46a98518f45aa56a2cd8ca838149ee3904372/src/main/java/com/myjeeva/spring/security/util/CrossDomainMapperImpl.java#L59-L71
1,127
jeevatkm/spring-extensions
src/main/java/com/myjeeva/spring/security/secureuri/SecureServerURI.java
SecureServerURI.badRequest
private void badRequest(HttpServletResponse res) throws IOException { res.setContentType("text/html"); PrintWriter pw = res.getWriter(); pw.write(BAD_REQUEST); pw.close(); }
java
private void badRequest(HttpServletResponse res) throws IOException { res.setContentType("text/html"); PrintWriter pw = res.getWriter(); pw.write(BAD_REQUEST); pw.close(); }
[ "private", "void", "badRequest", "(", "HttpServletResponse", "res", ")", "throws", "IOException", "{", "res", ".", "setContentType", "(", "\"text/html\"", ")", ";", "PrintWriter", "pw", "=", "res", ".", "getWriter", "(", ")", ";", "pw", ".", "write", "(", "BAD_REQUEST", ")", ";", "pw", ".", "close", "(", ")", ";", "}" ]
writes the Bad Request String in the Servlet response if condition falis @param res a {@link javax.servlet.http.HttpServletResponse} object @throws IOException
[ "writes", "the", "Bad", "Request", "String", "in", "the", "Servlet", "response", "if", "condition", "falis" ]
55d46a98518f45aa56a2cd8ca838149ee3904372
https://github.com/jeevatkm/spring-extensions/blob/55d46a98518f45aa56a2cd8ca838149ee3904372/src/main/java/com/myjeeva/spring/security/secureuri/SecureServerURI.java#L153-L158
1,128
jeevatkm/spring-extensions
src/main/java/com/myjeeva/spring/security/util/SpringExtensionsUtil.java
SpringExtensionsUtil.getMD5
public static String getMD5(String md5Salt) { try { MessageDigest md = MessageDigest.getInstance(MD5); byte[] array = md.digest(md5Salt.getBytes(UTF8)); StringBuffer sb = new StringBuffer(); for (int i = 0; i < array.length; ++i) { sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3)); } return sb.toString(); } catch (java.security.NoSuchAlgorithmException e) { LOG.error(e.getMessage()); } catch (UnsupportedEncodingException e) { LOG.error(e.getMessage()); } return null; }
java
public static String getMD5(String md5Salt) { try { MessageDigest md = MessageDigest.getInstance(MD5); byte[] array = md.digest(md5Salt.getBytes(UTF8)); StringBuffer sb = new StringBuffer(); for (int i = 0; i < array.length; ++i) { sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3)); } return sb.toString(); } catch (java.security.NoSuchAlgorithmException e) { LOG.error(e.getMessage()); } catch (UnsupportedEncodingException e) { LOG.error(e.getMessage()); } return null; }
[ "public", "static", "String", "getMD5", "(", "String", "md5Salt", ")", "{", "try", "{", "MessageDigest", "md", "=", "MessageDigest", ".", "getInstance", "(", "MD5", ")", ";", "byte", "[", "]", "array", "=", "md", ".", "digest", "(", "md5Salt", ".", "getBytes", "(", "UTF8", ")", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "++", "i", ")", "{", "sb", ".", "append", "(", "Integer", ".", "toHexString", "(", "(", "array", "[", "i", "]", "&", "0xFF", ")", "|", "0x100", ")", ".", "substring", "(", "1", ",", "3", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "catch", "(", "java", ".", "security", ".", "NoSuchAlgorithmException", "e", ")", "{", "LOG", ".", "error", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "LOG", ".", "error", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
generates the MD5 Hash value from given salt value @param md5Salt - a {@link java.lang.String} object. @return md5 hash value if success, <code>null</code> if exception/fails
[ "generates", "the", "MD5", "Hash", "value", "from", "given", "salt", "value" ]
55d46a98518f45aa56a2cd8ca838149ee3904372
https://github.com/jeevatkm/spring-extensions/blob/55d46a98518f45aa56a2cd8ca838149ee3904372/src/main/java/com/myjeeva/spring/security/util/SpringExtensionsUtil.java#L55-L70
1,129
codelibs/minhash
src/main/java/org/codelibs/minhash/MinHash.java
MinHash.compare
public static float compare(final int numOfBits, final String str1, final String str2) { return compare(numOfBits, BaseEncoding.base64().decode(str1), BaseEncoding.base64().decode(str2)); }
java
public static float compare(final int numOfBits, final String str1, final String str2) { return compare(numOfBits, BaseEncoding.base64().decode(str1), BaseEncoding.base64().decode(str2)); }
[ "public", "static", "float", "compare", "(", "final", "int", "numOfBits", ",", "final", "String", "str1", ",", "final", "String", "str2", ")", "{", "return", "compare", "(", "numOfBits", ",", "BaseEncoding", ".", "base64", "(", ")", ".", "decode", "(", "str1", ")", ",", "BaseEncoding", ".", "base64", "(", ")", ".", "decode", "(", "str2", ")", ")", ";", "}" ]
Compare base64 strings for MinHash. @param numOfBits The number of MinHash bits @param str1 MinHash base64 string @param str2 MinHash base64 string @return similarity (0 to 1.0f)
[ "Compare", "base64", "strings", "for", "MinHash", "." ]
2aaa16e3096461c0f550d0eb462ae9e69d1b7749
https://github.com/codelibs/minhash/blob/2aaa16e3096461c0f550d0eb462ae9e69d1b7749/src/main/java/org/codelibs/minhash/MinHash.java#L36-L40
1,130
codelibs/minhash
src/main/java/org/codelibs/minhash/MinHash.java
MinHash.compare
public static float compare(final int numOfBits, final byte[] data1, final byte[] data2) { if (data1.length != data2.length) { return 0; } final int count = countSameBits(data1, data2); return (float) count / (float) numOfBits; }
java
public static float compare(final int numOfBits, final byte[] data1, final byte[] data2) { if (data1.length != data2.length) { return 0; } final int count = countSameBits(data1, data2); return (float) count / (float) numOfBits; }
[ "public", "static", "float", "compare", "(", "final", "int", "numOfBits", ",", "final", "byte", "[", "]", "data1", ",", "final", "byte", "[", "]", "data2", ")", "{", "if", "(", "data1", ".", "length", "!=", "data2", ".", "length", ")", "{", "return", "0", ";", "}", "final", "int", "count", "=", "countSameBits", "(", "data1", ",", "data2", ")", ";", "return", "(", "float", ")", "count", "/", "(", "float", ")", "numOfBits", ";", "}" ]
Compare bytes for MinHash. @param numOfBits The number of MinHash bits @param data1 MinHash bytes @param data2 MinHash bytes @return similarity (0 to 1.0f)
[ "Compare", "bytes", "for", "MinHash", "." ]
2aaa16e3096461c0f550d0eb462ae9e69d1b7749
https://github.com/codelibs/minhash/blob/2aaa16e3096461c0f550d0eb462ae9e69d1b7749/src/main/java/org/codelibs/minhash/MinHash.java#L73-L80
1,131
codelibs/minhash
src/main/java/org/codelibs/minhash/MinHash.java
MinHash.createHashFunctions
public static HashFunction[] createHashFunctions(final int seed, final int num) { final HashFunction[] hashFunctions = new HashFunction[num]; for (int i = 0; i < num; i++) { hashFunctions[i] = Hashing.murmur3_128(seed + i); } return hashFunctions; }
java
public static HashFunction[] createHashFunctions(final int seed, final int num) { final HashFunction[] hashFunctions = new HashFunction[num]; for (int i = 0; i < num; i++) { hashFunctions[i] = Hashing.murmur3_128(seed + i); } return hashFunctions; }
[ "public", "static", "HashFunction", "[", "]", "createHashFunctions", "(", "final", "int", "seed", ",", "final", "int", "num", ")", "{", "final", "HashFunction", "[", "]", "hashFunctions", "=", "new", "HashFunction", "[", "num", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "num", ";", "i", "++", ")", "{", "hashFunctions", "[", "i", "]", "=", "Hashing", ".", "murmur3_128", "(", "seed", "+", "i", ")", ";", "}", "return", "hashFunctions", ";", "}" ]
Create hash functions. @param seed a base seed @param num the number of hash functions. @return
[ "Create", "hash", "functions", "." ]
2aaa16e3096461c0f550d0eb462ae9e69d1b7749
https://github.com/codelibs/minhash/blob/2aaa16e3096461c0f550d0eb462ae9e69d1b7749/src/main/java/org/codelibs/minhash/MinHash.java#L105-L112
1,132
codelibs/minhash
src/main/java/org/codelibs/minhash/MinHash.java
MinHash.toBinaryString
public static String toBinaryString(final byte[] data) { if (data == null) { return null; } final StringBuilder buf = new StringBuilder(data.length * 8); for (final byte element : data) { byte bits = element; for (int j = 0; j < 8; j++) { if ((bits & 0x80) == 0x80) { buf.append('1'); } else { buf.append('0'); } bits <<= 1; } } return buf.toString(); }
java
public static String toBinaryString(final byte[] data) { if (data == null) { return null; } final StringBuilder buf = new StringBuilder(data.length * 8); for (final byte element : data) { byte bits = element; for (int j = 0; j < 8; j++) { if ((bits & 0x80) == 0x80) { buf.append('1'); } else { buf.append('0'); } bits <<= 1; } } return buf.toString(); }
[ "public", "static", "String", "toBinaryString", "(", "final", "byte", "[", "]", "data", ")", "{", "if", "(", "data", "==", "null", ")", "{", "return", "null", ";", "}", "final", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", "data", ".", "length", "*", "8", ")", ";", "for", "(", "final", "byte", "element", ":", "data", ")", "{", "byte", "bits", "=", "element", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "8", ";", "j", "++", ")", "{", "if", "(", "(", "bits", "&", "0x80", ")", "==", "0x80", ")", "{", "buf", ".", "append", "(", "'", "'", ")", ";", "}", "else", "{", "buf", ".", "append", "(", "'", "'", ")", ";", "}", "bits", "<<=", "1", ";", "}", "}", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
Returns a string formatted by bits. @param data @return
[ "Returns", "a", "string", "formatted", "by", "bits", "." ]
2aaa16e3096461c0f550d0eb462ae9e69d1b7749
https://github.com/codelibs/minhash/blob/2aaa16e3096461c0f550d0eb462ae9e69d1b7749/src/main/java/org/codelibs/minhash/MinHash.java#L188-L205
1,133
codelibs/minhash
src/main/java/org/codelibs/minhash/MinHash.java
MinHash.bitCount
public static int bitCount(final byte[] data) { int count = 0; for (final byte element : data) { byte bits = element; for (int j = 0; j < 8; j++) { if ((bits & 1) == 1) { count++; } bits >>= 1; } } return count; }
java
public static int bitCount(final byte[] data) { int count = 0; for (final byte element : data) { byte bits = element; for (int j = 0; j < 8; j++) { if ((bits & 1) == 1) { count++; } bits >>= 1; } } return count; }
[ "public", "static", "int", "bitCount", "(", "final", "byte", "[", "]", "data", ")", "{", "int", "count", "=", "0", ";", "for", "(", "final", "byte", "element", ":", "data", ")", "{", "byte", "bits", "=", "element", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "8", ";", "j", "++", ")", "{", "if", "(", "(", "bits", "&", "1", ")", "==", "1", ")", "{", "count", "++", ";", "}", "bits", ">>=", "1", ";", "}", "}", "return", "count", ";", "}" ]
Count the number of true bits. @param data a target data @return the number of true bits
[ "Count", "the", "number", "of", "true", "bits", "." ]
2aaa16e3096461c0f550d0eb462ae9e69d1b7749
https://github.com/codelibs/minhash/blob/2aaa16e3096461c0f550d0eb462ae9e69d1b7749/src/main/java/org/codelibs/minhash/MinHash.java#L213-L225
1,134
codelibs/minhash
src/main/java/org/codelibs/minhash/MinHash.java
MinHash.createAnalyzer
public static Analyzer createAnalyzer(final Tokenizer tokenizer, final int hashBit, final int seed, final int num) { final HashFunction[] hashFunctions = MinHash.createHashFunctions(seed, num); final Analyzer minhashAnalyzer = new Analyzer() { @Override protected TokenStreamComponents createComponents( final String fieldName) { final TokenStream stream = new MinHashTokenFilter( tokenizer, hashFunctions, hashBit); return new TokenStreamComponents(tokenizer, stream); } }; return minhashAnalyzer; }
java
public static Analyzer createAnalyzer(final Tokenizer tokenizer, final int hashBit, final int seed, final int num) { final HashFunction[] hashFunctions = MinHash.createHashFunctions(seed, num); final Analyzer minhashAnalyzer = new Analyzer() { @Override protected TokenStreamComponents createComponents( final String fieldName) { final TokenStream stream = new MinHashTokenFilter( tokenizer, hashFunctions, hashBit); return new TokenStreamComponents(tokenizer, stream); } }; return minhashAnalyzer; }
[ "public", "static", "Analyzer", "createAnalyzer", "(", "final", "Tokenizer", "tokenizer", ",", "final", "int", "hashBit", ",", "final", "int", "seed", ",", "final", "int", "num", ")", "{", "final", "HashFunction", "[", "]", "hashFunctions", "=", "MinHash", ".", "createHashFunctions", "(", "seed", ",", "num", ")", ";", "final", "Analyzer", "minhashAnalyzer", "=", "new", "Analyzer", "(", ")", "{", "@", "Override", "protected", "TokenStreamComponents", "createComponents", "(", "final", "String", "fieldName", ")", "{", "final", "TokenStream", "stream", "=", "new", "MinHashTokenFilter", "(", "tokenizer", ",", "hashFunctions", ",", "hashBit", ")", ";", "return", "new", "TokenStreamComponents", "(", "tokenizer", ",", "stream", ")", ";", "}", "}", ";", "return", "minhashAnalyzer", ";", "}" ]
Create an analyzer to calculate a minhash. @param tokenizer a tokenizer to parse a text @param hashBit the number of hash bits @param seed a base seed for hash function @param num the number of hash functions @return analyzer used by {@link MinHash#calculate(Analyzer, String)}
[ "Create", "an", "analyzer", "to", "calculate", "a", "minhash", "." ]
2aaa16e3096461c0f550d0eb462ae9e69d1b7749
https://github.com/codelibs/minhash/blob/2aaa16e3096461c0f550d0eb462ae9e69d1b7749/src/main/java/org/codelibs/minhash/MinHash.java#L249-L263
1,135
codelibs/minhash
src/main/java/org/codelibs/minhash/MinHash.java
MinHash.newData
public static Data newData(final Analyzer analyzer, final String text, final int numOfBits) { return new Data(analyzer, text, numOfBits); }
java
public static Data newData(final Analyzer analyzer, final String text, final int numOfBits) { return new Data(analyzer, text, numOfBits); }
[ "public", "static", "Data", "newData", "(", "final", "Analyzer", "analyzer", ",", "final", "String", "text", ",", "final", "int", "numOfBits", ")", "{", "return", "new", "Data", "(", "analyzer", ",", "text", ",", "numOfBits", ")", ";", "}" ]
Create a target data which has analyzer, text and the number of bits. @param analyzer @param text @param numOfBits @return
[ "Create", "a", "target", "data", "which", "has", "analyzer", "text", "and", "the", "number", "of", "bits", "." ]
2aaa16e3096461c0f550d0eb462ae9e69d1b7749
https://github.com/codelibs/minhash/blob/2aaa16e3096461c0f550d0eb462ae9e69d1b7749/src/main/java/org/codelibs/minhash/MinHash.java#L273-L276
1,136
qmx/jitescript
src/main/java/me/qmx/jitescript/JiteClass.java
JiteClass.defineMethod
public void defineMethod(String methodName, int modifiers, String signature, CodeBlock methodBody) { this.methods.add(new MethodDefinition(methodName, modifiers, signature, methodBody)); }
java
public void defineMethod(String methodName, int modifiers, String signature, CodeBlock methodBody) { this.methods.add(new MethodDefinition(methodName, modifiers, signature, methodBody)); }
[ "public", "void", "defineMethod", "(", "String", "methodName", ",", "int", "modifiers", ",", "String", "signature", ",", "CodeBlock", "methodBody", ")", "{", "this", ".", "methods", ".", "add", "(", "new", "MethodDefinition", "(", "methodName", ",", "modifiers", ",", "signature", ",", "methodBody", ")", ")", ";", "}" ]
Defines a new method on the target class @param methodName the method name @param modifiers the modifier bitmask, made by OR'ing constants from ASM's {@link Opcodes} interface @param signature the method signature, on standard JVM notation @param methodBody the method body
[ "Defines", "a", "new", "method", "on", "the", "target", "class" ]
bda6d02f37a8083248d9a0c80ea76bb5a63151ae
https://github.com/qmx/jitescript/blob/bda6d02f37a8083248d9a0c80ea76bb5a63151ae/src/main/java/me/qmx/jitescript/JiteClass.java#L142-L144
1,137
qmx/jitescript
src/main/java/me/qmx/jitescript/JiteClass.java
JiteClass.defineField
public FieldDefinition defineField(String fieldName, int modifiers, String signature, Object value) { FieldDefinition field = new FieldDefinition(fieldName, modifiers, signature, value); this.fields.add(field); return field; }
java
public FieldDefinition defineField(String fieldName, int modifiers, String signature, Object value) { FieldDefinition field = new FieldDefinition(fieldName, modifiers, signature, value); this.fields.add(field); return field; }
[ "public", "FieldDefinition", "defineField", "(", "String", "fieldName", ",", "int", "modifiers", ",", "String", "signature", ",", "Object", "value", ")", "{", "FieldDefinition", "field", "=", "new", "FieldDefinition", "(", "fieldName", ",", "modifiers", ",", "signature", ",", "value", ")", ";", "this", ".", "fields", ".", "add", "(", "field", ")", ";", "return", "field", ";", "}" ]
Defines a new field on the target class @param fieldName the field name @param modifiers the modifier bitmask, made by OR'ing constants from ASM's {@link Opcodes} interface @param signature the field signature, on standard JVM notation @param value the default value (null for JVM default) @return the new field definition for further modification
[ "Defines", "a", "new", "field", "on", "the", "target", "class" ]
bda6d02f37a8083248d9a0c80ea76bb5a63151ae
https://github.com/qmx/jitescript/blob/bda6d02f37a8083248d9a0c80ea76bb5a63151ae/src/main/java/me/qmx/jitescript/JiteClass.java#L155-L159
1,138
qmx/jitescript
src/main/java/me/qmx/jitescript/JiteClass.java
JiteClass.toBytes
public byte[] toBytes(JDKVersion version) { ClassNode node = new ClassNode(); node.version = version.getVer(); node.access = this.access | ACC_SUPER; node.name = this.className; node.superName = this.superClassName; node.sourceFile = this.sourceFile; node.sourceDebug = this.sourceDebug; if (parentClassName != null) { node.visitOuterClass(parentClassName, null, null); } for (ChildEntry child : childClasses) { node.visitInnerClass(child.getClassName(), className, child.getInnerName(), child.getAccess()); } if (!this.interfaces.isEmpty()) { node.interfaces.addAll(this.interfaces); } for (MethodDefinition def : methods) { node.methods.add(def.getMethodNode()); } for (FieldDefinition def : fields) { node.fields.add(def.getFieldNode()); } if (node.visibleAnnotations == null) { node.visibleAnnotations = new ArrayList<AnnotationNode>(); } for (VisibleAnnotation a : annotations) { node.visibleAnnotations.add(a.getNode()); } ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); node.accept(cw); return cw.toByteArray(); }
java
public byte[] toBytes(JDKVersion version) { ClassNode node = new ClassNode(); node.version = version.getVer(); node.access = this.access | ACC_SUPER; node.name = this.className; node.superName = this.superClassName; node.sourceFile = this.sourceFile; node.sourceDebug = this.sourceDebug; if (parentClassName != null) { node.visitOuterClass(parentClassName, null, null); } for (ChildEntry child : childClasses) { node.visitInnerClass(child.getClassName(), className, child.getInnerName(), child.getAccess()); } if (!this.interfaces.isEmpty()) { node.interfaces.addAll(this.interfaces); } for (MethodDefinition def : methods) { node.methods.add(def.getMethodNode()); } for (FieldDefinition def : fields) { node.fields.add(def.getFieldNode()); } if (node.visibleAnnotations == null) { node.visibleAnnotations = new ArrayList<AnnotationNode>(); } for (VisibleAnnotation a : annotations) { node.visibleAnnotations.add(a.getNode()); } ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); node.accept(cw); return cw.toByteArray(); }
[ "public", "byte", "[", "]", "toBytes", "(", "JDKVersion", "version", ")", "{", "ClassNode", "node", "=", "new", "ClassNode", "(", ")", ";", "node", ".", "version", "=", "version", ".", "getVer", "(", ")", ";", "node", ".", "access", "=", "this", ".", "access", "|", "ACC_SUPER", ";", "node", ".", "name", "=", "this", ".", "className", ";", "node", ".", "superName", "=", "this", ".", "superClassName", ";", "node", ".", "sourceFile", "=", "this", ".", "sourceFile", ";", "node", ".", "sourceDebug", "=", "this", ".", "sourceDebug", ";", "if", "(", "parentClassName", "!=", "null", ")", "{", "node", ".", "visitOuterClass", "(", "parentClassName", ",", "null", ",", "null", ")", ";", "}", "for", "(", "ChildEntry", "child", ":", "childClasses", ")", "{", "node", ".", "visitInnerClass", "(", "child", ".", "getClassName", "(", ")", ",", "className", ",", "child", ".", "getInnerName", "(", ")", ",", "child", ".", "getAccess", "(", ")", ")", ";", "}", "if", "(", "!", "this", ".", "interfaces", ".", "isEmpty", "(", ")", ")", "{", "node", ".", "interfaces", ".", "addAll", "(", "this", ".", "interfaces", ")", ";", "}", "for", "(", "MethodDefinition", "def", ":", "methods", ")", "{", "node", ".", "methods", ".", "add", "(", "def", ".", "getMethodNode", "(", ")", ")", ";", "}", "for", "(", "FieldDefinition", "def", ":", "fields", ")", "{", "node", ".", "fields", ".", "add", "(", "def", ".", "getFieldNode", "(", ")", ")", ";", "}", "if", "(", "node", ".", "visibleAnnotations", "==", "null", ")", "{", "node", ".", "visibleAnnotations", "=", "new", "ArrayList", "<", "AnnotationNode", ">", "(", ")", ";", "}", "for", "(", "VisibleAnnotation", "a", ":", "annotations", ")", "{", "node", ".", "visibleAnnotations", ".", "add", "(", "a", ".", "getNode", "(", ")", ")", ";", "}", "ClassWriter", "cw", "=", "new", "ClassWriter", "(", "ClassWriter", ".", "COMPUTE_FRAMES", ")", ";", "node", ".", "accept", "(", "cw", ")", ";", "return", "cw", ".", "toByteArray", "(", ")", ";", "}" ]
Convert this class representation to JDK bytecode @param version the desired JDK version @return the bytecode representation of this class
[ "Convert", "this", "class", "representation", "to", "JDK", "bytecode" ]
bda6d02f37a8083248d9a0c80ea76bb5a63151ae
https://github.com/qmx/jitescript/blob/bda6d02f37a8083248d9a0c80ea76bb5a63151ae/src/main/java/me/qmx/jitescript/JiteClass.java#L192-L232
1,139
qmx/jitescript
src/main/java/me/qmx/jitescript/CodeBlock.java
CodeBlock.frame_same
public CodeBlock frame_same(final Object... stackArguments) { final int type; switch (stackArguments.length) { case 0: type = Opcodes.F_SAME; break; case 1: type = Opcodes.F_SAME1; break; default: throw new IllegalArgumentException("same frame should have 0" + " or 1 arguments on stack"); } instructionList.add(new FrameNode(type, 0, null, stackArguments.length, stackArguments)); return this; }
java
public CodeBlock frame_same(final Object... stackArguments) { final int type; switch (stackArguments.length) { case 0: type = Opcodes.F_SAME; break; case 1: type = Opcodes.F_SAME1; break; default: throw new IllegalArgumentException("same frame should have 0" + " or 1 arguments on stack"); } instructionList.add(new FrameNode(type, 0, null, stackArguments.length, stackArguments)); return this; }
[ "public", "CodeBlock", "frame_same", "(", "final", "Object", "...", "stackArguments", ")", "{", "final", "int", "type", ";", "switch", "(", "stackArguments", ".", "length", ")", "{", "case", "0", ":", "type", "=", "Opcodes", ".", "F_SAME", ";", "break", ";", "case", "1", ":", "type", "=", "Opcodes", ".", "F_SAME1", ";", "break", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", "\"same frame should have 0\"", "+", "\" or 1 arguments on stack\"", ")", ";", "}", "instructionList", ".", "add", "(", "new", "FrameNode", "(", "type", ",", "0", ",", "null", ",", "stackArguments", ".", "length", ",", "stackArguments", ")", ")", ";", "return", "this", ";", "}" ]
adds a compressed frame to the stack @param stackArguments the argument types on the stack, represented as "class path names" e.g java/lang/RuntimeException
[ "adds", "a", "compressed", "frame", "to", "the", "stack" ]
bda6d02f37a8083248d9a0c80ea76bb5a63151ae
https://github.com/qmx/jitescript/blob/bda6d02f37a8083248d9a0c80ea76bb5a63151ae/src/main/java/me/qmx/jitescript/CodeBlock.java#L1112-L1128
1,140
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/configuration/ServiceConfigurationManager.java
ServiceConfigurationManager.registerServiceConfiguration
public void registerServiceConfiguration(String id, String configFile, DescribeService service) throws POIProxyException { if (service == null || configFile == null || service.getId() == null) { throw new POIProxyException("Null service configuration"); } this.registeredConfigurations.put(id, configFile); this.parsedConfigurations.put(id, service); try { this.save(id, configFile); } catch (IOException e) { throw new POIProxyException("Unable to write service configuration"); } }
java
public void registerServiceConfiguration(String id, String configFile, DescribeService service) throws POIProxyException { if (service == null || configFile == null || service.getId() == null) { throw new POIProxyException("Null service configuration"); } this.registeredConfigurations.put(id, configFile); this.parsedConfigurations.put(id, service); try { this.save(id, configFile); } catch (IOException e) { throw new POIProxyException("Unable to write service configuration"); } }
[ "public", "void", "registerServiceConfiguration", "(", "String", "id", ",", "String", "configFile", ",", "DescribeService", "service", ")", "throws", "POIProxyException", "{", "if", "(", "service", "==", "null", "||", "configFile", "==", "null", "||", "service", ".", "getId", "(", ")", "==", "null", ")", "{", "throw", "new", "POIProxyException", "(", "\"Null service configuration\"", ")", ";", "}", "this", ".", "registeredConfigurations", ".", "put", "(", "id", ",", "configFile", ")", ";", "this", ".", "parsedConfigurations", ".", "put", "(", "id", ",", "service", ")", ";", "try", "{", "this", ".", "save", "(", "id", ",", "configFile", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "POIProxyException", "(", "\"Unable to write service configuration\"", ")", ";", "}", "}" ]
Registers a new service into the library @param id The id of the service @param configFile The content of the json document describing the service @param describeService The parsed {@link DescribeService} @throws POIProxyException When any of the parameters is null
[ "Registers", "a", "new", "service", "into", "the", "library" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/configuration/ServiceConfigurationManager.java#L145-L159
1,141
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/configuration/ServiceConfigurationManager.java
ServiceConfigurationManager.getServiceAsJSON
public String getServiceAsJSON(String id) { String path = this.registeredConfigurations.get(id); if (path == null) { return null; } // cargar fichero de disco obtener el json y parsearlo File f = new File(CONFIGURATION_DIR + File.separator + path); FileInputStream fis = null; InputStream in = null; OutputStream out = null; String res = null; try { fis = new FileInputStream(f); in = new BufferedInputStream(fis, Constants.IO_BUFFER_SIZE); final ByteArrayOutputStream dataStream = new ByteArrayOutputStream(); out = new BufferedOutputStream(dataStream, Constants.IO_BUFFER_SIZE); byte[] b = new byte[8 * 1024]; int read; while ((read = in.read(b)) != -1) { out.write(b, 0, read); } out.flush(); res = new String(dataStream.toByteArray()); } catch (IOException e) { e.printStackTrace(); return null; } finally { Constants.closeStream(fis); Constants.closeStream(in); Constants.closeStream(out); } return res; }
java
public String getServiceAsJSON(String id) { String path = this.registeredConfigurations.get(id); if (path == null) { return null; } // cargar fichero de disco obtener el json y parsearlo File f = new File(CONFIGURATION_DIR + File.separator + path); FileInputStream fis = null; InputStream in = null; OutputStream out = null; String res = null; try { fis = new FileInputStream(f); in = new BufferedInputStream(fis, Constants.IO_BUFFER_SIZE); final ByteArrayOutputStream dataStream = new ByteArrayOutputStream(); out = new BufferedOutputStream(dataStream, Constants.IO_BUFFER_SIZE); byte[] b = new byte[8 * 1024]; int read; while ((read = in.read(b)) != -1) { out.write(b, 0, read); } out.flush(); res = new String(dataStream.toByteArray()); } catch (IOException e) { e.printStackTrace(); return null; } finally { Constants.closeStream(fis); Constants.closeStream(in); Constants.closeStream(out); } return res; }
[ "public", "String", "getServiceAsJSON", "(", "String", "id", ")", "{", "String", "path", "=", "this", ".", "registeredConfigurations", ".", "get", "(", "id", ")", ";", "if", "(", "path", "==", "null", ")", "{", "return", "null", ";", "}", "// cargar fichero de disco obtener el json y parsearlo", "File", "f", "=", "new", "File", "(", "CONFIGURATION_DIR", "+", "File", ".", "separator", "+", "path", ")", ";", "FileInputStream", "fis", "=", "null", ";", "InputStream", "in", "=", "null", ";", "OutputStream", "out", "=", "null", ";", "String", "res", "=", "null", ";", "try", "{", "fis", "=", "new", "FileInputStream", "(", "f", ")", ";", "in", "=", "new", "BufferedInputStream", "(", "fis", ",", "Constants", ".", "IO_BUFFER_SIZE", ")", ";", "final", "ByteArrayOutputStream", "dataStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "out", "=", "new", "BufferedOutputStream", "(", "dataStream", ",", "Constants", ".", "IO_BUFFER_SIZE", ")", ";", "byte", "[", "]", "b", "=", "new", "byte", "[", "8", "*", "1024", "]", ";", "int", "read", ";", "while", "(", "(", "read", "=", "in", ".", "read", "(", "b", ")", ")", "!=", "-", "1", ")", "{", "out", ".", "write", "(", "b", ",", "0", ",", "read", ")", ";", "}", "out", ".", "flush", "(", ")", ";", "res", "=", "new", "String", "(", "dataStream", ".", "toByteArray", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "finally", "{", "Constants", ".", "closeStream", "(", "fis", ")", ";", "Constants", ".", "closeStream", "(", "in", ")", ";", "Constants", ".", "closeStream", "(", "out", ")", ";", "}", "return", "res", ";", "}" ]
Returns the content of the json document describing a service given its id @param id The id of the service. Usually the name of the json document @return The content of the json document
[ "Returns", "the", "content", "of", "the", "json", "document", "describing", "a", "service", "given", "its", "id" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/configuration/ServiceConfigurationManager.java#L198-L234
1,142
plume-lib/options
src/main/java/org/plumelib/options/Options.java
Options.printClassPath
static void printClassPath() { URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); if (sysLoader == null) { System.out.println( "No system class loader. (Maybe means bootstrap class loader is being used?)"); } else { System.out.println("Classpath:"); for (URL url : sysLoader.getURLs()) { System.out.println(url.getFile()); } } }
java
static void printClassPath() { URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); if (sysLoader == null) { System.out.println( "No system class loader. (Maybe means bootstrap class loader is being used?)"); } else { System.out.println("Classpath:"); for (URL url : sysLoader.getURLs()) { System.out.println(url.getFile()); } } }
[ "static", "void", "printClassPath", "(", ")", "{", "URLClassLoader", "sysLoader", "=", "(", "URLClassLoader", ")", "ClassLoader", ".", "getSystemClassLoader", "(", ")", ";", "if", "(", "sysLoader", "==", "null", ")", "{", "System", ".", "out", ".", "println", "(", "\"No system class loader. (Maybe means bootstrap class loader is being used?)\"", ")", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", "\"Classpath:\"", ")", ";", "for", "(", "URL", "url", ":", "sysLoader", ".", "getURLs", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "url", ".", "getFile", "(", ")", ")", ";", "}", "}", "}" ]
Print the classpath.
[ "Print", "the", "classpath", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/Options.java#L844-L855
1,143
plume-lib/options
src/main/java/org/plumelib/options/Options.java
Options.parse
public String[] parse(String[] args) throws ArgException { List<String> nonOptions = new ArrayList<>(); // If true, then "--" has been seen and any argument starting with "-" // is processed as an ordinary argument, not as an option. boolean ignoreOptions = false; // Loop through each argument String tail = ""; String arg; for (int ii = 0; ii < args.length; ) { // If there was a ',' separator in previous arg, use the tail as // current arg; otherwise, fetch the next arg from args list. if (tail.length() > 0) { arg = tail; tail = ""; } else { arg = args[ii]; } if (arg.equals("--")) { ignoreOptions = true; } else if ((arg.startsWith("--") || arg.startsWith("-")) && !ignoreOptions) { String argName; String argValue; // Allow ',' as an argument separator to get around // some command line quoting problems. (markro) int splitPos = arg.indexOf(",-"); if (splitPos == 0) { // Just discard the ',' if ",-" occurs at begining of string arg = arg.substring(1); splitPos = arg.indexOf(",-"); } if (splitPos > 0) { tail = arg.substring(splitPos + 1); arg = arg.substring(0, splitPos); } int eqPos = arg.indexOf('='); if (eqPos == -1) { argName = arg; argValue = null; } else { argName = arg.substring(0, eqPos); argValue = arg.substring(eqPos + 1); } OptionInfo oi = nameMap.get(argName); if (oi == null) { StringBuilder msg = new StringBuilder(); msg.append(String.format("unknown option name '%s' in arg '%s'", argName, arg)); if (false) { // for debugging msg.append("; known options:"); for (String optionName : sortedKeySet(nameMap)) { msg.append(" "); msg.append(optionName); } } throw new ArgException(msg.toString()); } if (oi.argumentRequired() && (argValue == null)) { ii++; if (ii >= args.length) { throw new ArgException("option %s requires an argument", arg); } argValue = args[ii]; } // System.out.printf ("argName = '%s', argValue='%s'%n", argName, // argValue); setArg(oi, argName, argValue); } else { // not an option if (!parseAfterArg) { ignoreOptions = true; } nonOptions.add(arg); } // If no ',' tail, advance to next args option if (tail.length() == 0) { ii++; } } String[] result = nonOptions.toArray(new String[nonOptions.size()]); return result; }
java
public String[] parse(String[] args) throws ArgException { List<String> nonOptions = new ArrayList<>(); // If true, then "--" has been seen and any argument starting with "-" // is processed as an ordinary argument, not as an option. boolean ignoreOptions = false; // Loop through each argument String tail = ""; String arg; for (int ii = 0; ii < args.length; ) { // If there was a ',' separator in previous arg, use the tail as // current arg; otherwise, fetch the next arg from args list. if (tail.length() > 0) { arg = tail; tail = ""; } else { arg = args[ii]; } if (arg.equals("--")) { ignoreOptions = true; } else if ((arg.startsWith("--") || arg.startsWith("-")) && !ignoreOptions) { String argName; String argValue; // Allow ',' as an argument separator to get around // some command line quoting problems. (markro) int splitPos = arg.indexOf(",-"); if (splitPos == 0) { // Just discard the ',' if ",-" occurs at begining of string arg = arg.substring(1); splitPos = arg.indexOf(",-"); } if (splitPos > 0) { tail = arg.substring(splitPos + 1); arg = arg.substring(0, splitPos); } int eqPos = arg.indexOf('='); if (eqPos == -1) { argName = arg; argValue = null; } else { argName = arg.substring(0, eqPos); argValue = arg.substring(eqPos + 1); } OptionInfo oi = nameMap.get(argName); if (oi == null) { StringBuilder msg = new StringBuilder(); msg.append(String.format("unknown option name '%s' in arg '%s'", argName, arg)); if (false) { // for debugging msg.append("; known options:"); for (String optionName : sortedKeySet(nameMap)) { msg.append(" "); msg.append(optionName); } } throw new ArgException(msg.toString()); } if (oi.argumentRequired() && (argValue == null)) { ii++; if (ii >= args.length) { throw new ArgException("option %s requires an argument", arg); } argValue = args[ii]; } // System.out.printf ("argName = '%s', argValue='%s'%n", argName, // argValue); setArg(oi, argName, argValue); } else { // not an option if (!parseAfterArg) { ignoreOptions = true; } nonOptions.add(arg); } // If no ',' tail, advance to next args option if (tail.length() == 0) { ii++; } } String[] result = nonOptions.toArray(new String[nonOptions.size()]); return result; }
[ "public", "String", "[", "]", "parse", "(", "String", "[", "]", "args", ")", "throws", "ArgException", "{", "List", "<", "String", ">", "nonOptions", "=", "new", "ArrayList", "<>", "(", ")", ";", "// If true, then \"--\" has been seen and any argument starting with \"-\"", "// is processed as an ordinary argument, not as an option.", "boolean", "ignoreOptions", "=", "false", ";", "// Loop through each argument", "String", "tail", "=", "\"\"", ";", "String", "arg", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "args", ".", "length", ";", ")", "{", "// If there was a ',' separator in previous arg, use the tail as", "// current arg; otherwise, fetch the next arg from args list.", "if", "(", "tail", ".", "length", "(", ")", ">", "0", ")", "{", "arg", "=", "tail", ";", "tail", "=", "\"\"", ";", "}", "else", "{", "arg", "=", "args", "[", "ii", "]", ";", "}", "if", "(", "arg", ".", "equals", "(", "\"--\"", ")", ")", "{", "ignoreOptions", "=", "true", ";", "}", "else", "if", "(", "(", "arg", ".", "startsWith", "(", "\"--\"", ")", "||", "arg", ".", "startsWith", "(", "\"-\"", ")", ")", "&&", "!", "ignoreOptions", ")", "{", "String", "argName", ";", "String", "argValue", ";", "// Allow ',' as an argument separator to get around", "// some command line quoting problems. (markro)", "int", "splitPos", "=", "arg", ".", "indexOf", "(", "\",-\"", ")", ";", "if", "(", "splitPos", "==", "0", ")", "{", "// Just discard the ',' if \",-\" occurs at begining of string", "arg", "=", "arg", ".", "substring", "(", "1", ")", ";", "splitPos", "=", "arg", ".", "indexOf", "(", "\",-\"", ")", ";", "}", "if", "(", "splitPos", ">", "0", ")", "{", "tail", "=", "arg", ".", "substring", "(", "splitPos", "+", "1", ")", ";", "arg", "=", "arg", ".", "substring", "(", "0", ",", "splitPos", ")", ";", "}", "int", "eqPos", "=", "arg", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "eqPos", "==", "-", "1", ")", "{", "argName", "=", "arg", ";", "argValue", "=", "null", ";", "}", "else", "{", "argName", "=", "arg", ".", "substring", "(", "0", ",", "eqPos", ")", ";", "argValue", "=", "arg", ".", "substring", "(", "eqPos", "+", "1", ")", ";", "}", "OptionInfo", "oi", "=", "nameMap", ".", "get", "(", "argName", ")", ";", "if", "(", "oi", "==", "null", ")", "{", "StringBuilder", "msg", "=", "new", "StringBuilder", "(", ")", ";", "msg", ".", "append", "(", "String", ".", "format", "(", "\"unknown option name '%s' in arg '%s'\"", ",", "argName", ",", "arg", ")", ")", ";", "if", "(", "false", ")", "{", "// for debugging", "msg", ".", "append", "(", "\"; known options:\"", ")", ";", "for", "(", "String", "optionName", ":", "sortedKeySet", "(", "nameMap", ")", ")", "{", "msg", ".", "append", "(", "\" \"", ")", ";", "msg", ".", "append", "(", "optionName", ")", ";", "}", "}", "throw", "new", "ArgException", "(", "msg", ".", "toString", "(", ")", ")", ";", "}", "if", "(", "oi", ".", "argumentRequired", "(", ")", "&&", "(", "argValue", "==", "null", ")", ")", "{", "ii", "++", ";", "if", "(", "ii", ">=", "args", ".", "length", ")", "{", "throw", "new", "ArgException", "(", "\"option %s requires an argument\"", ",", "arg", ")", ";", "}", "argValue", "=", "args", "[", "ii", "]", ";", "}", "// System.out.printf (\"argName = '%s', argValue='%s'%n\", argName,", "// argValue);", "setArg", "(", "oi", ",", "argName", ",", "argValue", ")", ";", "}", "else", "{", "// not an option", "if", "(", "!", "parseAfterArg", ")", "{", "ignoreOptions", "=", "true", ";", "}", "nonOptions", ".", "add", "(", "arg", ")", ";", "}", "// If no ',' tail, advance to next args option", "if", "(", "tail", ".", "length", "(", ")", "==", "0", ")", "{", "ii", "++", ";", "}", "}", "String", "[", "]", "result", "=", "nonOptions", ".", "toArray", "(", "new", "String", "[", "nonOptions", ".", "size", "(", ")", "]", ")", ";", "return", "result", ";", "}" ]
Sets option variables from the given command line. @param args the commandline to be parsed @return all non-option arguments @throws ArgException if the command line contains unknown option or misused options
[ "Sets", "option", "variables", "from", "the", "given", "command", "line", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/Options.java#L890-L974
1,144
plume-lib/options
src/main/java/org/plumelib/options/Options.java
Options.parse
public String[] parse(String message, String[] args) { String[] nonOptions = null; try { nonOptions = parse(args); } catch (ArgException ae) { String exceptionMessage = ae.getMessage(); if (exceptionMessage != null) { System.out.println(exceptionMessage); } System.out.println(message); System.exit(-1); // throw new Error ("message error: ", ae); } return nonOptions; }
java
public String[] parse(String message, String[] args) { String[] nonOptions = null; try { nonOptions = parse(args); } catch (ArgException ae) { String exceptionMessage = ae.getMessage(); if (exceptionMessage != null) { System.out.println(exceptionMessage); } System.out.println(message); System.exit(-1); // throw new Error ("message error: ", ae); } return nonOptions; }
[ "public", "String", "[", "]", "parse", "(", "String", "message", ",", "String", "[", "]", "args", ")", "{", "String", "[", "]", "nonOptions", "=", "null", ";", "try", "{", "nonOptions", "=", "parse", "(", "args", ")", ";", "}", "catch", "(", "ArgException", "ae", ")", "{", "String", "exceptionMessage", "=", "ae", ".", "getMessage", "(", ")", ";", "if", "(", "exceptionMessage", "!=", "null", ")", "{", "System", ".", "out", ".", "println", "(", "exceptionMessage", ")", ";", "}", "System", ".", "out", ".", "println", "(", "message", ")", ";", "System", ".", "exit", "(", "-", "1", ")", ";", "// throw new Error (\"message error: \", ae);", "}", "return", "nonOptions", ";", "}" ]
Sets option variables from the given command line; if any command-line argument is illegal, prints the given message and terminates the program. <p>If an error occurs, prints the exception's message, prints the given message, and then terminates the program. The program is terminated rather than throwing an error to create cleaner output. @param message a message to print, such as "Pass --help for a list of all command-line arguments." @param args the command line to parse @return all non-option arguments @see #parse(String[])
[ "Sets", "option", "variables", "from", "the", "given", "command", "line", ";", "if", "any", "command", "-", "line", "argument", "is", "illegal", "prints", "the", "given", "message", "and", "terminates", "the", "program", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/Options.java#L1042-L1058
1,145
plume-lib/options
src/main/java/org/plumelib/options/Options.java
Options.printUsage
public void printUsage(PrintStream ps) { hasListOption = false; if (usageSynopsis != null) { ps.printf("Usage: %s%n", usageSynopsis); } ps.println(usage()); if (hasListOption) { ps.println(); ps.println(LIST_HELP); } }
java
public void printUsage(PrintStream ps) { hasListOption = false; if (usageSynopsis != null) { ps.printf("Usage: %s%n", usageSynopsis); } ps.println(usage()); if (hasListOption) { ps.println(); ps.println(LIST_HELP); } }
[ "public", "void", "printUsage", "(", "PrintStream", "ps", ")", "{", "hasListOption", "=", "false", ";", "if", "(", "usageSynopsis", "!=", "null", ")", "{", "ps", ".", "printf", "(", "\"Usage: %s%n\"", ",", "usageSynopsis", ")", ";", "}", "ps", ".", "println", "(", "usage", "(", ")", ")", ";", "if", "(", "hasListOption", ")", "{", "ps", ".", "println", "(", ")", ";", "ps", ".", "println", "(", "LIST_HELP", ")", ";", "}", "}" ]
Prints usage information to the given PrintStream. Uses the usage synopsis passed into the constructor, if any. @param ps where to print usage information
[ "Prints", "usage", "information", "to", "the", "given", "PrintStream", ".", "Uses", "the", "usage", "synopsis", "passed", "into", "the", "constructor", "if", "any", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/Options.java#L1103-L1113
1,146
plume-lib/options
src/main/java/org/plumelib/options/Options.java
Options.usage
public String usage(boolean showUnpublicized, String... groupNames) { if (!hasGroups) { if (groupNames.length > 0) { throw new IllegalArgumentException( "This instance of Options does not have any option groups defined"); } return formatOptions(options, maxOptionLength(options, showUnpublicized), showUnpublicized); } List<OptionGroupInfo> groups = new ArrayList<>(); if (groupNames.length > 0) { for (String groupName : groupNames) { if (!groupMap.containsKey(groupName)) { throw new IllegalArgumentException("invalid option group: " + groupName); } OptionGroupInfo gi = groupMap.get(groupName); if (!showUnpublicized && !gi.anyPublicized()) { throw new IllegalArgumentException( "group does not contain any publicized options: " + groupName); } else { groups.add(groupMap.get(groupName)); } } } else { // return usage for all groups that are not unpublicized for (OptionGroupInfo gi : groupMap.values()) { if ((gi.unpublicized || !gi.anyPublicized()) && !showUnpublicized) { continue; } groups.add(gi); } } List<Integer> lengths = new ArrayList<>(); for (OptionGroupInfo gi : groups) { lengths.add(maxOptionLength(gi.optionList, showUnpublicized)); } int maxLength = Collections.max(lengths); StringJoiner buf = new StringJoiner(lineSeparator); for (OptionGroupInfo gi : groups) { buf.add(String.format("%n%s:", gi.name)); buf.add(formatOptions(gi.optionList, maxLength, showUnpublicized)); } return buf.toString(); }
java
public String usage(boolean showUnpublicized, String... groupNames) { if (!hasGroups) { if (groupNames.length > 0) { throw new IllegalArgumentException( "This instance of Options does not have any option groups defined"); } return formatOptions(options, maxOptionLength(options, showUnpublicized), showUnpublicized); } List<OptionGroupInfo> groups = new ArrayList<>(); if (groupNames.length > 0) { for (String groupName : groupNames) { if (!groupMap.containsKey(groupName)) { throw new IllegalArgumentException("invalid option group: " + groupName); } OptionGroupInfo gi = groupMap.get(groupName); if (!showUnpublicized && !gi.anyPublicized()) { throw new IllegalArgumentException( "group does not contain any publicized options: " + groupName); } else { groups.add(groupMap.get(groupName)); } } } else { // return usage for all groups that are not unpublicized for (OptionGroupInfo gi : groupMap.values()) { if ((gi.unpublicized || !gi.anyPublicized()) && !showUnpublicized) { continue; } groups.add(gi); } } List<Integer> lengths = new ArrayList<>(); for (OptionGroupInfo gi : groups) { lengths.add(maxOptionLength(gi.optionList, showUnpublicized)); } int maxLength = Collections.max(lengths); StringJoiner buf = new StringJoiner(lineSeparator); for (OptionGroupInfo gi : groups) { buf.add(String.format("%n%s:", gi.name)); buf.add(formatOptions(gi.optionList, maxLength, showUnpublicized)); } return buf.toString(); }
[ "public", "String", "usage", "(", "boolean", "showUnpublicized", ",", "String", "...", "groupNames", ")", "{", "if", "(", "!", "hasGroups", ")", "{", "if", "(", "groupNames", ".", "length", ">", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"This instance of Options does not have any option groups defined\"", ")", ";", "}", "return", "formatOptions", "(", "options", ",", "maxOptionLength", "(", "options", ",", "showUnpublicized", ")", ",", "showUnpublicized", ")", ";", "}", "List", "<", "OptionGroupInfo", ">", "groups", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "groupNames", ".", "length", ">", "0", ")", "{", "for", "(", "String", "groupName", ":", "groupNames", ")", "{", "if", "(", "!", "groupMap", ".", "containsKey", "(", "groupName", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"invalid option group: \"", "+", "groupName", ")", ";", "}", "OptionGroupInfo", "gi", "=", "groupMap", ".", "get", "(", "groupName", ")", ";", "if", "(", "!", "showUnpublicized", "&&", "!", "gi", ".", "anyPublicized", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"group does not contain any publicized options: \"", "+", "groupName", ")", ";", "}", "else", "{", "groups", ".", "add", "(", "groupMap", ".", "get", "(", "groupName", ")", ")", ";", "}", "}", "}", "else", "{", "// return usage for all groups that are not unpublicized", "for", "(", "OptionGroupInfo", "gi", ":", "groupMap", ".", "values", "(", ")", ")", "{", "if", "(", "(", "gi", ".", "unpublicized", "||", "!", "gi", ".", "anyPublicized", "(", ")", ")", "&&", "!", "showUnpublicized", ")", "{", "continue", ";", "}", "groups", ".", "add", "(", "gi", ")", ";", "}", "}", "List", "<", "Integer", ">", "lengths", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "OptionGroupInfo", "gi", ":", "groups", ")", "{", "lengths", ".", "add", "(", "maxOptionLength", "(", "gi", ".", "optionList", ",", "showUnpublicized", ")", ")", ";", "}", "int", "maxLength", "=", "Collections", ".", "max", "(", "lengths", ")", ";", "StringJoiner", "buf", "=", "new", "StringJoiner", "(", "lineSeparator", ")", ";", "for", "(", "OptionGroupInfo", "gi", ":", "groups", ")", "{", "buf", ".", "add", "(", "String", ".", "format", "(", "\"%n%s:\"", ",", "gi", ".", "name", ")", ")", ";", "buf", ".", "add", "(", "formatOptions", "(", "gi", ".", "optionList", ",", "maxLength", ",", "showUnpublicized", ")", ")", ";", "}", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
Returns a usage message for command-line options. @return the command-line usage message @param showUnpublicized if true, treat all unpublicized options and option groups as publicized @param groupNames the list of option groups to include in the usage message. If empty and option groups are being used, will return usage for all option groups that are not unpublicized. If empty and option groups are not being used, will return usage for all options that are not unpublicized.
[ "Returns", "a", "usage", "message", "for", "command", "-", "line", "options", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/Options.java#L1143-L1188
1,147
plume-lib/options
src/main/java/org/plumelib/options/Options.java
Options.maxOptionLength
private int maxOptionLength(List<OptionInfo> optList, boolean showUnpublicized) { int maxLength = 0; for (OptionInfo oi : optList) { if (oi.unpublicized && !showUnpublicized) { continue; } int len = oi.synopsis().length(); if (len > maxLength) { maxLength = len; } } return maxLength; }
java
private int maxOptionLength(List<OptionInfo> optList, boolean showUnpublicized) { int maxLength = 0; for (OptionInfo oi : optList) { if (oi.unpublicized && !showUnpublicized) { continue; } int len = oi.synopsis().length(); if (len > maxLength) { maxLength = len; } } return maxLength; }
[ "private", "int", "maxOptionLength", "(", "List", "<", "OptionInfo", ">", "optList", ",", "boolean", "showUnpublicized", ")", "{", "int", "maxLength", "=", "0", ";", "for", "(", "OptionInfo", "oi", ":", "optList", ")", "{", "if", "(", "oi", ".", "unpublicized", "&&", "!", "showUnpublicized", ")", "{", "continue", ";", "}", "int", "len", "=", "oi", ".", "synopsis", "(", ")", ".", "length", "(", ")", ";", "if", "(", "len", ">", "maxLength", ")", "{", "maxLength", "=", "len", ";", "}", "}", "return", "maxLength", ";", "}" ]
Return the length of the longest synopsis message in a list of options. Useful for aligning options in usage strings. @param optList the options whose synopsis messages to measure @param showUnpublicized if true, include unpublicized options in the computation @return the length of the longest synopsis message in a list of options
[ "Return", "the", "length", "of", "the", "longest", "synopsis", "message", "in", "a", "list", "of", "options", ".", "Useful", "for", "aligning", "options", "in", "usage", "strings", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/Options.java#L1230-L1242
1,148
plume-lib/options
src/main/java/org/plumelib/options/Options.java
Options.getRefArg
@SuppressWarnings("nullness") // static method, so null first arg is OK: oi.factory private @NonNull Object getRefArg(OptionInfo oi, String argName, String argValue) throws ArgException { Object val; try { if (oi.constructor != null) { val = oi.constructor.newInstance(new Object[] {argValue}); } else if (oi.baseType.isEnum()) { @SuppressWarnings({"unchecked", "rawtypes"}) Object tmpVal = getEnumValue((Class<Enum>) oi.baseType, argValue); val = tmpVal; } else { if (oi.factory == null) { throw new Error("No constructor or factory for argument " + argName); } if (oi.factoryArg2 == null) { val = oi.factory.invoke(null, argValue); } else { val = oi.factory.invoke(null, argValue, oi.factoryArg2); } } } catch (Exception e) { throw new ArgException("Invalid argument (%s) for argument %s", argValue, argName); } return val; }
java
@SuppressWarnings("nullness") // static method, so null first arg is OK: oi.factory private @NonNull Object getRefArg(OptionInfo oi, String argName, String argValue) throws ArgException { Object val; try { if (oi.constructor != null) { val = oi.constructor.newInstance(new Object[] {argValue}); } else if (oi.baseType.isEnum()) { @SuppressWarnings({"unchecked", "rawtypes"}) Object tmpVal = getEnumValue((Class<Enum>) oi.baseType, argValue); val = tmpVal; } else { if (oi.factory == null) { throw new Error("No constructor or factory for argument " + argName); } if (oi.factoryArg2 == null) { val = oi.factory.invoke(null, argValue); } else { val = oi.factory.invoke(null, argValue, oi.factoryArg2); } } } catch (Exception e) { throw new ArgException("Invalid argument (%s) for argument %s", argValue, argName); } return val; }
[ "@", "SuppressWarnings", "(", "\"nullness\"", ")", "// static method, so null first arg is OK: oi.factory", "private", "@", "NonNull", "Object", "getRefArg", "(", "OptionInfo", "oi", ",", "String", "argName", ",", "String", "argValue", ")", "throws", "ArgException", "{", "Object", "val", ";", "try", "{", "if", "(", "oi", ".", "constructor", "!=", "null", ")", "{", "val", "=", "oi", ".", "constructor", ".", "newInstance", "(", "new", "Object", "[", "]", "{", "argValue", "}", ")", ";", "}", "else", "if", "(", "oi", ".", "baseType", ".", "isEnum", "(", ")", ")", "{", "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "Object", "tmpVal", "=", "getEnumValue", "(", "(", "Class", "<", "Enum", ">", ")", "oi", ".", "baseType", ",", "argValue", ")", ";", "val", "=", "tmpVal", ";", "}", "else", "{", "if", "(", "oi", ".", "factory", "==", "null", ")", "{", "throw", "new", "Error", "(", "\"No constructor or factory for argument \"", "+", "argName", ")", ";", "}", "if", "(", "oi", ".", "factoryArg2", "==", "null", ")", "{", "val", "=", "oi", ".", "factory", ".", "invoke", "(", "null", ",", "argValue", ")", ";", "}", "else", "{", "val", "=", "oi", ".", "factory", ".", "invoke", "(", "null", ",", "argValue", ",", "oi", ".", "factoryArg2", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ArgException", "(", "\"Invalid argument (%s) for argument %s\"", ",", "argValue", ",", "argName", ")", ";", "}", "return", "val", ";", "}" ]
Given a value string supplied on the command line, create an object. The only expected error is some sort of parse error from the constructor. @param oi the option corresponding to {@code argName} and {@code argValue} @param argName the argument name -- used only for diagnostics @param argValue the value supplied on the command line, which this method parses @return a value, whose printed representation is {@code argValue} @throws ArgException if the user supplied an incorrect string (contained in {@code argValue})
[ "Given", "a", "value", "string", "supplied", "on", "the", "command", "line", "create", "an", "object", ".", "The", "only", "expected", "error", "is", "some", "sort", "of", "parse", "error", "from", "the", "constructor", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/Options.java#L1421-L1448
1,149
plume-lib/options
src/main/java/org/plumelib/options/Options.java
Options.settings
public String settings(boolean showUnpublicized) { StringJoiner out = new StringJoiner(lineSeparator); // Determine the length of the longest name int maxLength = maxOptionLength(options, showUnpublicized); // Create the settings string for (OptionInfo oi : options) { @SuppressWarnings("formatter") // format string computed from maxLength String use = String.format("%-" + maxLength + "s = ", oi.longName); try { use += oi.field.get(oi.obj); } catch (Exception e) { throw new Error("unexpected exception reading field " + oi.field, e); } out.add(use); } return out.toString(); }
java
public String settings(boolean showUnpublicized) { StringJoiner out = new StringJoiner(lineSeparator); // Determine the length of the longest name int maxLength = maxOptionLength(options, showUnpublicized); // Create the settings string for (OptionInfo oi : options) { @SuppressWarnings("formatter") // format string computed from maxLength String use = String.format("%-" + maxLength + "s = ", oi.longName); try { use += oi.field.get(oi.obj); } catch (Exception e) { throw new Error("unexpected exception reading field " + oi.field, e); } out.add(use); } return out.toString(); }
[ "public", "String", "settings", "(", "boolean", "showUnpublicized", ")", "{", "StringJoiner", "out", "=", "new", "StringJoiner", "(", "lineSeparator", ")", ";", "// Determine the length of the longest name", "int", "maxLength", "=", "maxOptionLength", "(", "options", ",", "showUnpublicized", ")", ";", "// Create the settings string", "for", "(", "OptionInfo", "oi", ":", "options", ")", "{", "@", "SuppressWarnings", "(", "\"formatter\"", ")", "// format string computed from maxLength", "String", "use", "=", "String", ".", "format", "(", "\"%-\"", "+", "maxLength", "+", "\"s = \"", ",", "oi", ".", "longName", ")", ";", "try", "{", "use", "+=", "oi", ".", "field", ".", "get", "(", "oi", ".", "obj", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "Error", "(", "\"unexpected exception reading field \"", "+", "oi", ".", "field", ",", "e", ")", ";", "}", "out", ".", "add", "(", "use", ")", ";", "}", "return", "out", ".", "toString", "(", ")", ";", "}" ]
Returns a string containing the current setting for each option, in command-line format that can be parsed by Options. Contains every known option even if the option was not specified on the command line. Never contains duplicates. @param showUnpublicized if true, treat all unpublicized options and option groups as publicized @return a command line that can be tokenized with {@link #tokenize}, containing the current setting for each option
[ "Returns", "a", "string", "containing", "the", "current", "setting", "for", "each", "option", "in", "command", "-", "line", "format", "that", "can", "be", "parsed", "by", "Options", ".", "Contains", "every", "known", "option", "even", "if", "the", "option", "was", "not", "specified", "on", "the", "command", "line", ".", "Never", "contains", "duplicates", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/Options.java#L1533-L1552
1,150
osglworks/java-tool-ext
src/main/java/org/osgl/util/Token.java
Token.payload
public String payload(int index) { return payload.size() > index ? payload.get(index) : null; }
java
public String payload(int index) { return payload.size() > index ? payload.get(index) : null; }
[ "public", "String", "payload", "(", "int", "index", ")", "{", "return", "payload", ".", "size", "(", ")", ">", "index", "?", "payload", ".", "get", "(", "index", ")", ":", "null", ";", "}" ]
Returns a payload at `index` or `null` if no payload found there @param index the index to fetch the payload @return the payload at the position or `null` if not available
[ "Returns", "a", "payload", "at", "index", "or", "null", "if", "no", "payload", "found", "there" ]
43f034bd0a42e571e437f44aa20487d45248a30b
https://github.com/osglworks/java-tool-ext/blob/43f034bd0a42e571e437f44aa20487d45248a30b/src/main/java/org/osgl/util/Token.java#L156-L158
1,151
osglworks/java-tool-ext
src/main/java/org/osgl/util/Token.java
Token.generateToken
public static String generateToken(byte[] secret, long seconds, String oid, String... payload) { long due = Life.due(seconds); List<String> l = new ArrayList<String>(2 + payload.length); l.add(oid); l.add(String.valueOf(due)); l.addAll(C.listOf(payload)); String s = S.join("|", l); return Crypto.encryptAES(s, secret); }
java
public static String generateToken(byte[] secret, long seconds, String oid, String... payload) { long due = Life.due(seconds); List<String> l = new ArrayList<String>(2 + payload.length); l.add(oid); l.add(String.valueOf(due)); l.addAll(C.listOf(payload)); String s = S.join("|", l); return Crypto.encryptAES(s, secret); }
[ "public", "static", "String", "generateToken", "(", "byte", "[", "]", "secret", ",", "long", "seconds", ",", "String", "oid", ",", "String", "...", "payload", ")", "{", "long", "due", "=", "Life", ".", "due", "(", "seconds", ")", ";", "List", "<", "String", ">", "l", "=", "new", "ArrayList", "<", "String", ">", "(", "2", "+", "payload", ".", "length", ")", ";", "l", ".", "add", "(", "oid", ")", ";", "l", ".", "add", "(", "String", ".", "valueOf", "(", "due", ")", ")", ";", "l", ".", "addAll", "(", "C", ".", "listOf", "(", "payload", ")", ")", ";", "String", "s", "=", "S", ".", "join", "(", "\"|\"", ",", "l", ")", ";", "return", "Crypto", ".", "encryptAES", "(", "s", ",", "secret", ")", ";", "}" ]
Generate a token string with secret key, ID and optionally payloads @param secret the secret to encrypt to token string @param seconds the expiration of the token in seconds @param oid the ID of the token (could be customer ID etc) @param payload the payload optionally indicate more information @return an encrypted token string that is expiring in {@link Life#SHORT} time period
[ "Generate", "a", "token", "string", "with", "secret", "key", "ID", "and", "optionally", "payloads" ]
43f034bd0a42e571e437f44aa20487d45248a30b
https://github.com/osglworks/java-tool-ext/blob/43f034bd0a42e571e437f44aa20487d45248a30b/src/main/java/org/osgl/util/Token.java#L336-L344
1,152
osglworks/java-tool-ext
src/main/java/org/osgl/util/Token.java
Token.isTokenValid
@SuppressWarnings("unused") public static boolean isTokenValid(byte[] secret, String oid, String token) { if (S.anyBlank(oid, token)) { return false; } String s = Crypto.decryptAES(token, secret); String[] sa = s.split("\\|"); if (sa.length < 2) return false; if (!S.isEqual(oid, sa[0])) return false; try { long due = Long.parseLong(sa[1]); return (due < 1 || due > System.currentTimeMillis()); } catch (Exception e) { return false; } }
java
@SuppressWarnings("unused") public static boolean isTokenValid(byte[] secret, String oid, String token) { if (S.anyBlank(oid, token)) { return false; } String s = Crypto.decryptAES(token, secret); String[] sa = s.split("\\|"); if (sa.length < 2) return false; if (!S.isEqual(oid, sa[0])) return false; try { long due = Long.parseLong(sa[1]); return (due < 1 || due > System.currentTimeMillis()); } catch (Exception e) { return false; } }
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "static", "boolean", "isTokenValid", "(", "byte", "[", "]", "secret", ",", "String", "oid", ",", "String", "token", ")", "{", "if", "(", "S", ".", "anyBlank", "(", "oid", ",", "token", ")", ")", "{", "return", "false", ";", "}", "String", "s", "=", "Crypto", ".", "decryptAES", "(", "token", ",", "secret", ")", ";", "String", "[", "]", "sa", "=", "s", ".", "split", "(", "\"\\\\|\"", ")", ";", "if", "(", "sa", ".", "length", "<", "2", ")", "return", "false", ";", "if", "(", "!", "S", ".", "isEqual", "(", "oid", ",", "sa", "[", "0", "]", ")", ")", "return", "false", ";", "try", "{", "long", "due", "=", "Long", ".", "parseLong", "(", "sa", "[", "1", "]", ")", ";", "return", "(", "due", "<", "1", "||", "due", ">", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "false", ";", "}", "}" ]
Check if a string is a valid token @param secret the secret to decrypt the string @param oid the ID supposed to be encapsulated in the token @param token the token string @return {@code true} if the token is valid
[ "Check", "if", "a", "string", "is", "a", "valid", "token" ]
43f034bd0a42e571e437f44aa20487d45248a30b
https://github.com/osglworks/java-tool-ext/blob/43f034bd0a42e571e437f44aa20487d45248a30b/src/main/java/org/osgl/util/Token.java#L415-L430
1,153
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/jpe/parser/configuration/DescribeServiceParser.java
DescribeServiceParser.parse
public DescribeService parse(String json) { Gson gson = createGSON(); return gson.fromJson(json, DescribeService.class); }
java
public DescribeService parse(String json) { Gson gson = createGSON(); return gson.fromJson(json, DescribeService.class); }
[ "public", "DescribeService", "parse", "(", "String", "json", ")", "{", "Gson", "gson", "=", "createGSON", "(", ")", ";", "return", "gson", ".", "fromJson", "(", "json", ",", "DescribeService", ".", "class", ")", ";", "}" ]
Parses a describe service json document passed as a String @param json The String containing the json document @return The {@link DescribeService} instance
[ "Parses", "a", "describe", "service", "json", "document", "passed", "as", "a", "String" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/jpe/parser/configuration/DescribeServiceParser.java#L107-L110
1,154
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/models/Polygon.java
Polygon.getCoordinates
public List<List<List<Double>>> getCoordinates() { List<List<List<Double>>> polygon = new ArrayList<List<List<Double>>>(); for (LineString lineString : coordinates) { polygon.add(lineString.getCoordinates()); } return polygon; }
java
public List<List<List<Double>>> getCoordinates() { List<List<List<Double>>> polygon = new ArrayList<List<List<Double>>>(); for (LineString lineString : coordinates) { polygon.add(lineString.getCoordinates()); } return polygon; }
[ "public", "List", "<", "List", "<", "List", "<", "Double", ">", ">", ">", "getCoordinates", "(", ")", "{", "List", "<", "List", "<", "List", "<", "Double", ">>>", "polygon", "=", "new", "ArrayList", "<", "List", "<", "List", "<", "Double", ">", ">", ">", "(", ")", ";", "for", "(", "LineString", "lineString", ":", "coordinates", ")", "{", "polygon", ".", "add", "(", "lineString", ".", "getCoordinates", "(", ")", ")", ";", "}", "return", "polygon", ";", "}" ]
Should throw is not a polygon exception
[ "Should", "throw", "is", "not", "a", "polygon", "exception" ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/models/Polygon.java#L16-L22
1,155
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/configuration/DescribeServices.java
DescribeServices.getServicesIDByCategory
public List<String> getServicesIDByCategory(String category) { Set<String> servicesID = services.keySet(); Iterator<String> it = servicesID.iterator(); List<String> ids = new ArrayList<String>(); if (category == null) { return ids; } String key; while (it.hasNext()) { key = it.next(); DescribeService service = services.get(key); if (service.containsCategory(category)) { ids.add(key); } } return ids; }
java
public List<String> getServicesIDByCategory(String category) { Set<String> servicesID = services.keySet(); Iterator<String> it = servicesID.iterator(); List<String> ids = new ArrayList<String>(); if (category == null) { return ids; } String key; while (it.hasNext()) { key = it.next(); DescribeService service = services.get(key); if (service.containsCategory(category)) { ids.add(key); } } return ids; }
[ "public", "List", "<", "String", ">", "getServicesIDByCategory", "(", "String", "category", ")", "{", "Set", "<", "String", ">", "servicesID", "=", "services", ".", "keySet", "(", ")", ";", "Iterator", "<", "String", ">", "it", "=", "servicesID", ".", "iterator", "(", ")", ";", "List", "<", "String", ">", "ids", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "category", "==", "null", ")", "{", "return", "ids", ";", "}", "String", "key", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "key", "=", "it", ".", "next", "(", ")", ";", "DescribeService", "service", "=", "services", ".", "get", "(", "key", ")", ";", "if", "(", "service", ".", "containsCategory", "(", "category", ")", ")", "{", "ids", ".", "add", "(", "key", ")", ";", "}", "}", "return", "ids", ";", "}" ]
Iterates the list of registered services and for those that support the category passed as a parameter return their ID @param category @return
[ "Iterates", "the", "list", "of", "registered", "services", "and", "for", "those", "that", "support", "the", "category", "passed", "as", "a", "parameter", "return", "their", "ID" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/configuration/DescribeServices.java#L118-L137
1,156
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/configuration/DescribeServices.java
DescribeServices.supportsCategory
public boolean supportsCategory(String category) { if (category == null) { return false; } List<String> categories = this.getCategories(); for (String cat : categories) { if (cat.compareToIgnoreCase(category) == 0) { return true; } } return false; }
java
public boolean supportsCategory(String category) { if (category == null) { return false; } List<String> categories = this.getCategories(); for (String cat : categories) { if (cat.compareToIgnoreCase(category) == 0) { return true; } } return false; }
[ "public", "boolean", "supportsCategory", "(", "String", "category", ")", "{", "if", "(", "category", "==", "null", ")", "{", "return", "false", ";", "}", "List", "<", "String", ">", "categories", "=", "this", ".", "getCategories", "(", ")", ";", "for", "(", "String", "cat", ":", "categories", ")", "{", "if", "(", "cat", ".", "compareToIgnoreCase", "(", "category", ")", "==", "0", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if there is any service registered that supports the category parameter @param category @return
[ "Returns", "true", "if", "there", "is", "any", "service", "registered", "that", "supports", "the", "category", "parameter" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/configuration/DescribeServices.java#L146-L159
1,157
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/LocalFilter.java
LocalFilter.getQueryParam
private Param getQueryParam(List<Param> optionalParams) { for (Param p : optionalParams) { if (p == null) { continue; } if (p.getType().equals(ParamEnum.QUERY.name)) { return p; } } return null; }
java
private Param getQueryParam(List<Param> optionalParams) { for (Param p : optionalParams) { if (p == null) { continue; } if (p.getType().equals(ParamEnum.QUERY.name)) { return p; } } return null; }
[ "private", "Param", "getQueryParam", "(", "List", "<", "Param", ">", "optionalParams", ")", "{", "for", "(", "Param", "p", ":", "optionalParams", ")", "{", "if", "(", "p", "==", "null", ")", "{", "continue", ";", "}", "if", "(", "p", ".", "getType", "(", ")", ".", "equals", "(", "ParamEnum", ".", "QUERY", ".", "name", ")", ")", "{", "return", "p", ";", "}", "}", "return", "null", ";", "}" ]
FIXME Extract the ArrayList to a Class
[ "FIXME", "Extract", "the", "ArrayList", "to", "a", "Class" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/LocalFilter.java#L79-L91
1,158
plume-lib/options
src/main/java/org/plumelib/options/OptionsDoclet.java
OptionsDoclet.start
public static boolean start(RootDoc root) { List<Object> objs = new ArrayList<>(); for (ClassDoc doc : root.specifiedClasses()) { // TODO: Class.forName() expects a binary name but doc.qualifiedName() // returns a fully qualified name. I do not know a good way to convert // between these two name formats. For now, we simply ignore inner // classes. This limitation can be removed when we figure out a better // way to go from ClassDoc to Class<?>. if (doc.containingClass() != null) { continue; } Class<?> clazz; try { @SuppressWarnings("signature") // Javadoc source code is not yet annotated @BinaryName String className = doc.qualifiedName(); clazz = Class.forName(className, true, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { e.printStackTrace(); Options.printClassPath(); return false; } if (needsInstantiation(clazz)) { try { Constructor<?> c = clazz.getDeclaredConstructor(); c.setAccessible(true); objs.add(c.newInstance(new Object[0])); } catch (Exception e) { e.printStackTrace(); return false; } } else { objs.add(clazz); } } if (objs.isEmpty()) { System.out.println("Error: no classes found"); return false; } Object[] objarray = objs.toArray(); Options options = new Options(objarray); if (options.getOptions().size() < 1) { System.out.println("Error: no @Option-annotated fields found"); return false; } OptionsDoclet o = new OptionsDoclet(root, options); o.setOptions(root.options()); o.processJavadoc(); try { o.write(); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
java
public static boolean start(RootDoc root) { List<Object> objs = new ArrayList<>(); for (ClassDoc doc : root.specifiedClasses()) { // TODO: Class.forName() expects a binary name but doc.qualifiedName() // returns a fully qualified name. I do not know a good way to convert // between these two name formats. For now, we simply ignore inner // classes. This limitation can be removed when we figure out a better // way to go from ClassDoc to Class<?>. if (doc.containingClass() != null) { continue; } Class<?> clazz; try { @SuppressWarnings("signature") // Javadoc source code is not yet annotated @BinaryName String className = doc.qualifiedName(); clazz = Class.forName(className, true, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { e.printStackTrace(); Options.printClassPath(); return false; } if (needsInstantiation(clazz)) { try { Constructor<?> c = clazz.getDeclaredConstructor(); c.setAccessible(true); objs.add(c.newInstance(new Object[0])); } catch (Exception e) { e.printStackTrace(); return false; } } else { objs.add(clazz); } } if (objs.isEmpty()) { System.out.println("Error: no classes found"); return false; } Object[] objarray = objs.toArray(); Options options = new Options(objarray); if (options.getOptions().size() < 1) { System.out.println("Error: no @Option-annotated fields found"); return false; } OptionsDoclet o = new OptionsDoclet(root, options); o.setOptions(root.options()); o.processJavadoc(); try { o.write(); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
[ "public", "static", "boolean", "start", "(", "RootDoc", "root", ")", "{", "List", "<", "Object", ">", "objs", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "ClassDoc", "doc", ":", "root", ".", "specifiedClasses", "(", ")", ")", "{", "// TODO: Class.forName() expects a binary name but doc.qualifiedName()", "// returns a fully qualified name. I do not know a good way to convert", "// between these two name formats. For now, we simply ignore inner", "// classes. This limitation can be removed when we figure out a better", "// way to go from ClassDoc to Class<?>.", "if", "(", "doc", ".", "containingClass", "(", ")", "!=", "null", ")", "{", "continue", ";", "}", "Class", "<", "?", ">", "clazz", ";", "try", "{", "@", "SuppressWarnings", "(", "\"signature\"", ")", "// Javadoc source code is not yet annotated", "@", "BinaryName", "String", "className", "=", "doc", ".", "qualifiedName", "(", ")", ";", "clazz", "=", "Class", ".", "forName", "(", "className", ",", "true", ",", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "Options", ".", "printClassPath", "(", ")", ";", "return", "false", ";", "}", "if", "(", "needsInstantiation", "(", "clazz", ")", ")", "{", "try", "{", "Constructor", "<", "?", ">", "c", "=", "clazz", ".", "getDeclaredConstructor", "(", ")", ";", "c", ".", "setAccessible", "(", "true", ")", ";", "objs", ".", "add", "(", "c", ".", "newInstance", "(", "new", "Object", "[", "0", "]", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "false", ";", "}", "}", "else", "{", "objs", ".", "add", "(", "clazz", ")", ";", "}", "}", "if", "(", "objs", ".", "isEmpty", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"Error: no classes found\"", ")", ";", "return", "false", ";", "}", "Object", "[", "]", "objarray", "=", "objs", ".", "toArray", "(", ")", ";", "Options", "options", "=", "new", "Options", "(", "objarray", ")", ";", "if", "(", "options", ".", "getOptions", "(", ")", ".", "size", "(", ")", "<", "1", ")", "{", "System", ".", "out", ".", "println", "(", "\"Error: no @Option-annotated fields found\"", ")", ";", "return", "false", ";", "}", "OptionsDoclet", "o", "=", "new", "OptionsDoclet", "(", "root", ",", "options", ")", ";", "o", ".", "setOptions", "(", "root", ".", "options", "(", ")", ")", ";", "o", ".", "processJavadoc", "(", ")", ";", "try", "{", "o", ".", "write", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Entry point for the doclet. @param root the root document @return true if processing completed without an error
[ "Entry", "point", "for", "the", "doclet", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/OptionsDoclet.java#L225-L285
1,159
plume-lib/options
src/main/java/org/plumelib/options/OptionsDoclet.java
OptionsDoclet.optionLength
public static int optionLength(String option) { if (option.equals("-help")) { System.out.printf(USAGE); return 1; } if (option.equals("-i") || option.equals("-classdoc") || option.equals("-singledash")) { return 1; } if (option.equals("-docfile") || option.equals("-outfile") || option.equals("-format") || option.equals("-d")) { return 2; } return 0; }
java
public static int optionLength(String option) { if (option.equals("-help")) { System.out.printf(USAGE); return 1; } if (option.equals("-i") || option.equals("-classdoc") || option.equals("-singledash")) { return 1; } if (option.equals("-docfile") || option.equals("-outfile") || option.equals("-format") || option.equals("-d")) { return 2; } return 0; }
[ "public", "static", "int", "optionLength", "(", "String", "option", ")", "{", "if", "(", "option", ".", "equals", "(", "\"-help\"", ")", ")", "{", "System", ".", "out", ".", "printf", "(", "USAGE", ")", ";", "return", "1", ";", "}", "if", "(", "option", ".", "equals", "(", "\"-i\"", ")", "||", "option", ".", "equals", "(", "\"-classdoc\"", ")", "||", "option", ".", "equals", "(", "\"-singledash\"", ")", ")", "{", "return", "1", ";", "}", "if", "(", "option", ".", "equals", "(", "\"-docfile\"", ")", "||", "option", ".", "equals", "(", "\"-outfile\"", ")", "||", "option", ".", "equals", "(", "\"-format\"", ")", "||", "option", ".", "equals", "(", "\"-d\"", ")", ")", "{", "return", "2", ";", "}", "return", "0", ";", "}" ]
Given a command-line option of this doclet, returns the number of arguments you must specify on the command line for the given option. Returns 0 if the argument is not recognized. This method is automatically invoked by Javadoc. @param option the command-line option @return the number of command-line arguments needed when using the option @see <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/doclet/overview.html">Doclet overview</a>
[ "Given", "a", "command", "-", "line", "option", "of", "this", "doclet", "returns", "the", "number", "of", "arguments", "you", "must", "specify", "on", "the", "command", "line", "for", "the", "given", "option", ".", "Returns", "0", "if", "the", "argument", "is", "not", "recognized", ".", "This", "method", "is", "automatically", "invoked", "by", "Javadoc", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/OptionsDoclet.java#L298-L313
1,160
plume-lib/options
src/main/java/org/plumelib/options/OptionsDoclet.java
OptionsDoclet.validOptions
@SuppressWarnings("index") // dependent: os[1] is legal when optionLength(os[0])==2 public static boolean validOptions(String[] @MinLen(1) [] options, DocErrorReporter reporter) { boolean hasDocFile = false; boolean hasOutFile = false; boolean hasDestDir = false; boolean hasFormat = false; boolean inPlace = false; String docFile = null; String outFile = null; for (int oi = 0; oi < options.length; oi++) { String[] os = options[oi]; String opt = os[0].toLowerCase(); if (opt.equals("-docfile")) { if (hasDocFile) { reporter.printError("-docfile option specified twice"); return false; } docFile = os[1]; File f = new File(docFile); if (!f.exists()) { reporter.printError("-docfile file not found: " + docFile); return false; } hasDocFile = true; } if (opt.equals("-outfile")) { if (hasOutFile) { reporter.printError("-outfile option specified twice"); return false; } if (inPlace) { reporter.printError("-i and -outfile can not be used at the same time"); return false; } outFile = os[1]; hasOutFile = true; } if (opt.equals("-i")) { if (hasOutFile) { reporter.printError("-i and -outfile can not be used at the same time"); return false; } inPlace = true; } if (opt.equals("-format")) { if (hasFormat) { reporter.printError("-format option specified twice"); return false; } String format = os[1]; if (!format.equals("javadoc") && !format.equals("html")) { reporter.printError("unrecognized output format: " + format); return false; } hasFormat = true; } if (opt.equals("-d")) { if (hasDestDir) { reporter.printError("-d specified twice"); return false; } hasDestDir = true; } } if (docFile != null && outFile != null && outFile.equals(docFile)) { reporter.printError("docfile must be different from outfile"); return false; } if (inPlace && docFile == null) { reporter.printError("-i supplied but -docfile was not"); return false; } return true; }
java
@SuppressWarnings("index") // dependent: os[1] is legal when optionLength(os[0])==2 public static boolean validOptions(String[] @MinLen(1) [] options, DocErrorReporter reporter) { boolean hasDocFile = false; boolean hasOutFile = false; boolean hasDestDir = false; boolean hasFormat = false; boolean inPlace = false; String docFile = null; String outFile = null; for (int oi = 0; oi < options.length; oi++) { String[] os = options[oi]; String opt = os[0].toLowerCase(); if (opt.equals("-docfile")) { if (hasDocFile) { reporter.printError("-docfile option specified twice"); return false; } docFile = os[1]; File f = new File(docFile); if (!f.exists()) { reporter.printError("-docfile file not found: " + docFile); return false; } hasDocFile = true; } if (opt.equals("-outfile")) { if (hasOutFile) { reporter.printError("-outfile option specified twice"); return false; } if (inPlace) { reporter.printError("-i and -outfile can not be used at the same time"); return false; } outFile = os[1]; hasOutFile = true; } if (opt.equals("-i")) { if (hasOutFile) { reporter.printError("-i and -outfile can not be used at the same time"); return false; } inPlace = true; } if (opt.equals("-format")) { if (hasFormat) { reporter.printError("-format option specified twice"); return false; } String format = os[1]; if (!format.equals("javadoc") && !format.equals("html")) { reporter.printError("unrecognized output format: " + format); return false; } hasFormat = true; } if (opt.equals("-d")) { if (hasDestDir) { reporter.printError("-d specified twice"); return false; } hasDestDir = true; } } if (docFile != null && outFile != null && outFile.equals(docFile)) { reporter.printError("docfile must be different from outfile"); return false; } if (inPlace && docFile == null) { reporter.printError("-i supplied but -docfile was not"); return false; } return true; }
[ "@", "SuppressWarnings", "(", "\"index\"", ")", "// dependent: os[1] is legal when optionLength(os[0])==2", "public", "static", "boolean", "validOptions", "(", "String", "[", "]", "@", "MinLen", "(", "1", ")", "[", "]", "options", ",", "DocErrorReporter", "reporter", ")", "{", "boolean", "hasDocFile", "=", "false", ";", "boolean", "hasOutFile", "=", "false", ";", "boolean", "hasDestDir", "=", "false", ";", "boolean", "hasFormat", "=", "false", ";", "boolean", "inPlace", "=", "false", ";", "String", "docFile", "=", "null", ";", "String", "outFile", "=", "null", ";", "for", "(", "int", "oi", "=", "0", ";", "oi", "<", "options", ".", "length", ";", "oi", "++", ")", "{", "String", "[", "]", "os", "=", "options", "[", "oi", "]", ";", "String", "opt", "=", "os", "[", "0", "]", ".", "toLowerCase", "(", ")", ";", "if", "(", "opt", ".", "equals", "(", "\"-docfile\"", ")", ")", "{", "if", "(", "hasDocFile", ")", "{", "reporter", ".", "printError", "(", "\"-docfile option specified twice\"", ")", ";", "return", "false", ";", "}", "docFile", "=", "os", "[", "1", "]", ";", "File", "f", "=", "new", "File", "(", "docFile", ")", ";", "if", "(", "!", "f", ".", "exists", "(", ")", ")", "{", "reporter", ".", "printError", "(", "\"-docfile file not found: \"", "+", "docFile", ")", ";", "return", "false", ";", "}", "hasDocFile", "=", "true", ";", "}", "if", "(", "opt", ".", "equals", "(", "\"-outfile\"", ")", ")", "{", "if", "(", "hasOutFile", ")", "{", "reporter", ".", "printError", "(", "\"-outfile option specified twice\"", ")", ";", "return", "false", ";", "}", "if", "(", "inPlace", ")", "{", "reporter", ".", "printError", "(", "\"-i and -outfile can not be used at the same time\"", ")", ";", "return", "false", ";", "}", "outFile", "=", "os", "[", "1", "]", ";", "hasOutFile", "=", "true", ";", "}", "if", "(", "opt", ".", "equals", "(", "\"-i\"", ")", ")", "{", "if", "(", "hasOutFile", ")", "{", "reporter", ".", "printError", "(", "\"-i and -outfile can not be used at the same time\"", ")", ";", "return", "false", ";", "}", "inPlace", "=", "true", ";", "}", "if", "(", "opt", ".", "equals", "(", "\"-format\"", ")", ")", "{", "if", "(", "hasFormat", ")", "{", "reporter", ".", "printError", "(", "\"-format option specified twice\"", ")", ";", "return", "false", ";", "}", "String", "format", "=", "os", "[", "1", "]", ";", "if", "(", "!", "format", ".", "equals", "(", "\"javadoc\"", ")", "&&", "!", "format", ".", "equals", "(", "\"html\"", ")", ")", "{", "reporter", ".", "printError", "(", "\"unrecognized output format: \"", "+", "format", ")", ";", "return", "false", ";", "}", "hasFormat", "=", "true", ";", "}", "if", "(", "opt", ".", "equals", "(", "\"-d\"", ")", ")", "{", "if", "(", "hasDestDir", ")", "{", "reporter", ".", "printError", "(", "\"-d specified twice\"", ")", ";", "return", "false", ";", "}", "hasDestDir", "=", "true", ";", "}", "}", "if", "(", "docFile", "!=", "null", "&&", "outFile", "!=", "null", "&&", "outFile", ".", "equals", "(", "docFile", ")", ")", "{", "reporter", ".", "printError", "(", "\"docfile must be different from outfile\"", ")", ";", "return", "false", ";", "}", "if", "(", "inPlace", "&&", "docFile", "==", "null", ")", "{", "reporter", ".", "printError", "(", "\"-i supplied but -docfile was not\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Tests the validity of command-line arguments passed to this doclet. Returns true if the option usage is valid, and false otherwise. This method is automatically invoked by Javadoc. <p>Also sets fields from the command-line arguments. @param options the command-line options to be checked: an array of 1- or 2-element arrays, where the length depends on {@link #optionLength} applied to the first element @param reporter where to report errors @return true iff the command-line options are valid @see <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/doclet/overview.html">Doclet overview</a>
[ "Tests", "the", "validity", "of", "command", "-", "line", "arguments", "passed", "to", "this", "doclet", ".", "Returns", "true", "if", "the", "option", "usage", "is", "valid", "and", "false", "otherwise", ".", "This", "method", "is", "automatically", "invoked", "by", "Javadoc", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/OptionsDoclet.java#L329-L402
1,161
plume-lib/options
src/main/java/org/plumelib/options/OptionsDoclet.java
OptionsDoclet.write
public void write() throws Exception { PrintWriter out; String output = output(); if (outFile != null) { out = new PrintWriter(Files.newBufferedWriter(outFile.toPath(), UTF_8)); } else if (inPlace) { assert docFile != null : "@AssumeAssertion(nullness): dependent: docFile is non-null if inPlace is true"; out = new PrintWriter(Files.newBufferedWriter(docFile.toPath(), UTF_8)); } else { out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out, UTF_8))); } out.println(output); out.flush(); out.close(); }
java
public void write() throws Exception { PrintWriter out; String output = output(); if (outFile != null) { out = new PrintWriter(Files.newBufferedWriter(outFile.toPath(), UTF_8)); } else if (inPlace) { assert docFile != null : "@AssumeAssertion(nullness): dependent: docFile is non-null if inPlace is true"; out = new PrintWriter(Files.newBufferedWriter(docFile.toPath(), UTF_8)); } else { out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out, UTF_8))); } out.println(output); out.flush(); out.close(); }
[ "public", "void", "write", "(", ")", "throws", "Exception", "{", "PrintWriter", "out", ";", "String", "output", "=", "output", "(", ")", ";", "if", "(", "outFile", "!=", "null", ")", "{", "out", "=", "new", "PrintWriter", "(", "Files", ".", "newBufferedWriter", "(", "outFile", ".", "toPath", "(", ")", ",", "UTF_8", ")", ")", ";", "}", "else", "if", "(", "inPlace", ")", "{", "assert", "docFile", "!=", "null", ":", "\"@AssumeAssertion(nullness): dependent: docFile is non-null if inPlace is true\"", ";", "out", "=", "new", "PrintWriter", "(", "Files", ".", "newBufferedWriter", "(", "docFile", ".", "toPath", "(", ")", ",", "UTF_8", ")", ")", ";", "}", "else", "{", "out", "=", "new", "PrintWriter", "(", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "System", ".", "out", ",", "UTF_8", ")", ")", ")", ";", "}", "out", ".", "println", "(", "output", ")", ";", "out", ".", "flush", "(", ")", ";", "out", ".", "close", "(", ")", ";", "}" ]
Write the output of this doclet to the correct file. @throws Exception if there is trouble
[ "Write", "the", "output", "of", "this", "doclet", "to", "the", "correct", "file", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/OptionsDoclet.java#L466-L483
1,162
plume-lib/options
src/main/java/org/plumelib/options/OptionsDoclet.java
OptionsDoclet.newDocFileText
@RequiresNonNull("docFile") private String newDocFileText() throws Exception { StringJoiner b = new StringJoiner(lineSep); BufferedReader doc = Files.newBufferedReader(docFile.toPath(), UTF_8); String docline; boolean replacing = false; boolean replacedOnce = false; String prefix = null; while ((docline = doc.readLine()) != null) { if (replacing) { if (docline.trim().equals(endDelim)) { replacing = false; } else { continue; } } b.add(docline); if (!replacedOnce && docline.trim().equals(startDelim)) { if (formatJavadoc) { int starIndex = docline.indexOf('*'); b.add(docline.substring(0, starIndex + 1)); String jdoc = optionsToJavadoc(starIndex, 100); b.add(jdoc); if (jdoc.endsWith("</ul>")) { b.add(docline.substring(0, starIndex + 1)); } } else { b.add(optionsToHtml(0)); } replacedOnce = true; replacing = true; } } doc.close(); return b.toString(); }
java
@RequiresNonNull("docFile") private String newDocFileText() throws Exception { StringJoiner b = new StringJoiner(lineSep); BufferedReader doc = Files.newBufferedReader(docFile.toPath(), UTF_8); String docline; boolean replacing = false; boolean replacedOnce = false; String prefix = null; while ((docline = doc.readLine()) != null) { if (replacing) { if (docline.trim().equals(endDelim)) { replacing = false; } else { continue; } } b.add(docline); if (!replacedOnce && docline.trim().equals(startDelim)) { if (formatJavadoc) { int starIndex = docline.indexOf('*'); b.add(docline.substring(0, starIndex + 1)); String jdoc = optionsToJavadoc(starIndex, 100); b.add(jdoc); if (jdoc.endsWith("</ul>")) { b.add(docline.substring(0, starIndex + 1)); } } else { b.add(optionsToHtml(0)); } replacedOnce = true; replacing = true; } } doc.close(); return b.toString(); }
[ "@", "RequiresNonNull", "(", "\"docFile\"", ")", "private", "String", "newDocFileText", "(", ")", "throws", "Exception", "{", "StringJoiner", "b", "=", "new", "StringJoiner", "(", "lineSep", ")", ";", "BufferedReader", "doc", "=", "Files", ".", "newBufferedReader", "(", "docFile", ".", "toPath", "(", ")", ",", "UTF_8", ")", ";", "String", "docline", ";", "boolean", "replacing", "=", "false", ";", "boolean", "replacedOnce", "=", "false", ";", "String", "prefix", "=", "null", ";", "while", "(", "(", "docline", "=", "doc", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "replacing", ")", "{", "if", "(", "docline", ".", "trim", "(", ")", ".", "equals", "(", "endDelim", ")", ")", "{", "replacing", "=", "false", ";", "}", "else", "{", "continue", ";", "}", "}", "b", ".", "add", "(", "docline", ")", ";", "if", "(", "!", "replacedOnce", "&&", "docline", ".", "trim", "(", ")", ".", "equals", "(", "startDelim", ")", ")", "{", "if", "(", "formatJavadoc", ")", "{", "int", "starIndex", "=", "docline", ".", "indexOf", "(", "'", "'", ")", ";", "b", ".", "add", "(", "docline", ".", "substring", "(", "0", ",", "starIndex", "+", "1", ")", ")", ";", "String", "jdoc", "=", "optionsToJavadoc", "(", "starIndex", ",", "100", ")", ";", "b", ".", "add", "(", "jdoc", ")", ";", "if", "(", "jdoc", ".", "endsWith", "(", "\"</ul>\"", ")", ")", "{", "b", ".", "add", "(", "docline", ".", "substring", "(", "0", ",", "starIndex", "+", "1", ")", ")", ";", "}", "}", "else", "{", "b", ".", "add", "(", "optionsToHtml", "(", "0", ")", ")", ";", "}", "replacedOnce", "=", "true", ";", "replacing", "=", "true", ";", "}", "}", "doc", ".", "close", "(", ")", ";", "return", "b", ".", "toString", "(", ")", ";", "}" ]
Get the result of inserting the options documentation into the docfile. @return the docfile, but with the command-line argument documentation updated @throws Exception if there is trouble reading files
[ "Get", "the", "result", "of", "inserting", "the", "options", "documentation", "into", "the", "docfile", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/OptionsDoclet.java#L510-L549
1,163
plume-lib/options
src/main/java/org/plumelib/options/OptionsDoclet.java
OptionsDoclet.optionsToHtml
public String optionsToHtml(int refillWidth) { StringJoiner b = new StringJoiner(lineSep); if (includeClassDoc && root.classes().length > 0) { b.add(OptionsDoclet.javadocToHtml(root.classes()[0])); b.add("<p>Command line options:</p>"); } b.add("<ul>"); if (!options.hasGroups()) { b.add(optionListToHtml(options.getOptions(), 6, 2, refillWidth)); } else { for (Options.OptionGroupInfo gi : options.getOptionGroups()) { // Do not include groups without publicized options in output if (!gi.anyPublicized()) { continue; } String ogroupHeader = " <li id=\"optiongroup:" + gi.name.replace(" ", "-").replace("/", "-") + "\">" + gi.name; b.add(refill(ogroupHeader, 6, 2, refillWidth)); b.add(" <ul>"); b.add(optionListToHtml(gi.optionList, 12, 8, refillWidth)); b.add(" </ul>"); // b.add(" </li>"); } } b.add("</ul>"); for (Options.OptionInfo oi : options.getOptions()) { if (oi.list != null && !oi.unpublicized) { b.add(""); b.add(LIST_HELP); break; } } return b.toString(); }
java
public String optionsToHtml(int refillWidth) { StringJoiner b = new StringJoiner(lineSep); if (includeClassDoc && root.classes().length > 0) { b.add(OptionsDoclet.javadocToHtml(root.classes()[0])); b.add("<p>Command line options:</p>"); } b.add("<ul>"); if (!options.hasGroups()) { b.add(optionListToHtml(options.getOptions(), 6, 2, refillWidth)); } else { for (Options.OptionGroupInfo gi : options.getOptionGroups()) { // Do not include groups without publicized options in output if (!gi.anyPublicized()) { continue; } String ogroupHeader = " <li id=\"optiongroup:" + gi.name.replace(" ", "-").replace("/", "-") + "\">" + gi.name; b.add(refill(ogroupHeader, 6, 2, refillWidth)); b.add(" <ul>"); b.add(optionListToHtml(gi.optionList, 12, 8, refillWidth)); b.add(" </ul>"); // b.add(" </li>"); } } b.add("</ul>"); for (Options.OptionInfo oi : options.getOptions()) { if (oi.list != null && !oi.unpublicized) { b.add(""); b.add(LIST_HELP); break; } } return b.toString(); }
[ "public", "String", "optionsToHtml", "(", "int", "refillWidth", ")", "{", "StringJoiner", "b", "=", "new", "StringJoiner", "(", "lineSep", ")", ";", "if", "(", "includeClassDoc", "&&", "root", ".", "classes", "(", ")", ".", "length", ">", "0", ")", "{", "b", ".", "add", "(", "OptionsDoclet", ".", "javadocToHtml", "(", "root", ".", "classes", "(", ")", "[", "0", "]", ")", ")", ";", "b", ".", "add", "(", "\"<p>Command line options:</p>\"", ")", ";", "}", "b", ".", "add", "(", "\"<ul>\"", ")", ";", "if", "(", "!", "options", ".", "hasGroups", "(", ")", ")", "{", "b", ".", "add", "(", "optionListToHtml", "(", "options", ".", "getOptions", "(", ")", ",", "6", ",", "2", ",", "refillWidth", ")", ")", ";", "}", "else", "{", "for", "(", "Options", ".", "OptionGroupInfo", "gi", ":", "options", ".", "getOptionGroups", "(", ")", ")", "{", "// Do not include groups without publicized options in output", "if", "(", "!", "gi", ".", "anyPublicized", "(", ")", ")", "{", "continue", ";", "}", "String", "ogroupHeader", "=", "\" <li id=\\\"optiongroup:\"", "+", "gi", ".", "name", ".", "replace", "(", "\" \"", ",", "\"-\"", ")", ".", "replace", "(", "\"/\"", ",", "\"-\"", ")", "+", "\"\\\">\"", "+", "gi", ".", "name", ";", "b", ".", "add", "(", "refill", "(", "ogroupHeader", ",", "6", ",", "2", ",", "refillWidth", ")", ")", ";", "b", ".", "add", "(", "\" <ul>\"", ")", ";", "b", ".", "add", "(", "optionListToHtml", "(", "gi", ".", "optionList", ",", "12", ",", "8", ",", "refillWidth", ")", ")", ";", "b", ".", "add", "(", "\" </ul>\"", ")", ";", "// b.add(\" </li>\");", "}", "}", "b", ".", "add", "(", "\"</ul>\"", ")", ";", "for", "(", "Options", ".", "OptionInfo", "oi", ":", "options", ".", "getOptions", "(", ")", ")", "{", "if", "(", "oi", ".", "list", "!=", "null", "&&", "!", "oi", ".", "unpublicized", ")", "{", "b", ".", "add", "(", "\"\"", ")", ";", "b", ".", "add", "(", "LIST_HELP", ")", ";", "break", ";", "}", "}", "return", "b", ".", "toString", "(", ")", ";", "}" ]
Get the HTML documentation for the underlying Options instance. @param refillWidth the number of columns to fit the text into, by breaking lines @return the HTML documentation for the underlying Options instance
[ "Get", "the", "HTML", "documentation", "for", "the", "underlying", "Options", "instance", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/OptionsDoclet.java#L627-L668
1,164
plume-lib/options
src/main/java/org/plumelib/options/OptionsDoclet.java
OptionsDoclet.optionsToJavadoc
public String optionsToJavadoc(int padding, int refillWidth) { StringJoiner b = new StringJoiner(lineSep); Scanner s = new Scanner(optionsToHtml(refillWidth - padding - 2)); while (s.hasNextLine()) { String line = s.nextLine(); StringBuilder bb = new StringBuilder(); bb.append(StringUtils.repeat(" ", padding)); if (line.trim().equals("")) { bb.append("*"); } else { bb.append("* ").append(line); } b.add(bb); } return b.toString(); }
java
public String optionsToJavadoc(int padding, int refillWidth) { StringJoiner b = new StringJoiner(lineSep); Scanner s = new Scanner(optionsToHtml(refillWidth - padding - 2)); while (s.hasNextLine()) { String line = s.nextLine(); StringBuilder bb = new StringBuilder(); bb.append(StringUtils.repeat(" ", padding)); if (line.trim().equals("")) { bb.append("*"); } else { bb.append("* ").append(line); } b.add(bb); } return b.toString(); }
[ "public", "String", "optionsToJavadoc", "(", "int", "padding", ",", "int", "refillWidth", ")", "{", "StringJoiner", "b", "=", "new", "StringJoiner", "(", "lineSep", ")", ";", "Scanner", "s", "=", "new", "Scanner", "(", "optionsToHtml", "(", "refillWidth", "-", "padding", "-", "2", ")", ")", ";", "while", "(", "s", ".", "hasNextLine", "(", ")", ")", "{", "String", "line", "=", "s", ".", "nextLine", "(", ")", ";", "StringBuilder", "bb", "=", "new", "StringBuilder", "(", ")", ";", "bb", ".", "append", "(", "StringUtils", ".", "repeat", "(", "\" \"", ",", "padding", ")", ")", ";", "if", "(", "line", ".", "trim", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "bb", ".", "append", "(", "\"*\"", ")", ";", "}", "else", "{", "bb", ".", "append", "(", "\"* \"", ")", ".", "append", "(", "line", ")", ";", "}", "b", ".", "add", "(", "bb", ")", ";", "}", "return", "b", ".", "toString", "(", ")", ";", "}" ]
Get the HTML documentation for the underlying Options instance, formatted as a Javadoc comment. @param padding the number of leading spaces to add in the Javadoc output, before "* " @param refillWidth the number of columns to fit the text into, by breaking lines @return the HTML documentation for the underlying Options instance
[ "Get", "the", "HTML", "documentation", "for", "the", "underlying", "Options", "instance", "formatted", "as", "a", "Javadoc", "comment", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/OptionsDoclet.java#L677-L694
1,165
plume-lib/options
src/main/java/org/plumelib/options/OptionsDoclet.java
OptionsDoclet.optionListToHtml
private String optionListToHtml( List<Options.OptionInfo> optList, int padding, int firstLinePadding, int refillWidth) { StringJoiner b = new StringJoiner(lineSep); for (Options.OptionInfo oi : optList) { if (oi.unpublicized) { continue; } StringBuilder bb = new StringBuilder(); String optHtml = optionToHtml(oi, padding); bb.append(StringUtils.repeat(" ", padding)); bb.append("<li id=\"option:" + oi.longName + "\">").append(optHtml); // .append("</li>"); if (refillWidth <= 0) { b.add(bb); } else { b.add(refill(bb.toString(), padding, firstLinePadding, refillWidth)); } } return b.toString(); }
java
private String optionListToHtml( List<Options.OptionInfo> optList, int padding, int firstLinePadding, int refillWidth) { StringJoiner b = new StringJoiner(lineSep); for (Options.OptionInfo oi : optList) { if (oi.unpublicized) { continue; } StringBuilder bb = new StringBuilder(); String optHtml = optionToHtml(oi, padding); bb.append(StringUtils.repeat(" ", padding)); bb.append("<li id=\"option:" + oi.longName + "\">").append(optHtml); // .append("</li>"); if (refillWidth <= 0) { b.add(bb); } else { b.add(refill(bb.toString(), padding, firstLinePadding, refillWidth)); } } return b.toString(); }
[ "private", "String", "optionListToHtml", "(", "List", "<", "Options", ".", "OptionInfo", ">", "optList", ",", "int", "padding", ",", "int", "firstLinePadding", ",", "int", "refillWidth", ")", "{", "StringJoiner", "b", "=", "new", "StringJoiner", "(", "lineSep", ")", ";", "for", "(", "Options", ".", "OptionInfo", "oi", ":", "optList", ")", "{", "if", "(", "oi", ".", "unpublicized", ")", "{", "continue", ";", "}", "StringBuilder", "bb", "=", "new", "StringBuilder", "(", ")", ";", "String", "optHtml", "=", "optionToHtml", "(", "oi", ",", "padding", ")", ";", "bb", ".", "append", "(", "StringUtils", ".", "repeat", "(", "\" \"", ",", "padding", ")", ")", ";", "bb", ".", "append", "(", "\"<li id=\\\"option:\"", "+", "oi", ".", "longName", "+", "\"\\\">\"", ")", ".", "append", "(", "optHtml", ")", ";", "// .append(\"</li>\");", "if", "(", "refillWidth", "<=", "0", ")", "{", "b", ".", "add", "(", "bb", ")", ";", "}", "else", "{", "b", ".", "add", "(", "refill", "(", "bb", ".", "toString", "(", ")", ",", "padding", ",", "firstLinePadding", ",", "refillWidth", ")", ")", ";", "}", "}", "return", "b", ".", "toString", "(", ")", ";", "}" ]
Get the HTML describing many options, formatted as an HTML list. @param optList the options to document @param padding the number of leading spaces to add before each line of HTML output, except the first one @param firstLinePadding the number of leading spaces to add before the first line of HTML output @param refillWidth the number of columns to fit the text into, by breaking lines @return the options documented in HTML format
[ "Get", "the", "HTML", "describing", "many", "options", "formatted", "as", "an", "HTML", "list", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/OptionsDoclet.java#L707-L726
1,166
plume-lib/options
src/main/java/org/plumelib/options/OptionsDoclet.java
OptionsDoclet.optionToHtml
public String optionToHtml(Options.OptionInfo oi, int padding) { StringBuilder b = new StringBuilder(); Formatter f = new Formatter(b); if (oi.shortName != null) { f.format("<b>-%s</b> ", oi.shortName); } for (String a : oi.aliases) { f.format("<b>%s</b> ", a); } String prefix = getUseSingleDash() ? "-" : "--"; f.format("<b>%s%s=</b><i>%s</i>", prefix, oi.longName, oi.typeName); if (oi.list != null) { b.append(" <code>[+]</code>"); } f.format(".%n "); f.format("%s", StringUtils.repeat(" ", padding)); String jdoc = ((oi.jdoc == null) ? "" : oi.jdoc); if (oi.noDocDefault || oi.defaultStr == null) { f.format("%s", jdoc); } else { String defaultStr = "default " + oi.defaultStr; // The default string must be HTML-escaped since it comes from a string // rather than a Javadoc comment. String suffix = ""; if (jdoc.endsWith("</p>")) { suffix = "</p>"; jdoc = jdoc.substring(0, jdoc.length() - suffix.length()); } f.format("%s [%s]%s", jdoc, StringEscapeUtils.escapeHtml4(defaultStr), suffix); } if (oi.baseType.isEnum()) { b.append(lineSep).append("<ul>").append(lineSep); assert oi.enumJdoc != null : "@AssumeAssertion(nullness): dependent: non-null if oi.baseType is an enum"; for (Map.Entry<String, String> entry : oi.enumJdoc.entrySet()) { b.append(" <li><b>").append(entry.getKey()).append("</b>"); if (entry.getValue().length() != 0) { b.append(" ").append(entry.getValue()); } // b.append("</li>"); b.append(lineSep); } b.append("</ul>").append(lineSep); } return b.toString(); }
java
public String optionToHtml(Options.OptionInfo oi, int padding) { StringBuilder b = new StringBuilder(); Formatter f = new Formatter(b); if (oi.shortName != null) { f.format("<b>-%s</b> ", oi.shortName); } for (String a : oi.aliases) { f.format("<b>%s</b> ", a); } String prefix = getUseSingleDash() ? "-" : "--"; f.format("<b>%s%s=</b><i>%s</i>", prefix, oi.longName, oi.typeName); if (oi.list != null) { b.append(" <code>[+]</code>"); } f.format(".%n "); f.format("%s", StringUtils.repeat(" ", padding)); String jdoc = ((oi.jdoc == null) ? "" : oi.jdoc); if (oi.noDocDefault || oi.defaultStr == null) { f.format("%s", jdoc); } else { String defaultStr = "default " + oi.defaultStr; // The default string must be HTML-escaped since it comes from a string // rather than a Javadoc comment. String suffix = ""; if (jdoc.endsWith("</p>")) { suffix = "</p>"; jdoc = jdoc.substring(0, jdoc.length() - suffix.length()); } f.format("%s [%s]%s", jdoc, StringEscapeUtils.escapeHtml4(defaultStr), suffix); } if (oi.baseType.isEnum()) { b.append(lineSep).append("<ul>").append(lineSep); assert oi.enumJdoc != null : "@AssumeAssertion(nullness): dependent: non-null if oi.baseType is an enum"; for (Map.Entry<String, String> entry : oi.enumJdoc.entrySet()) { b.append(" <li><b>").append(entry.getKey()).append("</b>"); if (entry.getValue().length() != 0) { b.append(" ").append(entry.getValue()); } // b.append("</li>"); b.append(lineSep); } b.append("</ul>").append(lineSep); } return b.toString(); }
[ "public", "String", "optionToHtml", "(", "Options", ".", "OptionInfo", "oi", ",", "int", "padding", ")", "{", "StringBuilder", "b", "=", "new", "StringBuilder", "(", ")", ";", "Formatter", "f", "=", "new", "Formatter", "(", "b", ")", ";", "if", "(", "oi", ".", "shortName", "!=", "null", ")", "{", "f", ".", "format", "(", "\"<b>-%s</b> \"", ",", "oi", ".", "shortName", ")", ";", "}", "for", "(", "String", "a", ":", "oi", ".", "aliases", ")", "{", "f", ".", "format", "(", "\"<b>%s</b> \"", ",", "a", ")", ";", "}", "String", "prefix", "=", "getUseSingleDash", "(", ")", "?", "\"-\"", ":", "\"--\"", ";", "f", ".", "format", "(", "\"<b>%s%s=</b><i>%s</i>\"", ",", "prefix", ",", "oi", ".", "longName", ",", "oi", ".", "typeName", ")", ";", "if", "(", "oi", ".", "list", "!=", "null", ")", "{", "b", ".", "append", "(", "\" <code>[+]</code>\"", ")", ";", "}", "f", ".", "format", "(", "\".%n \"", ")", ";", "f", ".", "format", "(", "\"%s\"", ",", "StringUtils", ".", "repeat", "(", "\" \"", ",", "padding", ")", ")", ";", "String", "jdoc", "=", "(", "(", "oi", ".", "jdoc", "==", "null", ")", "?", "\"\"", ":", "oi", ".", "jdoc", ")", ";", "if", "(", "oi", ".", "noDocDefault", "||", "oi", ".", "defaultStr", "==", "null", ")", "{", "f", ".", "format", "(", "\"%s\"", ",", "jdoc", ")", ";", "}", "else", "{", "String", "defaultStr", "=", "\"default \"", "+", "oi", ".", "defaultStr", ";", "// The default string must be HTML-escaped since it comes from a string", "// rather than a Javadoc comment.", "String", "suffix", "=", "\"\"", ";", "if", "(", "jdoc", ".", "endsWith", "(", "\"</p>\"", ")", ")", "{", "suffix", "=", "\"</p>\"", ";", "jdoc", "=", "jdoc", ".", "substring", "(", "0", ",", "jdoc", ".", "length", "(", ")", "-", "suffix", ".", "length", "(", ")", ")", ";", "}", "f", ".", "format", "(", "\"%s [%s]%s\"", ",", "jdoc", ",", "StringEscapeUtils", ".", "escapeHtml4", "(", "defaultStr", ")", ",", "suffix", ")", ";", "}", "if", "(", "oi", ".", "baseType", ".", "isEnum", "(", ")", ")", "{", "b", ".", "append", "(", "lineSep", ")", ".", "append", "(", "\"<ul>\"", ")", ".", "append", "(", "lineSep", ")", ";", "assert", "oi", ".", "enumJdoc", "!=", "null", ":", "\"@AssumeAssertion(nullness): dependent: non-null if oi.baseType is an enum\"", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "oi", ".", "enumJdoc", ".", "entrySet", "(", ")", ")", "{", "b", ".", "append", "(", "\" <li><b>\"", ")", ".", "append", "(", "entry", ".", "getKey", "(", ")", ")", ".", "append", "(", "\"</b>\"", ")", ";", "if", "(", "entry", ".", "getValue", "(", ")", ".", "length", "(", ")", "!=", "0", ")", "{", "b", ".", "append", "(", "\" \"", ")", ".", "append", "(", "entry", ".", "getValue", "(", ")", ")", ";", "}", "// b.append(\"</li>\");", "b", ".", "append", "(", "lineSep", ")", ";", "}", "b", ".", "append", "(", "\"</ul>\"", ")", ".", "append", "(", "lineSep", ")", ";", "}", "return", "b", ".", "toString", "(", ")", ";", "}" ]
Get the line of HTML describing one Option. @param oi the option to describe @param padding the number of spaces to add at the begginning of the detail line (after the line with the option itself) @return HTML describing oi
[ "Get", "the", "line", "of", "HTML", "describing", "one", "Option", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/OptionsDoclet.java#L792-L838
1,167
plume-lib/options
src/main/java/org/plumelib/options/OptionsDoclet.java
OptionsDoclet.setFormatJavadoc
public void setFormatJavadoc(boolean val) { if (val && !formatJavadoc) { startDelim = "* " + startDelim; endDelim = "* " + endDelim; } else if (!val && formatJavadoc) { startDelim = StringUtils.removeStart("* ", startDelim); endDelim = StringUtils.removeStart("* ", endDelim); } this.formatJavadoc = val; }
java
public void setFormatJavadoc(boolean val) { if (val && !formatJavadoc) { startDelim = "* " + startDelim; endDelim = "* " + endDelim; } else if (!val && formatJavadoc) { startDelim = StringUtils.removeStart("* ", startDelim); endDelim = StringUtils.removeStart("* ", endDelim); } this.formatJavadoc = val; }
[ "public", "void", "setFormatJavadoc", "(", "boolean", "val", ")", "{", "if", "(", "val", "&&", "!", "formatJavadoc", ")", "{", "startDelim", "=", "\"* \"", "+", "startDelim", ";", "endDelim", "=", "\"* \"", "+", "endDelim", ";", "}", "else", "if", "(", "!", "val", "&&", "formatJavadoc", ")", "{", "startDelim", "=", "StringUtils", ".", "removeStart", "(", "\"* \"", ",", "startDelim", ")", ";", "endDelim", "=", "StringUtils", ".", "removeStart", "(", "\"* \"", ",", "endDelim", ")", ";", "}", "this", ".", "formatJavadoc", "=", "val", ";", "}" ]
Supply true to set the output format to Javadoc, false to set the output format to HTML. @param val true to set the output format to Javadoc, false to set the output format to HTML
[ "Supply", "true", "to", "set", "the", "output", "format", "to", "Javadoc", "false", "to", "set", "the", "output", "format", "to", "HTML", "." ]
1bdd0ac7a1794bdf9dd373e279f69d43395154f0
https://github.com/plume-lib/options/blob/1bdd0ac7a1794bdf9dd373e279f69d43395154f0/src/main/java/org/plumelib/options/OptionsDoclet.java#L897-L906
1,168
alrocar/POIProxy
es.alrocar.map.vector/src/main/java/es/alrocar/map/vector/provider/VectorTileCache.java
VectorTileCache.onLowMemory
public synchronized void onLowMemory() { try { this.mCachedTiles.clear(); } catch (Exception e) { log.log(Level.SEVERE, "onLowMemory", e); } }
java
public synchronized void onLowMemory() { try { this.mCachedTiles.clear(); } catch (Exception e) { log.log(Level.SEVERE, "onLowMemory", e); } }
[ "public", "synchronized", "void", "onLowMemory", "(", ")", "{", "try", "{", "this", ".", "mCachedTiles", ".", "clear", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"onLowMemory\"", ",", "e", ")", ";", "}", "}" ]
This method clears the memory cache
[ "This", "method", "clears", "the", "memory", "cache" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.map.vector/src/main/java/es/alrocar/map/vector/provider/VectorTileCache.java#L74-L80
1,169
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getJourney
public TransportApiResult<Journey> getJourney(String journeyId, String exclude) { if (Extensions.isNullOrWhiteSpace(journeyId)) { throw new IllegalArgumentException("JourneyId is required."); } return TransportApiClientCalls.getJourney(tokenComponent, settings, journeyId, exclude); }
java
public TransportApiResult<Journey> getJourney(String journeyId, String exclude) { if (Extensions.isNullOrWhiteSpace(journeyId)) { throw new IllegalArgumentException("JourneyId is required."); } return TransportApiClientCalls.getJourney(tokenComponent, settings, journeyId, exclude); }
[ "public", "TransportApiResult", "<", "Journey", ">", "getJourney", "(", "String", "journeyId", ",", "String", "exclude", ")", "{", "if", "(", "Extensions", ".", "isNullOrWhiteSpace", "(", "journeyId", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"JourneyId is required.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getJourney", "(", "tokenComponent", ",", "settings", ",", "journeyId", ",", "exclude", ")", ";", "}" ]
Gets a journey previously requested through the POST journey call. @param journeyId The id of the journey you want to get. Previously made in a POST journey call. @param exclude Entities to exclude from the call to reduce the payload. See https://developer.whereismytransport.com/documentation#excluding-data @return A previously requested journey.
[ "Gets", "a", "journey", "previously", "requested", "through", "the", "POST", "journey", "call", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L51-L59
1,170
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getItinerary
public TransportApiResult<Itinerary> getItinerary(String journeyId, String itineraryId, String exclude) { if (Extensions.isNullOrWhiteSpace(journeyId)) { throw new IllegalArgumentException("JourneyId is required."); } if (Extensions.isNullOrWhiteSpace(itineraryId)) { throw new IllegalArgumentException("ItineraryId is required."); } return TransportApiClientCalls.getItinerary(tokenComponent, settings, journeyId, itineraryId, exclude); }
java
public TransportApiResult<Itinerary> getItinerary(String journeyId, String itineraryId, String exclude) { if (Extensions.isNullOrWhiteSpace(journeyId)) { throw new IllegalArgumentException("JourneyId is required."); } if (Extensions.isNullOrWhiteSpace(itineraryId)) { throw new IllegalArgumentException("ItineraryId is required."); } return TransportApiClientCalls.getItinerary(tokenComponent, settings, journeyId, itineraryId, exclude); }
[ "public", "TransportApiResult", "<", "Itinerary", ">", "getItinerary", "(", "String", "journeyId", ",", "String", "itineraryId", ",", "String", "exclude", ")", "{", "if", "(", "Extensions", ".", "isNullOrWhiteSpace", "(", "journeyId", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"JourneyId is required.\"", ")", ";", "}", "if", "(", "Extensions", ".", "isNullOrWhiteSpace", "(", "itineraryId", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"ItineraryId is required.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getItinerary", "(", "tokenComponent", ",", "settings", ",", "journeyId", ",", "itineraryId", ",", "exclude", ")", ";", "}" ]
Gets a specific itinerary of a journey previously requested through the POST journey call. @param journeyId The id of the journey you want to get an itinerary for. Previously made in a POST journey call. @param itineraryId The id of the itinerary you want to get. Previously made in a POST journey call. @param exclude Entities to exclude from the call to reduce the payload. See https://developer.whereismytransport.com/documentation#excluding-data @return A previously requested itinerary.
[ "Gets", "a", "specific", "itinerary", "of", "a", "journey", "previously", "requested", "through", "the", "POST", "journey", "call", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L69-L82
1,171
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getAgencies
public TransportApiResult<List<Agency>> getAgencies(AgencyQueryOptions options) { if (options == null) { options = AgencyQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getAgencies(tokenComponent, settings, options, null, null, null); }
java
public TransportApiResult<List<Agency>> getAgencies(AgencyQueryOptions options) { if (options == null) { options = AgencyQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getAgencies(tokenComponent, settings, options, null, null, null); }
[ "public", "TransportApiResult", "<", "List", "<", "Agency", ">", ">", "getAgencies", "(", "AgencyQueryOptions", "options", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "AgencyQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getAgencies", "(", "tokenComponent", ",", "settings", ",", "options", ",", "null", ",", "null", ",", "null", ")", ";", "}" ]
Gets a list of all agencies in the system. @param options Options to limit the results by. Default: AgencyQueryOptions.defaultQueryOptions() @return A list of all agencies.
[ "Gets", "a", "list", "of", "all", "agencies", "in", "the", "system", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L90-L98
1,172
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getAgenciesByBoundingBox
public TransportApiResult<List<Agency>> getAgenciesByBoundingBox(AgencyQueryOptions options, String boundingBox) { if (options == null) { options = AgencyQueryOptions.defaultQueryOptions(); } if (boundingBox == null) { throw new IllegalArgumentException("BoundingBox is required."); } String[] bbox = boundingBox.split(",", -1); if (bbox.length != 4) { throw new IllegalArgumentException("Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box."); } return TransportApiClientCalls.getAgencies(tokenComponent, settings, options, null, null, boundingBox); }
java
public TransportApiResult<List<Agency>> getAgenciesByBoundingBox(AgencyQueryOptions options, String boundingBox) { if (options == null) { options = AgencyQueryOptions.defaultQueryOptions(); } if (boundingBox == null) { throw new IllegalArgumentException("BoundingBox is required."); } String[] bbox = boundingBox.split(",", -1); if (bbox.length != 4) { throw new IllegalArgumentException("Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box."); } return TransportApiClientCalls.getAgencies(tokenComponent, settings, options, null, null, boundingBox); }
[ "public", "TransportApiResult", "<", "List", "<", "Agency", ">", ">", "getAgenciesByBoundingBox", "(", "AgencyQueryOptions", "options", ",", "String", "boundingBox", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "AgencyQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "if", "(", "boundingBox", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"BoundingBox is required.\"", ")", ";", "}", "String", "[", "]", "bbox", "=", "boundingBox", ".", "split", "(", "\",\"", ",", "-", "1", ")", ";", "if", "(", "bbox", ".", "length", "!=", "4", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getAgencies", "(", "tokenComponent", ",", "settings", ",", "options", ",", "null", ",", "null", ",", "boundingBox", ")", ";", "}" ]
Gets a list of all agencies within a bounding box. @param options Options to limit the results by. Default: AgencyQueryOptions.defaultQueryOptions() @param boundingBox The bounding box from where to retrieve agencies. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box. @return A list of agencies within a bounding box.
[ "Gets", "a", "list", "of", "all", "agencies", "within", "a", "bounding", "box", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L131-L150
1,173
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getAgency
public TransportApiResult<Agency> getAgency(String agencyId) { if (Extensions.isNullOrWhiteSpace(agencyId)) { throw new IllegalArgumentException("AgencyId is required."); } return TransportApiClientCalls.getAgency(tokenComponent, settings, agencyId); }
java
public TransportApiResult<Agency> getAgency(String agencyId) { if (Extensions.isNullOrWhiteSpace(agencyId)) { throw new IllegalArgumentException("AgencyId is required."); } return TransportApiClientCalls.getAgency(tokenComponent, settings, agencyId); }
[ "public", "TransportApiResult", "<", "Agency", ">", "getAgency", "(", "String", "agencyId", ")", "{", "if", "(", "Extensions", ".", "isNullOrWhiteSpace", "(", "agencyId", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"AgencyId is required.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getAgency", "(", "tokenComponent", ",", "settings", ",", "agencyId", ")", ";", "}" ]
Gets a specific agency. @param agencyId The id of the agency you want to get. @return An agency.
[ "Gets", "a", "specific", "agency", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L158-L166
1,174
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getLines
public TransportApiResult<List<Line>> getLines(LineQueryOptions options) { if (options == null) { options = LineQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getLines(tokenComponent, settings, options, null, null, null); }
java
public TransportApiResult<List<Line>> getLines(LineQueryOptions options) { if (options == null) { options = LineQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getLines(tokenComponent, settings, options, null, null, null); }
[ "public", "TransportApiResult", "<", "List", "<", "Line", ">", ">", "getLines", "(", "LineQueryOptions", "options", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "LineQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getLines", "(", "tokenComponent", ",", "settings", ",", "options", ",", "null", ",", "null", ",", "null", ")", ";", "}" ]
Gets a list of all lines in the system. @param options Options to limit the results by. Default: LineQueryOptions.defaultQueryOptions() @return A list of all lines.
[ "Gets", "a", "list", "of", "all", "lines", "in", "the", "system", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L174-L182
1,175
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getLinesNearby
public TransportApiResult<List<Line>> getLinesNearby(LineQueryOptions options, double latitude, double longitude, int radiusInMeters) { if (options == null) { options = LineQueryOptions.defaultQueryOptions(); } if (radiusInMeters < 0) { throw new IllegalArgumentException("Invalid limit. Valid values are positive numbers only."); } return TransportApiClientCalls.getLines(tokenComponent, settings, options, new Point(longitude, latitude), radiusInMeters, null); }
java
public TransportApiResult<List<Line>> getLinesNearby(LineQueryOptions options, double latitude, double longitude, int radiusInMeters) { if (options == null) { options = LineQueryOptions.defaultQueryOptions(); } if (radiusInMeters < 0) { throw new IllegalArgumentException("Invalid limit. Valid values are positive numbers only."); } return TransportApiClientCalls.getLines(tokenComponent, settings, options, new Point(longitude, latitude), radiusInMeters, null); }
[ "public", "TransportApiResult", "<", "List", "<", "Line", ">", ">", "getLinesNearby", "(", "LineQueryOptions", "options", ",", "double", "latitude", ",", "double", "longitude", ",", "int", "radiusInMeters", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "LineQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "if", "(", "radiusInMeters", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid limit. Valid values are positive numbers only.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getLines", "(", "tokenComponent", ",", "settings", ",", "options", ",", "new", "Point", "(", "longitude", ",", "latitude", ")", ",", "radiusInMeters", ",", "null", ")", ";", "}" ]
Gets a list of lines nearby ordered by distance from the point specified. @param options Options to limit the results by. Default: LineQueryOptions.defaultQueryOptions() @param latitude Latitude in decimal degrees. @param longitude Longitude in decimal degrees. @param radiusInMeters Radius in meters to filter results by. @return A list of lines nearby the specified point.
[ "Gets", "a", "list", "of", "lines", "nearby", "ordered", "by", "distance", "from", "the", "point", "specified", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L193-L206
1,176
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getLinesByBoundingBox
public TransportApiResult<List<Line>> getLinesByBoundingBox(LineQueryOptions options, String boundingBox) { if (options == null) { options = LineQueryOptions.defaultQueryOptions(); } if (boundingBox == null) { throw new IllegalArgumentException("BoundingBox is required."); } String[] bbox = boundingBox.split(",", -1); if (bbox.length != 4) { throw new IllegalArgumentException("Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box."); } return TransportApiClientCalls.getLines(tokenComponent, settings, options, null, null, boundingBox); }
java
public TransportApiResult<List<Line>> getLinesByBoundingBox(LineQueryOptions options, String boundingBox) { if (options == null) { options = LineQueryOptions.defaultQueryOptions(); } if (boundingBox == null) { throw new IllegalArgumentException("BoundingBox is required."); } String[] bbox = boundingBox.split(",", -1); if (bbox.length != 4) { throw new IllegalArgumentException("Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box."); } return TransportApiClientCalls.getLines(tokenComponent, settings, options, null, null, boundingBox); }
[ "public", "TransportApiResult", "<", "List", "<", "Line", ">", ">", "getLinesByBoundingBox", "(", "LineQueryOptions", "options", ",", "String", "boundingBox", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "LineQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "if", "(", "boundingBox", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"BoundingBox is required.\"", ")", ";", "}", "String", "[", "]", "bbox", "=", "boundingBox", ".", "split", "(", "\",\"", ",", "-", "1", ")", ";", "if", "(", "bbox", ".", "length", "!=", "4", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getLines", "(", "tokenComponent", ",", "settings", ",", "options", ",", "null", ",", "null", ",", "boundingBox", ")", ";", "}" ]
Gets a list of all lines within a bounding box. @param options Options to limit the results by. Default: LineQueryOptions.defaultQueryOptions() @param boundingBox The bounding box from where to retrieve lines. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box. @return A list of lines within a bounding box.
[ "Gets", "a", "list", "of", "all", "lines", "within", "a", "bounding", "box", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L215-L234
1,177
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getLine
public TransportApiResult<Line> getLine(String lineId) { if (Extensions.isNullOrWhiteSpace(lineId)) { throw new IllegalArgumentException("LineId is required."); } return TransportApiClientCalls.getLine(tokenComponent, settings, lineId); }
java
public TransportApiResult<Line> getLine(String lineId) { if (Extensions.isNullOrWhiteSpace(lineId)) { throw new IllegalArgumentException("LineId is required."); } return TransportApiClientCalls.getLine(tokenComponent, settings, lineId); }
[ "public", "TransportApiResult", "<", "Line", ">", "getLine", "(", "String", "lineId", ")", "{", "if", "(", "Extensions", ".", "isNullOrWhiteSpace", "(", "lineId", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"LineId is required.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getLine", "(", "tokenComponent", ",", "settings", ",", "lineId", ")", ";", "}" ]
Gets a specific line. @param lineId The id of the line you want to get. @return A line.
[ "Gets", "a", "specific", "line", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L242-L251
1,178
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getLineTimetable
public TransportApiResult<List<LineTimetable>> getLineTimetable(String lineId, LineTimetableQueryOptions options) { if (Extensions.isNullOrWhiteSpace(lineId)) { throw new IllegalArgumentException("LineId is required."); } if (options == null) { options = LineTimetableQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getLineTimetable(tokenComponent, settings, lineId, options); }
java
public TransportApiResult<List<LineTimetable>> getLineTimetable(String lineId, LineTimetableQueryOptions options) { if (Extensions.isNullOrWhiteSpace(lineId)) { throw new IllegalArgumentException("LineId is required."); } if (options == null) { options = LineTimetableQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getLineTimetable(tokenComponent, settings, lineId, options); }
[ "public", "TransportApiResult", "<", "List", "<", "LineTimetable", ">", ">", "getLineTimetable", "(", "String", "lineId", ",", "LineTimetableQueryOptions", "options", ")", "{", "if", "(", "Extensions", ".", "isNullOrWhiteSpace", "(", "lineId", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"LineId is required.\"", ")", ";", "}", "if", "(", "options", "==", "null", ")", "{", "options", "=", "LineTimetableQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getLineTimetable", "(", "tokenComponent", ",", "settings", ",", "lineId", ",", "options", ")", ";", "}" ]
Gets a timetable for a specific line. @param lineId The id of the line you want to get a timetable for. @param options Options to limit the results by. Default: LineTimetableQueryOptions.defaultQueryOptions() @return The line timetable.
[ "Gets", "a", "timetable", "for", "a", "specific", "line", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L260-L273
1,179
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getStops
public TransportApiResult<List<Stop>> getStops(StopQueryOptions options) { if (options == null) { options = StopQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getStops(tokenComponent, settings, options, null, null, null); }
java
public TransportApiResult<List<Stop>> getStops(StopQueryOptions options) { if (options == null) { options = StopQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getStops(tokenComponent, settings, options, null, null, null); }
[ "public", "TransportApiResult", "<", "List", "<", "Stop", ">", ">", "getStops", "(", "StopQueryOptions", "options", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "StopQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getStops", "(", "tokenComponent", ",", "settings", ",", "options", ",", "null", ",", "null", ",", "null", ")", ";", "}" ]
Gets a list of all stops in the system. @param options Options to limit the results by. Default: StopQueryOptions.defaultQueryOptions() @return A list of all stops.
[ "Gets", "a", "list", "of", "all", "stops", "in", "the", "system", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L281-L289
1,180
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getStopsNearby
public TransportApiResult<List<Stop>> getStopsNearby(StopQueryOptions options, double latitude, double longitude, int radiusInMeters) { if (options == null) { options = StopQueryOptions.defaultQueryOptions(); } if (radiusInMeters < 0) { throw new IllegalArgumentException("Invalid limit. Valid values are positive numbers only."); } return TransportApiClientCalls.getStops(tokenComponent, settings, options, new Point(longitude, latitude), radiusInMeters, null); }
java
public TransportApiResult<List<Stop>> getStopsNearby(StopQueryOptions options, double latitude, double longitude, int radiusInMeters) { if (options == null) { options = StopQueryOptions.defaultQueryOptions(); } if (radiusInMeters < 0) { throw new IllegalArgumentException("Invalid limit. Valid values are positive numbers only."); } return TransportApiClientCalls.getStops(tokenComponent, settings, options, new Point(longitude, latitude), radiusInMeters, null); }
[ "public", "TransportApiResult", "<", "List", "<", "Stop", ">", ">", "getStopsNearby", "(", "StopQueryOptions", "options", ",", "double", "latitude", ",", "double", "longitude", ",", "int", "radiusInMeters", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "StopQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "if", "(", "radiusInMeters", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid limit. Valid values are positive numbers only.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getStops", "(", "tokenComponent", ",", "settings", ",", "options", ",", "new", "Point", "(", "longitude", ",", "latitude", ")", ",", "radiusInMeters", ",", "null", ")", ";", "}" ]
Gets a list of stops nearby ordered by distance from the point specified. @param options Options to limit the results by. Default: StopQueryOptions.defaultQueryOptions() @param latitude Latitude in decimal degrees. @param longitude Longitude in decimal degrees. @param radiusInMeters Radius in meters to filter results by. @return A list of stops nearby the specified point.
[ "Gets", "a", "list", "of", "stops", "nearby", "ordered", "by", "distance", "from", "the", "point", "specified", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L300-L313
1,181
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getStopsByBoundingBox
public TransportApiResult<List<Stop>> getStopsByBoundingBox(StopQueryOptions options, String boundingBox) { if (options == null) { options = StopQueryOptions.defaultQueryOptions(); } if (boundingBox == null) { throw new IllegalArgumentException("BoundingBox is required."); } String[] bbox = boundingBox.split(",", -1); if (bbox.length != 4) { throw new IllegalArgumentException("Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box."); } return TransportApiClientCalls.getStops(tokenComponent, settings, options, null, null, boundingBox); }
java
public TransportApiResult<List<Stop>> getStopsByBoundingBox(StopQueryOptions options, String boundingBox) { if (options == null) { options = StopQueryOptions.defaultQueryOptions(); } if (boundingBox == null) { throw new IllegalArgumentException("BoundingBox is required."); } String[] bbox = boundingBox.split(",", -1); if (bbox.length != 4) { throw new IllegalArgumentException("Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box."); } return TransportApiClientCalls.getStops(tokenComponent, settings, options, null, null, boundingBox); }
[ "public", "TransportApiResult", "<", "List", "<", "Stop", ">", ">", "getStopsByBoundingBox", "(", "StopQueryOptions", "options", ",", "String", "boundingBox", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "StopQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "if", "(", "boundingBox", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"BoundingBox is required.\"", ")", ";", "}", "String", "[", "]", "bbox", "=", "boundingBox", ".", "split", "(", "\",\"", ",", "-", "1", ")", ";", "if", "(", "bbox", ".", "length", "!=", "4", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid bounding box. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getStops", "(", "tokenComponent", ",", "settings", ",", "options", ",", "null", ",", "null", ",", "boundingBox", ")", ";", "}" ]
Gets a list of all stops within a bounding box. @param options Options to limit the results by. Default: StopQueryOptions.defaultQueryOptions() @param boundingBox The bounding box from where to retrieve stop. See valid examples here: http://developer.whereismytransport.com/documentation#bounding-box. @return A list of stop within a bounding box.
[ "Gets", "a", "list", "of", "all", "stops", "within", "a", "bounding", "box", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L322-L341
1,182
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getStop
public TransportApiResult<Stop> getStop(String stopId) { if (Extensions.isNullOrWhiteSpace(stopId)) { throw new IllegalArgumentException("StopId is required."); } return TransportApiClientCalls.getStop(tokenComponent, settings, stopId); }
java
public TransportApiResult<Stop> getStop(String stopId) { if (Extensions.isNullOrWhiteSpace(stopId)) { throw new IllegalArgumentException("StopId is required."); } return TransportApiClientCalls.getStop(tokenComponent, settings, stopId); }
[ "public", "TransportApiResult", "<", "Stop", ">", "getStop", "(", "String", "stopId", ")", "{", "if", "(", "Extensions", ".", "isNullOrWhiteSpace", "(", "stopId", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"StopId is required.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getStop", "(", "tokenComponent", ",", "settings", ",", "stopId", ")", ";", "}" ]
Gets a specific stop. @param stopId The id of the stop you want to get. @return An stop.
[ "Gets", "a", "specific", "stop", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L349-L357
1,183
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getStopTimetable
public TransportApiResult<List<StopTimetable>> getStopTimetable(String stopId, StopTimetableQueryOptions options) { if (Extensions.isNullOrWhiteSpace(stopId)) { throw new IllegalArgumentException("StopId is required."); } if (options == null) { options = StopTimetableQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getStopTimetable(tokenComponent, settings, stopId, options); }
java
public TransportApiResult<List<StopTimetable>> getStopTimetable(String stopId, StopTimetableQueryOptions options) { if (Extensions.isNullOrWhiteSpace(stopId)) { throw new IllegalArgumentException("StopId is required."); } if (options == null) { options = StopTimetableQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getStopTimetable(tokenComponent, settings, stopId, options); }
[ "public", "TransportApiResult", "<", "List", "<", "StopTimetable", ">", ">", "getStopTimetable", "(", "String", "stopId", ",", "StopTimetableQueryOptions", "options", ")", "{", "if", "(", "Extensions", ".", "isNullOrWhiteSpace", "(", "stopId", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"StopId is required.\"", ")", ";", "}", "if", "(", "options", "==", "null", ")", "{", "options", "=", "StopTimetableQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getStopTimetable", "(", "tokenComponent", ",", "settings", ",", "stopId", ",", "options", ")", ";", "}" ]
Gets a timetable for a specific stop. @param stopId The id of the stop you want to get a timetable for. @param options Options to limit the results by. Default: StopTimetableQueryOptions.defaultQueryOptions() @return The stop timetable.
[ "Gets", "a", "timetable", "for", "a", "specific", "stop", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L366-L379
1,184
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getFareProducts
public TransportApiResult<List<FareProduct>> getFareProducts(FareProductQueryOptions options) { if (options == null) { options = FareProductQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getFareProducts(tokenComponent, settings, options); }
java
public TransportApiResult<List<FareProduct>> getFareProducts(FareProductQueryOptions options) { if (options == null) { options = FareProductQueryOptions.defaultQueryOptions(); } return TransportApiClientCalls.getFareProducts(tokenComponent, settings, options); }
[ "public", "TransportApiResult", "<", "List", "<", "FareProduct", ">", ">", "getFareProducts", "(", "FareProductQueryOptions", "options", ")", "{", "if", "(", "options", "==", "null", ")", "{", "options", "=", "FareProductQueryOptions", ".", "defaultQueryOptions", "(", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getFareProducts", "(", "tokenComponent", ",", "settings", ",", "options", ")", ";", "}" ]
Gets a list of all fare products in the system. @param options Options to limit the results by. Default: FareProductQueryOptions.defaultQueryOptions() @return A list of all fare products.
[ "Gets", "a", "list", "of", "all", "fare", "products", "in", "the", "system", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L387-L395
1,185
WhereIsMyTransport/TransportApiSdk.Java
transportapisdk/src/main/java/transportapisdk/TransportApiClient.java
TransportApiClient.getFareProduct
public TransportApiResult<FareProduct> getFareProduct(String fareProductId) { if (Extensions.isNullOrWhiteSpace(fareProductId)) { throw new IllegalArgumentException("FareProductId is required."); } return TransportApiClientCalls.getFareProduct(tokenComponent, settings, fareProductId); }
java
public TransportApiResult<FareProduct> getFareProduct(String fareProductId) { if (Extensions.isNullOrWhiteSpace(fareProductId)) { throw new IllegalArgumentException("FareProductId is required."); } return TransportApiClientCalls.getFareProduct(tokenComponent, settings, fareProductId); }
[ "public", "TransportApiResult", "<", "FareProduct", ">", "getFareProduct", "(", "String", "fareProductId", ")", "{", "if", "(", "Extensions", ".", "isNullOrWhiteSpace", "(", "fareProductId", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"FareProductId is required.\"", ")", ";", "}", "return", "TransportApiClientCalls", ".", "getFareProduct", "(", "tokenComponent", ",", "settings", ",", "fareProductId", ")", ";", "}" ]
Gets a specific fare product. @param fareProductId The id of the fare product you want to get. @return An fare product.
[ "Gets", "a", "specific", "fare", "product", "." ]
f4ade7046c8dadfcb2976ee354f85f67a6e930a2
https://github.com/WhereIsMyTransport/TransportApiSdk.Java/blob/f4ade7046c8dadfcb2976ee354f85f67a6e930a2/transportapisdk/src/main/java/transportapisdk/TransportApiClient.java#L403-L411
1,186
aoindustries/semanticcms-news-rss
src/main/java/com/semanticcms/news/rss/RssServlet.java
RssServlet.getBookParam
private static String getBookParam(Map<String,String> bookParams, String paramName) { String value = bookParams.get(paramName); if(value != null && value.isEmpty()) value = null; return value; }
java
private static String getBookParam(Map<String,String> bookParams, String paramName) { String value = bookParams.get(paramName); if(value != null && value.isEmpty()) value = null; return value; }
[ "private", "static", "String", "getBookParam", "(", "Map", "<", "String", ",", "String", ">", "bookParams", ",", "String", "paramName", ")", "{", "String", "value", "=", "bookParams", ".", "get", "(", "paramName", ")", ";", "if", "(", "value", "!=", "null", "&&", "value", ".", "isEmpty", "(", ")", ")", "value", "=", "null", ";", "return", "value", ";", "}" ]
Gets a book parameter, null if empty.
[ "Gets", "a", "book", "parameter", "null", "if", "empty", "." ]
bffa0324ba8ccb3b4f478e9a279f2a10383649df
https://github.com/aoindustries/semanticcms-news-rss/blob/bffa0324ba8ccb3b4f478e9a279f2a10383649df/src/main/java/com/semanticcms/news/rss/RssServlet.java#L110-L114
1,187
aoindustries/semanticcms-news-rss
src/main/java/com/semanticcms/news/rss/RssServlet.java
RssServlet.findNewsView
private static View findNewsView(HtmlRenderer htmlRenderer) throws ServletException { // Find the news view, which this RSS extends and iteroperates with View view = htmlRenderer.getViewsByName().get(NewsView.VIEW_NAME); if(view == null) throw new ServletException("View not found: " + NewsView.VIEW_NAME); return view; }
java
private static View findNewsView(HtmlRenderer htmlRenderer) throws ServletException { // Find the news view, which this RSS extends and iteroperates with View view = htmlRenderer.getViewsByName().get(NewsView.VIEW_NAME); if(view == null) throw new ServletException("View not found: " + NewsView.VIEW_NAME); return view; }
[ "private", "static", "View", "findNewsView", "(", "HtmlRenderer", "htmlRenderer", ")", "throws", "ServletException", "{", "// Find the news view, which this RSS extends and iteroperates with", "View", "view", "=", "htmlRenderer", ".", "getViewsByName", "(", ")", ".", "get", "(", "NewsView", ".", "VIEW_NAME", ")", ";", "if", "(", "view", "==", "null", ")", "throw", "new", "ServletException", "(", "\"View not found: \"", "+", "NewsView", ".", "VIEW_NAME", ")", ";", "return", "view", ";", "}" ]
Finds the news view. @throws ServletException when cannot find the news view
[ "Finds", "the", "news", "view", "." ]
bffa0324ba8ccb3b4f478e9a279f2a10383649df
https://github.com/aoindustries/semanticcms-news-rss/blob/bffa0324ba8ccb3b4f478e9a279f2a10383649df/src/main/java/com/semanticcms/news/rss/RssServlet.java#L223-L228
1,188
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java
POIProxy.getAvailableServices
public String getAvailableServices() throws JsonGenerationException, JsonMappingException, IOException { DescribeServices services = serviceManager.getAvailableServices(); return services.asJSON(); }
java
public String getAvailableServices() throws JsonGenerationException, JsonMappingException, IOException { DescribeServices services = serviceManager.getAvailableServices(); return services.asJSON(); }
[ "public", "String", "getAvailableServices", "(", ")", "throws", "JsonGenerationException", ",", "JsonMappingException", ",", "IOException", "{", "DescribeServices", "services", "=", "serviceManager", ".", "getAvailableServices", "(", ")", ";", "return", "services", ".", "asJSON", "(", ")", ";", "}" ]
Returns a JSON containing the describe service document of each service registered into the library @return @throws IOException @throws JsonMappingException @throws JsonGenerationException
[ "Returns", "a", "JSON", "containing", "the", "describe", "service", "document", "of", "each", "service", "registered", "into", "the", "library" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java#L171-L175
1,189
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java
POIProxy.getPOIs
public String getPOIs(String id, double lon, double lat, double distanceInMeters, List<Param> optionalParams) throws Exception { DescribeService describeService = getDescribeServiceByID(id); double[] bbox = Calculator.boundingCoordinates(lon, lat, distanceInMeters); POIProxyEvent beforeEvent = new POIProxyEvent(POIProxyEventEnum.BeforeBrowseLonLat, describeService, new Extent(bbox[0], bbox[1], bbox[2], bbox[3]), null, null, null, lon, lat, distanceInMeters, null, null, null); notifyListenersBeforeRequest(beforeEvent); String geoJSON = getCacheData(beforeEvent); boolean fromCache = true; if (geoJSON == null) { fromCache = false; geoJSON = getResponseAsGeoJSON(id, optionalParams, describeService, bbox[0], bbox[1], bbox[2], bbox[3], lon, lat, beforeEvent); } POIProxyEvent afterEvent = new POIProxyEvent(POIProxyEventEnum.AfterBrowseLonLat, describeService, new Extent(bbox[0], bbox[1], bbox[2], bbox[3]), null, null, null, lon, lat, distanceInMeters, null, geoJSON, null); if (!fromCache) { storeData(afterEvent); } notifyListenersBeforeRequest(afterEvent); return geoJSON; }
java
public String getPOIs(String id, double lon, double lat, double distanceInMeters, List<Param> optionalParams) throws Exception { DescribeService describeService = getDescribeServiceByID(id); double[] bbox = Calculator.boundingCoordinates(lon, lat, distanceInMeters); POIProxyEvent beforeEvent = new POIProxyEvent(POIProxyEventEnum.BeforeBrowseLonLat, describeService, new Extent(bbox[0], bbox[1], bbox[2], bbox[3]), null, null, null, lon, lat, distanceInMeters, null, null, null); notifyListenersBeforeRequest(beforeEvent); String geoJSON = getCacheData(beforeEvent); boolean fromCache = true; if (geoJSON == null) { fromCache = false; geoJSON = getResponseAsGeoJSON(id, optionalParams, describeService, bbox[0], bbox[1], bbox[2], bbox[3], lon, lat, beforeEvent); } POIProxyEvent afterEvent = new POIProxyEvent(POIProxyEventEnum.AfterBrowseLonLat, describeService, new Extent(bbox[0], bbox[1], bbox[2], bbox[3]), null, null, null, lon, lat, distanceInMeters, null, geoJSON, null); if (!fromCache) { storeData(afterEvent); } notifyListenersBeforeRequest(afterEvent); return geoJSON; }
[ "public", "String", "getPOIs", "(", "String", "id", ",", "double", "lon", ",", "double", "lat", ",", "double", "distanceInMeters", ",", "List", "<", "Param", ">", "optionalParams", ")", "throws", "Exception", "{", "DescribeService", "describeService", "=", "getDescribeServiceByID", "(", "id", ")", ";", "double", "[", "]", "bbox", "=", "Calculator", ".", "boundingCoordinates", "(", "lon", ",", "lat", ",", "distanceInMeters", ")", ";", "POIProxyEvent", "beforeEvent", "=", "new", "POIProxyEvent", "(", "POIProxyEventEnum", ".", "BeforeBrowseLonLat", ",", "describeService", ",", "new", "Extent", "(", "bbox", "[", "0", "]", ",", "bbox", "[", "1", "]", ",", "bbox", "[", "2", "]", ",", "bbox", "[", "3", "]", ")", ",", "null", ",", "null", ",", "null", ",", "lon", ",", "lat", ",", "distanceInMeters", ",", "null", ",", "null", ",", "null", ")", ";", "notifyListenersBeforeRequest", "(", "beforeEvent", ")", ";", "String", "geoJSON", "=", "getCacheData", "(", "beforeEvent", ")", ";", "boolean", "fromCache", "=", "true", ";", "if", "(", "geoJSON", "==", "null", ")", "{", "fromCache", "=", "false", ";", "geoJSON", "=", "getResponseAsGeoJSON", "(", "id", ",", "optionalParams", ",", "describeService", ",", "bbox", "[", "0", "]", ",", "bbox", "[", "1", "]", ",", "bbox", "[", "2", "]", ",", "bbox", "[", "3", "]", ",", "lon", ",", "lat", ",", "beforeEvent", ")", ";", "}", "POIProxyEvent", "afterEvent", "=", "new", "POIProxyEvent", "(", "POIProxyEventEnum", ".", "AfterBrowseLonLat", ",", "describeService", ",", "new", "Extent", "(", "bbox", "[", "0", "]", ",", "bbox", "[", "1", "]", ",", "bbox", "[", "2", "]", ",", "bbox", "[", "3", "]", ")", ",", "null", ",", "null", ",", "null", ",", "lon", ",", "lat", ",", "distanceInMeters", ",", "null", ",", "geoJSON", ",", "null", ")", ";", "if", "(", "!", "fromCache", ")", "{", "storeData", "(", "afterEvent", ")", ";", "}", "notifyListenersBeforeRequest", "(", "afterEvent", ")", ";", "return", "geoJSON", ";", "}" ]
This method is used to get the pois from a service and return a GeoJSON document with the data retrieved given a longitude, latitude and a radius in meters. @param id The id of the service @param lon The longitude @param lat The latitude @param distanceInMeters The distance in meters from the lon, lat @return The GeoJSON response from the original service response
[ "This", "method", "is", "used", "to", "get", "the", "pois", "from", "a", "service", "and", "return", "a", "GeoJSON", "document", "with", "the", "data", "retrieved", "given", "a", "longitude", "latitude", "and", "a", "radius", "in", "meters", "." ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java#L326-L358
1,190
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java
POIProxy.getPOIs
public String getPOIs(String id, double minX, double minY, double maxX, double maxY, List<Param> optionalParams) throws Exception { DescribeService describeService = getDescribeServiceByID(id); POIProxyEvent beforeEvent = new POIProxyEvent(POIProxyEventEnum.BeforeBrowseExtent, describeService, new Extent(minX, minY, maxX, maxY), null, null, null, null, null, null, null, null, null); notifyListenersBeforeRequest(beforeEvent); String geoJSON = this.getCacheData(beforeEvent); boolean fromCache = true; if (geoJSON == null) { fromCache = false; geoJSON = getResponseAsGeoJSON(id, optionalParams, describeService, minX, minY, maxX, maxY, 0, 0, beforeEvent); } POIProxyEvent afterEvent = new POIProxyEvent(POIProxyEventEnum.AfterBrowseExtent, describeService, new Extent(minX, minY, maxX, maxY), null, null, null, null, null, null, null, geoJSON, null); if (!fromCache) { storeData(afterEvent); } notifyListenersAfterParse(afterEvent); return geoJSON; }
java
public String getPOIs(String id, double minX, double minY, double maxX, double maxY, List<Param> optionalParams) throws Exception { DescribeService describeService = getDescribeServiceByID(id); POIProxyEvent beforeEvent = new POIProxyEvent(POIProxyEventEnum.BeforeBrowseExtent, describeService, new Extent(minX, minY, maxX, maxY), null, null, null, null, null, null, null, null, null); notifyListenersBeforeRequest(beforeEvent); String geoJSON = this.getCacheData(beforeEvent); boolean fromCache = true; if (geoJSON == null) { fromCache = false; geoJSON = getResponseAsGeoJSON(id, optionalParams, describeService, minX, minY, maxX, maxY, 0, 0, beforeEvent); } POIProxyEvent afterEvent = new POIProxyEvent(POIProxyEventEnum.AfterBrowseExtent, describeService, new Extent(minX, minY, maxX, maxY), null, null, null, null, null, null, null, geoJSON, null); if (!fromCache) { storeData(afterEvent); } notifyListenersAfterParse(afterEvent); return geoJSON; }
[ "public", "String", "getPOIs", "(", "String", "id", ",", "double", "minX", ",", "double", "minY", ",", "double", "maxX", ",", "double", "maxY", ",", "List", "<", "Param", ">", "optionalParams", ")", "throws", "Exception", "{", "DescribeService", "describeService", "=", "getDescribeServiceByID", "(", "id", ")", ";", "POIProxyEvent", "beforeEvent", "=", "new", "POIProxyEvent", "(", "POIProxyEventEnum", ".", "BeforeBrowseExtent", ",", "describeService", ",", "new", "Extent", "(", "minX", ",", "minY", ",", "maxX", ",", "maxY", ")", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "notifyListenersBeforeRequest", "(", "beforeEvent", ")", ";", "String", "geoJSON", "=", "this", ".", "getCacheData", "(", "beforeEvent", ")", ";", "boolean", "fromCache", "=", "true", ";", "if", "(", "geoJSON", "==", "null", ")", "{", "fromCache", "=", "false", ";", "geoJSON", "=", "getResponseAsGeoJSON", "(", "id", ",", "optionalParams", ",", "describeService", ",", "minX", ",", "minY", ",", "maxX", ",", "maxY", ",", "0", ",", "0", ",", "beforeEvent", ")", ";", "}", "POIProxyEvent", "afterEvent", "=", "new", "POIProxyEvent", "(", "POIProxyEventEnum", ".", "AfterBrowseExtent", ",", "describeService", ",", "new", "Extent", "(", "minX", ",", "minY", ",", "maxX", ",", "maxY", ")", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "null", ",", "geoJSON", ",", "null", ")", ";", "if", "(", "!", "fromCache", ")", "{", "storeData", "(", "afterEvent", ")", ";", "}", "notifyListenersAfterParse", "(", "afterEvent", ")", ";", "return", "geoJSON", ";", "}" ]
This method is used to get the pois from a service and return a GeoJSON document with the data retrieved given a bounding box corners @param id The id of the service @param minX @param minY @param maxX @param maxY @return The GeoJSON response from the original service response
[ "This", "method", "is", "used", "to", "get", "the", "pois", "from", "a", "service", "and", "return", "a", "GeoJSON", "document", "with", "the", "data", "retrieved", "given", "a", "bounding", "box", "corners" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java#L430-L458
1,191
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java
POIProxy.getDistanceMeters
public int getDistanceMeters(Extent boundingBox) { return new Double(Math.floor(Calculator.latLonDist(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMaxX(), boundingBox.getMaxY()))).intValue(); }
java
public int getDistanceMeters(Extent boundingBox) { return new Double(Math.floor(Calculator.latLonDist(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMaxX(), boundingBox.getMaxY()))).intValue(); }
[ "public", "int", "getDistanceMeters", "(", "Extent", "boundingBox", ")", "{", "return", "new", "Double", "(", "Math", ".", "floor", "(", "Calculator", ".", "latLonDist", "(", "boundingBox", ".", "getMinX", "(", ")", ",", "boundingBox", ".", "getMinY", "(", ")", ",", "boundingBox", ".", "getMaxX", "(", ")", ",", "boundingBox", ".", "getMaxY", "(", ")", ")", ")", ")", ".", "intValue", "(", ")", ";", "}" ]
Utility method to get the distance from the bottom left corner of the bounding box to the upper right corner @param boundingBox The bounding box @return The distance in meters
[ "Utility", "method", "to", "get", "the", "distance", "from", "the", "bottom", "left", "corner", "of", "the", "bounding", "box", "to", "the", "upper", "right", "corner" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java#L732-L735
1,192
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java
POIProxy.getErrorForUnknownService
private String getErrorForUnknownService(String id) { StringBuffer error = new StringBuffer(); error.append("Services path: " + ServiceConfigurationManager.CONFIGURATION_DIR); error.append("The service with id: " + id + " is not registered"); error.append("\n Available services are: "); Set<String> keys = serviceManager.getRegisteredConfigurations().keySet(); Iterator<String> it = keys.iterator(); while (it.hasNext()) { error.append(it.next()).append(" "); } return error.toString(); }
java
private String getErrorForUnknownService(String id) { StringBuffer error = new StringBuffer(); error.append("Services path: " + ServiceConfigurationManager.CONFIGURATION_DIR); error.append("The service with id: " + id + " is not registered"); error.append("\n Available services are: "); Set<String> keys = serviceManager.getRegisteredConfigurations().keySet(); Iterator<String> it = keys.iterator(); while (it.hasNext()) { error.append(it.next()).append(" "); } return error.toString(); }
[ "private", "String", "getErrorForUnknownService", "(", "String", "id", ")", "{", "StringBuffer", "error", "=", "new", "StringBuffer", "(", ")", ";", "error", ".", "append", "(", "\"Services path: \"", "+", "ServiceConfigurationManager", ".", "CONFIGURATION_DIR", ")", ";", "error", ".", "append", "(", "\"The service with id: \"", "+", "id", "+", "\" is not registered\"", ")", ";", "error", ".", "append", "(", "\"\\n Available services are: \"", ")", ";", "Set", "<", "String", ">", "keys", "=", "serviceManager", ".", "getRegisteredConfigurations", "(", ")", ".", "keySet", "(", ")", ";", "Iterator", "<", "String", ">", "it", "=", "keys", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "error", ".", "append", "(", "it", ".", "next", "(", ")", ")", ".", "append", "(", "\" \"", ")", ";", "}", "return", "error", ".", "toString", "(", ")", ";", "}" ]
Exception text when a service requested is not registered into the library @param id The id of the service not found @return The Exception text to show to the user
[ "Exception", "text", "when", "a", "service", "requested", "is", "not", "registered", "into", "the", "library" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java#L776-L792
1,193
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java
POIProxy.register
public void register(DescribeService service, String describeService) throws POIProxyException { serviceManager.registerServiceConfiguration(service.getId(), describeService, service); }
java
public void register(DescribeService service, String describeService) throws POIProxyException { serviceManager.registerServiceConfiguration(service.getId(), describeService, service); }
[ "public", "void", "register", "(", "DescribeService", "service", ",", "String", "describeService", ")", "throws", "POIProxyException", "{", "serviceManager", ".", "registerServiceConfiguration", "(", "service", ".", "getId", "(", ")", ",", "describeService", ",", "service", ")", ";", "}" ]
Interface for registering a new service in POIProxy @param service The {@link DescribeService} @param describeService The JSON representation of the DescribeService for hot registering @throws POIProxyException
[ "Interface", "for", "registering", "a", "new", "service", "in", "POIProxy" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/poiproxy/proxy/POIProxy.java#L829-L831
1,194
alrocar/POIProxy
es.alrocar.map.vector/src/main/java/es/alrocar/map/vector/provider/filesystem/impl/GeoJSONParser.java
GeoJSONParser.parseFeature
public JTSFeature parseFeature(JSONObject feature) throws JSONException { JTSFeature feat = new JTSFeature(null); JSONObject geometry = (JSONObject) feature.get("geometry"); String geomType = geometry.get("type").toString(); if (geomType.compareTo("Point") == 0) { JSONArray coords = geometry.getJSONArray("coordinates"); double x = coords.getDouble(0); double y = coords.getDouble(1); GeometryFactory factory = new GeometryFactory(); Coordinate c = new Coordinate(); c.x = x; c.y = y; Point p = factory.createPoint(c); feat.setGeometry(new JTSGeometry(p)); } // TODO process other geometry types JSONObject props = feature.getJSONObject("properties"); Iterator it = props.keys(); String key; String val; feat.setText(""); while (it.hasNext()) { key = it.next().toString(); val = props.getString(key); feat.addField(key, val, 0); if (val.indexOf("http") == -1) { feat.setText(feat.getText() + " " + val); } } return feat; }
java
public JTSFeature parseFeature(JSONObject feature) throws JSONException { JTSFeature feat = new JTSFeature(null); JSONObject geometry = (JSONObject) feature.get("geometry"); String geomType = geometry.get("type").toString(); if (geomType.compareTo("Point") == 0) { JSONArray coords = geometry.getJSONArray("coordinates"); double x = coords.getDouble(0); double y = coords.getDouble(1); GeometryFactory factory = new GeometryFactory(); Coordinate c = new Coordinate(); c.x = x; c.y = y; Point p = factory.createPoint(c); feat.setGeometry(new JTSGeometry(p)); } // TODO process other geometry types JSONObject props = feature.getJSONObject("properties"); Iterator it = props.keys(); String key; String val; feat.setText(""); while (it.hasNext()) { key = it.next().toString(); val = props.getString(key); feat.addField(key, val, 0); if (val.indexOf("http") == -1) { feat.setText(feat.getText() + " " + val); } } return feat; }
[ "public", "JTSFeature", "parseFeature", "(", "JSONObject", "feature", ")", "throws", "JSONException", "{", "JTSFeature", "feat", "=", "new", "JTSFeature", "(", "null", ")", ";", "JSONObject", "geometry", "=", "(", "JSONObject", ")", "feature", ".", "get", "(", "\"geometry\"", ")", ";", "String", "geomType", "=", "geometry", ".", "get", "(", "\"type\"", ")", ".", "toString", "(", ")", ";", "if", "(", "geomType", ".", "compareTo", "(", "\"Point\"", ")", "==", "0", ")", "{", "JSONArray", "coords", "=", "geometry", ".", "getJSONArray", "(", "\"coordinates\"", ")", ";", "double", "x", "=", "coords", ".", "getDouble", "(", "0", ")", ";", "double", "y", "=", "coords", ".", "getDouble", "(", "1", ")", ";", "GeometryFactory", "factory", "=", "new", "GeometryFactory", "(", ")", ";", "Coordinate", "c", "=", "new", "Coordinate", "(", ")", ";", "c", ".", "x", "=", "x", ";", "c", ".", "y", "=", "y", ";", "Point", "p", "=", "factory", ".", "createPoint", "(", "c", ")", ";", "feat", ".", "setGeometry", "(", "new", "JTSGeometry", "(", "p", ")", ")", ";", "}", "// TODO process other geometry types", "JSONObject", "props", "=", "feature", ".", "getJSONObject", "(", "\"properties\"", ")", ";", "Iterator", "it", "=", "props", ".", "keys", "(", ")", ";", "String", "key", ";", "String", "val", ";", "feat", ".", "setText", "(", "\"\"", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "key", "=", "it", ".", "next", "(", ")", ".", "toString", "(", ")", ";", "val", "=", "props", ".", "getString", "(", "key", ")", ";", "feat", ".", "addField", "(", "key", ",", "val", ",", "0", ")", ";", "if", "(", "val", ".", "indexOf", "(", "\"http\"", ")", "==", "-", "1", ")", "{", "feat", ".", "setText", "(", "feat", ".", "getText", "(", ")", "+", "\" \"", "+", "val", ")", ";", "}", "}", "return", "feat", ";", "}" ]
Parses a single feature with a Point @param feature The feature {@link JSONObject} @return A {@link JTSFeature} @throws JSONException
[ "Parses", "a", "single", "feature", "with", "a", "Point" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.map.vector/src/main/java/es/alrocar/map/vector/provider/filesystem/impl/GeoJSONParser.java#L97-L133
1,195
alrocar/POIProxy
es.alrocar.map.vector/src/main/java/es/alrocar/map/vector/provider/LRUVectorTileCache.java
LRUVectorTileCache.put
public synchronized Object put(final String key, final Object value) { try { if (maxCacheSize == 0) { return null; } // if the key isn't in the cache and the cache is full... if (!super.containsKey(key) && !list.isEmpty() && list.size() + 1 > maxCacheSize) { final Object deadKey = list.removeLast(); super.remove(deadKey); } updateKey(key); } catch (Exception e) { log.log(Level.SEVERE, "put", e); } return super.put(key, value); }
java
public synchronized Object put(final String key, final Object value) { try { if (maxCacheSize == 0) { return null; } // if the key isn't in the cache and the cache is full... if (!super.containsKey(key) && !list.isEmpty() && list.size() + 1 > maxCacheSize) { final Object deadKey = list.removeLast(); super.remove(deadKey); } updateKey(key); } catch (Exception e) { log.log(Level.SEVERE, "put", e); } return super.put(key, value); }
[ "public", "synchronized", "Object", "put", "(", "final", "String", "key", ",", "final", "Object", "value", ")", "{", "try", "{", "if", "(", "maxCacheSize", "==", "0", ")", "{", "return", "null", ";", "}", "// if the key isn't in the cache and the cache is full...", "if", "(", "!", "super", ".", "containsKey", "(", "key", ")", "&&", "!", "list", ".", "isEmpty", "(", ")", "&&", "list", ".", "size", "(", ")", "+", "1", ">", "maxCacheSize", ")", "{", "final", "Object", "deadKey", "=", "list", ".", "removeLast", "(", ")", ";", "super", ".", "remove", "(", "deadKey", ")", ";", "}", "updateKey", "(", "key", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"put\"", ",", "e", ")", ";", "}", "return", "super", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
Adds an Object to the cache. If the cache is full, removes the last
[ "Adds", "an", "Object", "to", "the", "cache", ".", "If", "the", "cache", "is", "full", "removes", "the", "last" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.map.vector/src/main/java/es/alrocar/map/vector/provider/LRUVectorTileCache.java#L82-L100
1,196
alrocar/POIProxy
es.alrocar.map.vector/src/main/java/es/alrocar/map/vector/provider/LRUVectorTileCache.java
LRUVectorTileCache.get
public synchronized Object get(final String key) { try { final Object value = super.get(key); if (value != null) { updateKey(key); } return value; } catch (Exception e) { log.log(Level.SEVERE, "get", e); return null; } }
java
public synchronized Object get(final String key) { try { final Object value = super.get(key); if (value != null) { updateKey(key); } return value; } catch (Exception e) { log.log(Level.SEVERE, "get", e); return null; } }
[ "public", "synchronized", "Object", "get", "(", "final", "String", "key", ")", "{", "try", "{", "final", "Object", "value", "=", "super", ".", "get", "(", "key", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "updateKey", "(", "key", ")", ";", "}", "return", "value", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"get\"", ",", "e", ")", ";", "return", "null", ";", "}", "}" ]
Returns a cached Object given a key @param key The key of the Object stored on the HashMap @return The Object or null if it is not stored in the cache
[ "Returns", "a", "cached", "Object", "given", "a", "key" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.map.vector/src/main/java/es/alrocar/map/vector/provider/LRUVectorTileCache.java#L109-L120
1,197
alrocar/POIProxy
es.alrocar.map.vector/src/main/java/es/alrocar/map/vector/provider/LRUVectorTileCache.java
LRUVectorTileCache.remove
public synchronized void remove(final String key) { try { list.remove(key); } catch (Exception e) { log.log(Level.SEVERE, "remove", e); } super.remove(key); }
java
public synchronized void remove(final String key) { try { list.remove(key); } catch (Exception e) { log.log(Level.SEVERE, "remove", e); } super.remove(key); }
[ "public", "synchronized", "void", "remove", "(", "final", "String", "key", ")", "{", "try", "{", "list", ".", "remove", "(", "key", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"remove\"", ",", "e", ")", ";", "}", "super", ".", "remove", "(", "key", ")", ";", "}" ]
Removes a Object from the cache @param key The key of the Bitmap to remove
[ "Removes", "a", "Object", "from", "the", "cache" ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.map.vector/src/main/java/es/alrocar/map/vector/provider/LRUVectorTileCache.java#L128-L135
1,198
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java
CsvReader.setEscapeMode
public void setEscapeMode(int escapeMode) throws IllegalArgumentException { if (escapeMode != ESCAPE_MODE_DOUBLED && escapeMode != ESCAPE_MODE_BACKSLASH) { throw new IllegalArgumentException( "Parameter escapeMode must be a valid value."); } userSettings.EscapeMode = escapeMode; }
java
public void setEscapeMode(int escapeMode) throws IllegalArgumentException { if (escapeMode != ESCAPE_MODE_DOUBLED && escapeMode != ESCAPE_MODE_BACKSLASH) { throw new IllegalArgumentException( "Parameter escapeMode must be a valid value."); } userSettings.EscapeMode = escapeMode; }
[ "public", "void", "setEscapeMode", "(", "int", "escapeMode", ")", "throws", "IllegalArgumentException", "{", "if", "(", "escapeMode", "!=", "ESCAPE_MODE_DOUBLED", "&&", "escapeMode", "!=", "ESCAPE_MODE_BACKSLASH", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Parameter escapeMode must be a valid value.\"", ")", ";", "}", "userSettings", ".", "EscapeMode", "=", "escapeMode", ";", "}" ]
Sets the current way to escape an occurance of the text qualifier inside qualified data. @param escapeMode The way to escape an occurance of the text qualifier inside qualified data. @exception IllegalArgumentException When an illegal value is specified for escapeMode.
[ "Sets", "the", "current", "way", "to", "escape", "an", "occurance", "of", "the", "text", "qualifier", "inside", "qualified", "data", "." ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java#L401-L409
1,199
alrocar/POIProxy
es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java
CsvReader.getHeaders
public String[] getHeaders() throws IOException { checkClosed(); if (headersHolder.Headers == null) { return null; } else { // use clone here to prevent the outside code from // setting values on the array directly, which would // throw off the index lookup based on header name String[] clone = new String[headersHolder.Length]; System.arraycopy(headersHolder.Headers, 0, clone, 0, headersHolder.Length); return clone; } }
java
public String[] getHeaders() throws IOException { checkClosed(); if (headersHolder.Headers == null) { return null; } else { // use clone here to prevent the outside code from // setting values on the array directly, which would // throw off the index lookup based on header name String[] clone = new String[headersHolder.Length]; System.arraycopy(headersHolder.Headers, 0, clone, 0, headersHolder.Length); return clone; } }
[ "public", "String", "[", "]", "getHeaders", "(", ")", "throws", "IOException", "{", "checkClosed", "(", ")", ";", "if", "(", "headersHolder", ".", "Headers", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "// use clone here to prevent the outside code from", "// setting values on the array directly, which would", "// throw off the index lookup based on header name", "String", "[", "]", "clone", "=", "new", "String", "[", "headersHolder", ".", "Length", "]", ";", "System", ".", "arraycopy", "(", "headersHolder", ".", "Headers", ",", "0", ",", "clone", ",", "0", ",", "headersHolder", ".", "Length", ")", ";", "return", "clone", ";", "}", "}" ]
Returns the header values as a string array. @return The header values as a String array. @exception IOException Thrown if this object has already been closed.
[ "Returns", "the", "header", "values", "as", "a", "string", "array", "." ]
e1dabe738a862478b2580e90d5fc4209a2997868
https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java#L483-L497