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
200
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teatools/TeaToolsUtils.java
TeaToolsUtils.addMissingContextMethodDescriptors
protected MethodDescriptor[] addMissingContextMethodDescriptors( Method[] methods, MethodDescriptor[] methodDescriptors) { List<Method> methodNames = new ArrayList<Method>(methodDescriptors.length); Vector<MethodDescriptor> mds = new Vector<MethodDescriptor>(methods.length); for (int i=0; i<methodDescriptors.length; i++) { methodNames.add(methodDescriptors[i].getMethod()); mds.add(methodDescriptors[i]); } for (int i=0; i<methods.length; i++) { if (!methodNames.contains(methods[i])) { mds.add(new MethodDescriptor(methods[i])); } } methodDescriptors = new MethodDescriptor[mds.size()]; mds.copyInto(methodDescriptors); return methodDescriptors; }
java
protected MethodDescriptor[] addMissingContextMethodDescriptors( Method[] methods, MethodDescriptor[] methodDescriptors) { List<Method> methodNames = new ArrayList<Method>(methodDescriptors.length); Vector<MethodDescriptor> mds = new Vector<MethodDescriptor>(methods.length); for (int i=0; i<methodDescriptors.length; i++) { methodNames.add(methodDescriptors[i].getMethod()); mds.add(methodDescriptors[i]); } for (int i=0; i<methods.length; i++) { if (!methodNames.contains(methods[i])) { mds.add(new MethodDescriptor(methods[i])); } } methodDescriptors = new MethodDescriptor[mds.size()]; mds.copyInto(methodDescriptors); return methodDescriptors; }
[ "protected", "MethodDescriptor", "[", "]", "addMissingContextMethodDescriptors", "(", "Method", "[", "]", "methods", ",", "MethodDescriptor", "[", "]", "methodDescriptors", ")", "{", "List", "<", "Method", ">", "methodNames", "=", "new", "ArrayList", "<", "Method", ">", "(", "methodDescriptors", ".", "length", ")", ";", "Vector", "<", "MethodDescriptor", ">", "mds", "=", "new", "Vector", "<", "MethodDescriptor", ">", "(", "methods", ".", "length", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "methodDescriptors", ".", "length", ";", "i", "++", ")", "{", "methodNames", ".", "add", "(", "methodDescriptors", "[", "i", "]", ".", "getMethod", "(", ")", ")", ";", "mds", ".", "add", "(", "methodDescriptors", "[", "i", "]", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "methods", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "methodNames", ".", "contains", "(", "methods", "[", "i", "]", ")", ")", "{", "mds", ".", "add", "(", "new", "MethodDescriptor", "(", "methods", "[", "i", "]", ")", ")", ";", "}", "}", "methodDescriptors", "=", "new", "MethodDescriptor", "[", "mds", ".", "size", "(", ")", "]", ";", "mds", ".", "copyInto", "(", "methodDescriptors", ")", ";", "return", "methodDescriptors", ";", "}" ]
Works around a bug in java.beans.Introspector, where sub-interfaces do not return their parent's methods, in the method descriptor array.
[ "Works", "around", "a", "bug", "in", "java", ".", "beans", ".", "Introspector", "where", "sub", "-", "interfaces", "do", "not", "return", "their", "parent", "s", "methods", "in", "the", "method", "descriptor", "array", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/TeaToolsUtils.java#L1230-L1251
201
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teatools/PropertyDescription.java
PropertyDescription.getType
public TypeDescription getType() { if (mType == null) { mType = getTeaToolsUtils().createTypeDescription( getPropertyDescriptor().getPropertyType()); } return mType; }
java
public TypeDescription getType() { if (mType == null) { mType = getTeaToolsUtils().createTypeDescription( getPropertyDescriptor().getPropertyType()); } return mType; }
[ "public", "TypeDescription", "getType", "(", ")", "{", "if", "(", "mType", "==", "null", ")", "{", "mType", "=", "getTeaToolsUtils", "(", ")", ".", "createTypeDescription", "(", "getPropertyDescriptor", "(", ")", ".", "getPropertyType", "(", ")", ")", ";", "}", "return", "mType", ";", "}" ]
Returns the property's type
[ "Returns", "the", "property", "s", "type" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/PropertyDescription.java#L46-L53
202
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teatools/PropertyDescription.java
PropertyDescription.isDeprecated
public boolean isDeprecated() { Method method = getPropertyDescriptor().getReadMethod(); return (method == null ? false : getTeaToolsUtils().isDeprecated(method)); }
java
public boolean isDeprecated() { Method method = getPropertyDescriptor().getReadMethod(); return (method == null ? false : getTeaToolsUtils().isDeprecated(method)); }
[ "public", "boolean", "isDeprecated", "(", ")", "{", "Method", "method", "=", "getPropertyDescriptor", "(", ")", ".", "getReadMethod", "(", ")", ";", "return", "(", "method", "==", "null", "?", "false", ":", "getTeaToolsUtils", "(", ")", ".", "isDeprecated", "(", "method", ")", ")", ";", "}" ]
Returns whether the given property is deprecated based on whether any of its read methods are deprecated. @return <code>true</code> if the property is deprecated @see Deprecated
[ "Returns", "whether", "the", "given", "property", "is", "deprecated", "based", "on", "whether", "any", "of", "its", "read", "methods", "are", "deprecated", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/PropertyDescription.java#L70-L73
203
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/DelegatingClassInjector.java
DelegatingClassInjector.getInstance
public static ClassInjector getInstance(ClassLoader loader) { ClassInjector injector = null; synchronized (cShared) { Reference ref = (Reference)cShared.get(loader); if (ref != null) { injector = (ClassInjector)ref.get(); } if (injector == null) { injector = new ClassInjector(loader); cShared.put(loader, new WeakReference(injector)); } return injector; } }
java
public static ClassInjector getInstance(ClassLoader loader) { ClassInjector injector = null; synchronized (cShared) { Reference ref = (Reference)cShared.get(loader); if (ref != null) { injector = (ClassInjector)ref.get(); } if (injector == null) { injector = new ClassInjector(loader); cShared.put(loader, new WeakReference(injector)); } return injector; } }
[ "public", "static", "ClassInjector", "getInstance", "(", "ClassLoader", "loader", ")", "{", "ClassInjector", "injector", "=", "null", ";", "synchronized", "(", "cShared", ")", "{", "Reference", "ref", "=", "(", "Reference", ")", "cShared", ".", "get", "(", "loader", ")", ";", "if", "(", "ref", "!=", "null", ")", "{", "injector", "=", "(", "ClassInjector", ")", "ref", ".", "get", "(", ")", ";", "}", "if", "(", "injector", "==", "null", ")", "{", "injector", "=", "new", "ClassInjector", "(", "loader", ")", ";", "cShared", ".", "put", "(", "loader", ",", "new", "WeakReference", "(", "injector", ")", ")", ";", "}", "return", "injector", ";", "}", "}" ]
Returns a shared ClassInjector instance for the given ClassLoader.
[ "Returns", "a", "shared", "ClassInjector", "instance", "for", "the", "given", "ClassLoader", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/DelegatingClassInjector.java#L50-L64
204
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java
MultiplexFile.getScaledValue
private static long getScaledValue(FileBuffer buffer, int scale, long position) throws IOException { return getScaledValue(new byte[8], buffer, scale, position); }
java
private static long getScaledValue(FileBuffer buffer, int scale, long position) throws IOException { return getScaledValue(new byte[8], buffer, scale, position); }
[ "private", "static", "long", "getScaledValue", "(", "FileBuffer", "buffer", ",", "int", "scale", ",", "long", "position", ")", "throws", "IOException", "{", "return", "getScaledValue", "(", "new", "byte", "[", "8", "]", ",", "buffer", ",", "scale", ",", "position", ")", ";", "}" ]
temporary byte array.
[ "temporary", "byte", "array", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java#L47-L52
205
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java
MultiplexFile.putScaledValue
private static void putScaledValue(FileBuffer buffer, int scale, long position, long value) throws IOException { putScaledValue(new byte[8], buffer, scale, position, value); }
java
private static void putScaledValue(FileBuffer buffer, int scale, long position, long value) throws IOException { putScaledValue(new byte[8], buffer, scale, position, value); }
[ "private", "static", "void", "putScaledValue", "(", "FileBuffer", "buffer", ",", "int", "scale", ",", "long", "position", ",", "long", "value", ")", "throws", "IOException", "{", "putScaledValue", "(", "new", "byte", "[", "8", "]", ",", "buffer", ",", "scale", ",", "position", ",", "value", ")", ";", "}" ]
temorary byte array.
[ "temorary", "byte", "array", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java#L100-L105
206
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java
MultiplexFile.deleteFile
public void deleteFile(long id) throws IOException { if (id >= getFileCount()) { return; } Long key = new Long(id); InternalFile file = openInternal(key); // Acquire write lock on file to delete before acquiring lock on // file table. This ensures a consistent lock order with all other // operations and prevents deadlock. Operations on internal files // will first lock the internal file, and then lock the shared file // table when necessary. try { file.lock().acquireWriteLock(); // Use the file table lock to prevent multiple threads from using // mOpenFiles. try { mFileTableLock.acquireWriteLock(); file.delete(); mOpenFiles.remove(key); } finally { mFileTableLock.releaseLock(); } } catch (InterruptedException e) { throw new InterruptedIOException(); } finally { file.lock().releaseLock(); } }
java
public void deleteFile(long id) throws IOException { if (id >= getFileCount()) { return; } Long key = new Long(id); InternalFile file = openInternal(key); // Acquire write lock on file to delete before acquiring lock on // file table. This ensures a consistent lock order with all other // operations and prevents deadlock. Operations on internal files // will first lock the internal file, and then lock the shared file // table when necessary. try { file.lock().acquireWriteLock(); // Use the file table lock to prevent multiple threads from using // mOpenFiles. try { mFileTableLock.acquireWriteLock(); file.delete(); mOpenFiles.remove(key); } finally { mFileTableLock.releaseLock(); } } catch (InterruptedException e) { throw new InterruptedIOException(); } finally { file.lock().releaseLock(); } }
[ "public", "void", "deleteFile", "(", "long", "id", ")", "throws", "IOException", "{", "if", "(", "id", ">=", "getFileCount", "(", ")", ")", "{", "return", ";", "}", "Long", "key", "=", "new", "Long", "(", "id", ")", ";", "InternalFile", "file", "=", "openInternal", "(", "key", ")", ";", "// Acquire write lock on file to delete before acquiring lock on", "// file table. This ensures a consistent lock order with all other", "// operations and prevents deadlock. Operations on internal files", "// will first lock the internal file, and then lock the shared file", "// table when necessary.", "try", "{", "file", ".", "lock", "(", ")", ".", "acquireWriteLock", "(", ")", ";", "// Use the file table lock to prevent multiple threads from using", "// mOpenFiles.", "try", "{", "mFileTableLock", ".", "acquireWriteLock", "(", ")", ";", "file", ".", "delete", "(", ")", ";", "mOpenFiles", ".", "remove", "(", "key", ")", ";", "}", "finally", "{", "mFileTableLock", ".", "releaseLock", "(", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "InterruptedIOException", "(", ")", ";", "}", "finally", "{", "file", ".", "lock", "(", ")", ".", "releaseLock", "(", ")", ";", "}", "}" ]
Deletes the specified file. Opening it up again re-creates it.
[ "Deletes", "the", "specified", "file", ".", "Opening", "it", "up", "again", "re", "-", "creates", "it", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java#L421-L453
207
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java
MultiplexFile.truncateFileCount
public void truncateFileCount(long count) throws IOException { if (count < 0) { throw new IllegalArgumentException("count < 0: " + count); } try { mFileTableLock.acquireUpgradableLock(); long oldCount = getFileCount(); if (count >= oldCount) { return; } mFileTableLock.acquireWriteLock(); try { for (long id = oldCount; --id >= count; ) { deleteFile(id); } mFileTable.truncate(count * mFileTableEntrySize); } finally { mFileTableLock.releaseLock(); } } catch (InterruptedException e) { throw new InterruptedIOException(); } finally { mFileTableLock.releaseLock(); } }
java
public void truncateFileCount(long count) throws IOException { if (count < 0) { throw new IllegalArgumentException("count < 0: " + count); } try { mFileTableLock.acquireUpgradableLock(); long oldCount = getFileCount(); if (count >= oldCount) { return; } mFileTableLock.acquireWriteLock(); try { for (long id = oldCount; --id >= count; ) { deleteFile(id); } mFileTable.truncate(count * mFileTableEntrySize); } finally { mFileTableLock.releaseLock(); } } catch (InterruptedException e) { throw new InterruptedIOException(); } finally { mFileTableLock.releaseLock(); } }
[ "public", "void", "truncateFileCount", "(", "long", "count", ")", "throws", "IOException", "{", "if", "(", "count", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"count < 0: \"", "+", "count", ")", ";", "}", "try", "{", "mFileTableLock", ".", "acquireUpgradableLock", "(", ")", ";", "long", "oldCount", "=", "getFileCount", "(", ")", ";", "if", "(", "count", ">=", "oldCount", ")", "{", "return", ";", "}", "mFileTableLock", ".", "acquireWriteLock", "(", ")", ";", "try", "{", "for", "(", "long", "id", "=", "oldCount", ";", "--", "id", ">=", "count", ";", ")", "{", "deleteFile", "(", "id", ")", ";", "}", "mFileTable", ".", "truncate", "(", "count", "*", "mFileTableEntrySize", ")", ";", "}", "finally", "{", "mFileTableLock", ".", "releaseLock", "(", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "InterruptedIOException", "(", ")", ";", "}", "finally", "{", "mFileTableLock", ".", "releaseLock", "(", ")", ";", "}", "}" ]
Truncating the file count deletes any files with ids at or above the new count.
[ "Truncating", "the", "file", "count", "deletes", "any", "files", "with", "ids", "at", "or", "above", "the", "new", "count", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java#L503-L531
208
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java
MultiplexFile.calcLevels
final int calcLevels(long length) { // The calculation is essentially a math log operation, but the table // lookup is faster. int index = Arrays.binarySearch(mLevelMaxSizes, length); return (index < 0) ? ~index : index; }
java
final int calcLevels(long length) { // The calculation is essentially a math log operation, but the table // lookup is faster. int index = Arrays.binarySearch(mLevelMaxSizes, length); return (index < 0) ? ~index : index; }
[ "final", "int", "calcLevels", "(", "long", "length", ")", "{", "// The calculation is essentially a math log operation, but the table", "// lookup is faster.", "int", "index", "=", "Arrays", ".", "binarySearch", "(", "mLevelMaxSizes", ",", "length", ")", ";", "return", "(", "index", "<", "0", ")", "?", "~", "index", ":", "index", ";", "}" ]
Calculates the level of indirection needed to access a block in a file of the given length. If the level is zero, the file table points directly to a data block. If the level is one, the file table points to file table block. A file table block contains block ids which map to data blocks or more file table blocks.
[ "Calculates", "the", "level", "of", "indirection", "needed", "to", "access", "a", "block", "in", "a", "file", "of", "the", "given", "length", ".", "If", "the", "level", "is", "zero", "the", "file", "table", "points", "directly", "to", "a", "data", "block", ".", "If", "the", "level", "is", "one", "the", "file", "table", "points", "to", "file", "table", "block", ".", "A", "file", "table", "block", "contains", "block", "ids", "which", "map", "to", "data", "blocks", "or", "more", "file", "table", "blocks", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java#L568-L573
209
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java
MultiplexFile.freeBlock
final void freeBlock(long blockId) throws IOException { if (blockId == 0) { // Can't free block 0. } else { try { mFreeBlocksBitlist.lock().acquireWriteLock(); mFreeBlocksBitlist.set(blockId); if (mFirstFreeBlock == 0 || blockId < mFirstFreeBlock) { setFirstFreeBlock(blockId); } } catch (InterruptedException e) { throw new InterruptedIOException(); } finally { mFreeBlocksBitlist.lock().releaseLock(); } } }
java
final void freeBlock(long blockId) throws IOException { if (blockId == 0) { // Can't free block 0. } else { try { mFreeBlocksBitlist.lock().acquireWriteLock(); mFreeBlocksBitlist.set(blockId); if (mFirstFreeBlock == 0 || blockId < mFirstFreeBlock) { setFirstFreeBlock(blockId); } } catch (InterruptedException e) { throw new InterruptedIOException(); } finally { mFreeBlocksBitlist.lock().releaseLock(); } } }
[ "final", "void", "freeBlock", "(", "long", "blockId", ")", "throws", "IOException", "{", "if", "(", "blockId", "==", "0", ")", "{", "// Can't free block 0.", "}", "else", "{", "try", "{", "mFreeBlocksBitlist", ".", "lock", "(", ")", ".", "acquireWriteLock", "(", ")", ";", "mFreeBlocksBitlist", ".", "set", "(", "blockId", ")", ";", "if", "(", "mFirstFreeBlock", "==", "0", "||", "blockId", "<", "mFirstFreeBlock", ")", "{", "setFirstFreeBlock", "(", "blockId", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "InterruptedIOException", "(", ")", ";", "}", "finally", "{", "mFreeBlocksBitlist", ".", "lock", "(", ")", ".", "releaseLock", "(", ")", ";", "}", "}", "}" ]
Attempting to free block 0 or a block that is already free has no effect.
[ "Attempting", "to", "free", "block", "0", "or", "a", "block", "that", "is", "already", "free", "has", "no", "effect", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java#L644-L663
210
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java
MultiplexFile.getBlockId
final long getBlockId(long refBlockId, int index) throws IOException { if (refBlockId == 0) { return 0; } return getBlockId(mBackingFile, refBlockId * mBlockSize + index); }
java
final long getBlockId(long refBlockId, int index) throws IOException { if (refBlockId == 0) { return 0; } return getBlockId(mBackingFile, refBlockId * mBlockSize + index); }
[ "final", "long", "getBlockId", "(", "long", "refBlockId", ",", "int", "index", ")", "throws", "IOException", "{", "if", "(", "refBlockId", "==", "0", ")", "{", "return", "0", ";", "}", "return", "getBlockId", "(", "mBackingFile", ",", "refBlockId", "*", "mBlockSize", "+", "index", ")", ";", "}" ]
Returns 0 if referring block is 0.
[ "Returns", "0", "if", "referring", "block", "is", "0", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/file/MultiplexFile.java#L740-L747
211
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/util/TemplateServerServlet.java
TemplateServerServlet.doGet
public void doGet(HttpServletRequest req,HttpServletResponse res) { getTemplateData(req, res,req.getPathInfo()); }
java
public void doGet(HttpServletRequest req,HttpServletResponse res) { getTemplateData(req, res,req.getPathInfo()); }
[ "public", "void", "doGet", "(", "HttpServletRequest", "req", ",", "HttpServletResponse", "res", ")", "{", "getTemplateData", "(", "req", ",", "res", ",", "req", ".", "getPathInfo", "(", ")", ")", ";", "}" ]
Retrieves all the templates that are newer that the timestamp specified by the client. The pathInfo from the request specifies which templates are desired. QueryString parameters "timeStamp" and ??? provide
[ "Retrieves", "all", "the", "templates", "that", "are", "newer", "that", "the", "timestamp", "specified", "by", "the", "client", ".", "The", "pathInfo", "from", "the", "request", "specifies", "which", "templates", "are", "desired", ".", "QueryString", "parameters", "timeStamp", "and", "???", "provide" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/util/TemplateServerServlet.java#L79-L81
212
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/runtime/TemplateLoader.java
TemplateLoader.getTemplate
public final synchronized Template getTemplate(String name) throws ClassNotFoundException, NoSuchMethodException, LinkageError { Template template = mTemplates.get(name); if (template == null) { template = loadTemplate(name); mTemplates.put(name, template); } return template; }
java
public final synchronized Template getTemplate(String name) throws ClassNotFoundException, NoSuchMethodException, LinkageError { Template template = mTemplates.get(name); if (template == null) { template = loadTemplate(name); mTemplates.put(name, template); } return template; }
[ "public", "final", "synchronized", "Template", "getTemplate", "(", "String", "name", ")", "throws", "ClassNotFoundException", ",", "NoSuchMethodException", ",", "LinkageError", "{", "Template", "template", "=", "mTemplates", ".", "get", "(", "name", ")", ";", "if", "(", "template", "==", "null", ")", "{", "template", "=", "loadTemplate", "(", "name", ")", ";", "mTemplates", ".", "put", "(", "name", ",", "template", ")", ";", "}", "return", "template", ";", "}" ]
Get or load a template by its full name. The full name of a template has '.' characters to separate name parts, and it does not include a Java package prefix. @throws ClassNotFoundException when template not found @throws NoSuchMethodException when the template is invalid
[ "Get", "or", "load", "a", "template", "by", "its", "full", "name", ".", "The", "full", "name", "of", "a", "template", "has", ".", "characters", "to", "separate", "name", "parts", "and", "it", "does", "not", "include", "a", "Java", "package", "prefix", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/runtime/TemplateLoader.java#L97-L106
213
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/CompiledTemplate.java
CompiledTemplate.getTemplateClass
private Class<?> getTemplateClass() { String fqName = getTargetPackage() + "." + getName(); try { mTemplateClass = getCompiler().loadClass(fqName); } catch (ClassNotFoundException nx) { try { mTemplateClass = getCompiler().loadClass(getName()); // Try standard path as a last resort } catch (ClassNotFoundException nx2) { return null; } } return mTemplateClass; }
java
private Class<?> getTemplateClass() { String fqName = getTargetPackage() + "." + getName(); try { mTemplateClass = getCompiler().loadClass(fqName); } catch (ClassNotFoundException nx) { try { mTemplateClass = getCompiler().loadClass(getName()); // Try standard path as a last resort } catch (ClassNotFoundException nx2) { return null; } } return mTemplateClass; }
[ "private", "Class", "<", "?", ">", "getTemplateClass", "(", ")", "{", "String", "fqName", "=", "getTargetPackage", "(", ")", "+", "\".\"", "+", "getName", "(", ")", ";", "try", "{", "mTemplateClass", "=", "getCompiler", "(", ")", ".", "loadClass", "(", "fqName", ")", ";", "}", "catch", "(", "ClassNotFoundException", "nx", ")", "{", "try", "{", "mTemplateClass", "=", "getCompiler", "(", ")", ".", "loadClass", "(", "getName", "(", ")", ")", ";", "// Try standard path as a last resort", "}", "catch", "(", "ClassNotFoundException", "nx2", ")", "{", "return", "null", ";", "}", "}", "return", "mTemplateClass", ";", "}" ]
Load the template.
[ "Load", "the", "template", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/CompiledTemplate.java#L84-L98
214
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/CompiledTemplate.java
CompiledTemplate.exists
public static boolean exists(Compiler c, String name, CompilationUnit from) { String fqName = getFullyQualifiedName(resolveName(name, from)); try { c.loadClass(fqName); return true; } catch (ClassNotFoundException nx) { try { c.loadClass(resolveName(name, from)); // Try standard path as a last resort return true; } catch (ClassNotFoundException nx2) { return false; } } }
java
public static boolean exists(Compiler c, String name, CompilationUnit from) { String fqName = getFullyQualifiedName(resolveName(name, from)); try { c.loadClass(fqName); return true; } catch (ClassNotFoundException nx) { try { c.loadClass(resolveName(name, from)); // Try standard path as a last resort return true; } catch (ClassNotFoundException nx2) { return false; } } }
[ "public", "static", "boolean", "exists", "(", "Compiler", "c", ",", "String", "name", ",", "CompilationUnit", "from", ")", "{", "String", "fqName", "=", "getFullyQualifiedName", "(", "resolveName", "(", "name", ",", "from", ")", ")", ";", "try", "{", "c", ".", "loadClass", "(", "fqName", ")", ";", "return", "true", ";", "}", "catch", "(", "ClassNotFoundException", "nx", ")", "{", "try", "{", "c", ".", "loadClass", "(", "resolveName", "(", "name", ",", "from", ")", ")", ";", "// Try standard path as a last resort", "return", "true", ";", "}", "catch", "(", "ClassNotFoundException", "nx2", ")", "{", "return", "false", ";", "}", "}", "}" ]
Test to see of the template can be loaded before CompiledTemplate can be constructed.
[ "Test", "to", "see", "of", "the", "template", "can", "be", "loaded", "before", "CompiledTemplate", "can", "be", "constructed", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/CompiledTemplate.java#L126-L141
215
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/CompiledTemplate.java
CompiledTemplate.getParseTree
public Template getParseTree() { getTemplateClass(); if (findExecuteMethod() == null) throw new IllegalArgumentException("Cannot locate compiled template entry point."); reflectParameters(); mTree = new Template(mCallerInfo, new Name(mCallerInfo, getName()), mParameters, mSubParam, null, null); mTree.setReturnType(new Type(mExecuteMethod.getReturnType(), mExecuteMethod.getGenericReturnType())); return mTree; }
java
public Template getParseTree() { getTemplateClass(); if (findExecuteMethod() == null) throw new IllegalArgumentException("Cannot locate compiled template entry point."); reflectParameters(); mTree = new Template(mCallerInfo, new Name(mCallerInfo, getName()), mParameters, mSubParam, null, null); mTree.setReturnType(new Type(mExecuteMethod.getReturnType(), mExecuteMethod.getGenericReturnType())); return mTree; }
[ "public", "Template", "getParseTree", "(", ")", "{", "getTemplateClass", "(", ")", ";", "if", "(", "findExecuteMethod", "(", ")", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Cannot locate compiled template entry point.\"", ")", ";", "reflectParameters", "(", ")", ";", "mTree", "=", "new", "Template", "(", "mCallerInfo", ",", "new", "Name", "(", "mCallerInfo", ",", "getName", "(", ")", ")", ",", "mParameters", ",", "mSubParam", ",", "null", ",", "null", ")", ";", "mTree", ".", "setReturnType", "(", "new", "Type", "(", "mExecuteMethod", ".", "getReturnType", "(", ")", ",", "mExecuteMethod", ".", "getGenericReturnType", "(", ")", ")", ")", ";", "return", "mTree", ";", "}" ]
This method is called by JavaClassGenerator during the compile phase. It overrides the method in CompilationUnit and returns just the reflected template signature.
[ "This", "method", "is", "called", "by", "JavaClassGenerator", "during", "the", "compile", "phase", ".", "It", "overrides", "the", "method", "in", "CompilationUnit", "and", "returns", "just", "the", "reflected", "template", "signature", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/CompiledTemplate.java#L160-L172
216
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/CompiledTemplate.java
CompiledTemplate.getTargetPackage
public String getTargetPackage() { return mCaller != null && mCaller.getTargetPackage() != null ? mCaller.getTargetPackage() : TEMPLATE_PACKAGE; }
java
public String getTargetPackage() { return mCaller != null && mCaller.getTargetPackage() != null ? mCaller.getTargetPackage() : TEMPLATE_PACKAGE; }
[ "public", "String", "getTargetPackage", "(", ")", "{", "return", "mCaller", "!=", "null", "&&", "mCaller", ".", "getTargetPackage", "(", ")", "!=", "null", "?", "mCaller", ".", "getTargetPackage", "(", ")", ":", "TEMPLATE_PACKAGE", ";", "}" ]
Return the package name that this CompilationUnit should be compiled into.
[ "Return", "the", "package", "name", "that", "this", "CompilationUnit", "should", "be", "compiled", "into", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/CompiledTemplate.java#L214-L217
217
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueue.java
TransactionQueue.enqueue
public synchronized boolean enqueue(Transaction transaction) { mTotalEnqueueAttempts++; if (transaction == null || mThreadPool.isClosed()) { return false; } int queueSize; if ((queueSize = mQueue.size()) >= mMaxSize) { if (mListeners.size() > 0) { TransactionQueueEvent event = new TransactionQueueEvent(this, transaction); Iterator it = mListeners.iterator(); while (it.hasNext()) { ((TransactionQueueListener)it.next()) .transactionQueueFull(event); } } return false; } if (!mSuspended) { if (!ensureWaitingThread()) { return false; } } mTotalEnqueued++; TransactionQueueEvent event = new TransactionQueueEvent(this, transaction); mQueue.addLast(event); if (++queueSize > mPeakQueueSize) { mPeakQueueSize = queueSize; } notify(); if (mListeners.size() > 0) { Iterator it = mListeners.iterator(); while (it.hasNext()) { ((TransactionQueueListener)it.next()) .transactionEnqueued(event); } } return true; }
java
public synchronized boolean enqueue(Transaction transaction) { mTotalEnqueueAttempts++; if (transaction == null || mThreadPool.isClosed()) { return false; } int queueSize; if ((queueSize = mQueue.size()) >= mMaxSize) { if (mListeners.size() > 0) { TransactionQueueEvent event = new TransactionQueueEvent(this, transaction); Iterator it = mListeners.iterator(); while (it.hasNext()) { ((TransactionQueueListener)it.next()) .transactionQueueFull(event); } } return false; } if (!mSuspended) { if (!ensureWaitingThread()) { return false; } } mTotalEnqueued++; TransactionQueueEvent event = new TransactionQueueEvent(this, transaction); mQueue.addLast(event); if (++queueSize > mPeakQueueSize) { mPeakQueueSize = queueSize; } notify(); if (mListeners.size() > 0) { Iterator it = mListeners.iterator(); while (it.hasNext()) { ((TransactionQueueListener)it.next()) .transactionEnqueued(event); } } return true; }
[ "public", "synchronized", "boolean", "enqueue", "(", "Transaction", "transaction", ")", "{", "mTotalEnqueueAttempts", "++", ";", "if", "(", "transaction", "==", "null", "||", "mThreadPool", ".", "isClosed", "(", ")", ")", "{", "return", "false", ";", "}", "int", "queueSize", ";", "if", "(", "(", "queueSize", "=", "mQueue", ".", "size", "(", ")", ")", ">=", "mMaxSize", ")", "{", "if", "(", "mListeners", ".", "size", "(", ")", ">", "0", ")", "{", "TransactionQueueEvent", "event", "=", "new", "TransactionQueueEvent", "(", "this", ",", "transaction", ")", ";", "Iterator", "it", "=", "mListeners", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "(", "(", "TransactionQueueListener", ")", "it", ".", "next", "(", ")", ")", ".", "transactionQueueFull", "(", "event", ")", ";", "}", "}", "return", "false", ";", "}", "if", "(", "!", "mSuspended", ")", "{", "if", "(", "!", "ensureWaitingThread", "(", ")", ")", "{", "return", "false", ";", "}", "}", "mTotalEnqueued", "++", ";", "TransactionQueueEvent", "event", "=", "new", "TransactionQueueEvent", "(", "this", ",", "transaction", ")", ";", "mQueue", ".", "addLast", "(", "event", ")", ";", "if", "(", "++", "queueSize", ">", "mPeakQueueSize", ")", "{", "mPeakQueueSize", "=", "queueSize", ";", "}", "notify", "(", ")", ";", "if", "(", "mListeners", ".", "size", "(", ")", ">", "0", ")", "{", "Iterator", "it", "=", "mListeners", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "(", "(", "TransactionQueueListener", ")", "it", ".", "next", "(", ")", ")", ".", "transactionEnqueued", "(", "event", ")", ";", "}", "}", "return", "true", ";", "}" ]
Enqueues a transaction that will be serviced when a worker is available. If the queue is full or cannot accept new transactions, the transaction is not enqueued, and false is returned. @return true if enqueued, false if queue is full or cannot accept new transactions.
[ "Enqueues", "a", "transaction", "that", "will", "be", "serviced", "when", "a", "worker", "is", "available", ".", "If", "the", "queue", "is", "full", "or", "cannot", "accept", "new", "transactions", "the", "transaction", "is", "not", "enqueued", "and", "false", "is", "returned", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueue.java#L174-L224
218
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueue.java
TransactionQueue.getStatistics
public synchronized TransactionQueueData getStatistics() { return new TransactionQueueData(this, mTimeLapseStart, System.currentTimeMillis(), mQueue.size(), mThreadCount, mServicingCount, mPeakQueueSize, mPeakThreadCount, mPeakServicingCount, mTotalEnqueueAttempts, mTotalEnqueued, mTotalServiced, mTotalExpired, mTotalServiceExceptions, mTotalUncaughtExceptions, mTotalQueueDuration, mTotalServiceDuration); }
java
public synchronized TransactionQueueData getStatistics() { return new TransactionQueueData(this, mTimeLapseStart, System.currentTimeMillis(), mQueue.size(), mThreadCount, mServicingCount, mPeakQueueSize, mPeakThreadCount, mPeakServicingCount, mTotalEnqueueAttempts, mTotalEnqueued, mTotalServiced, mTotalExpired, mTotalServiceExceptions, mTotalUncaughtExceptions, mTotalQueueDuration, mTotalServiceDuration); }
[ "public", "synchronized", "TransactionQueueData", "getStatistics", "(", ")", "{", "return", "new", "TransactionQueueData", "(", "this", ",", "mTimeLapseStart", ",", "System", ".", "currentTimeMillis", "(", ")", ",", "mQueue", ".", "size", "(", ")", ",", "mThreadCount", ",", "mServicingCount", ",", "mPeakQueueSize", ",", "mPeakThreadCount", ",", "mPeakServicingCount", ",", "mTotalEnqueueAttempts", ",", "mTotalEnqueued", ",", "mTotalServiced", ",", "mTotalExpired", ",", "mTotalServiceExceptions", ",", "mTotalUncaughtExceptions", ",", "mTotalQueueDuration", ",", "mTotalServiceDuration", ")", ";", "}" ]
Returns a snapshot of the statistics on this TransactionQueue.
[ "Returns", "a", "snapshot", "of", "the", "statistics", "on", "this", "TransactionQueue", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueue.java#L310-L328
219
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueue.java
TransactionQueue.resetStatistics
public synchronized void resetStatistics() { mPeakQueueSize = 0; mPeakThreadCount = 0; mPeakServicingCount = 0; mTotalEnqueueAttempts = 0; mTotalEnqueued = 0; mTotalServiced = 0; mTotalExpired = 0; mTotalServiceExceptions = 0; mTotalUncaughtExceptions = 0; mTotalQueueDuration = 0; mTotalServiceDuration = 0; mTimeLapseStart = System.currentTimeMillis(); }
java
public synchronized void resetStatistics() { mPeakQueueSize = 0; mPeakThreadCount = 0; mPeakServicingCount = 0; mTotalEnqueueAttempts = 0; mTotalEnqueued = 0; mTotalServiced = 0; mTotalExpired = 0; mTotalServiceExceptions = 0; mTotalUncaughtExceptions = 0; mTotalQueueDuration = 0; mTotalServiceDuration = 0; mTimeLapseStart = System.currentTimeMillis(); }
[ "public", "synchronized", "void", "resetStatistics", "(", ")", "{", "mPeakQueueSize", "=", "0", ";", "mPeakThreadCount", "=", "0", ";", "mPeakServicingCount", "=", "0", ";", "mTotalEnqueueAttempts", "=", "0", ";", "mTotalEnqueued", "=", "0", ";", "mTotalServiced", "=", "0", ";", "mTotalExpired", "=", "0", ";", "mTotalServiceExceptions", "=", "0", ";", "mTotalUncaughtExceptions", "=", "0", ";", "mTotalQueueDuration", "=", "0", ";", "mTotalServiceDuration", "=", "0", ";", "mTimeLapseStart", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "}" ]
Resets all time lapse statistics.
[ "Resets", "all", "time", "lapse", "statistics", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueue.java#L333-L347
220
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueue.java
TransactionQueue.applyProperties
public synchronized void applyProperties(PropertyMap properties) { if (properties.containsKey("max.size")) { setMaximumSize(properties.getInt("max.size")); } if (properties.containsKey("max.threads")) { setMaximumThreads(properties.getInt("max.threads")); } if (properties.containsKey("timeout.idle")) { setIdleTimeout(properties.getNumber("timeout.idle").longValue()); } if (properties.containsKey("timeout.transaction")) { setTransactionTimeout (properties.getNumber("timeout.transaction").longValue()); } if ("true".equalsIgnoreCase(properties.getString("tune.size"))) { addTransactionQueueListener(new TransactionQueueSizeTuner()); } if ("true".equalsIgnoreCase(properties.getString("tune.threads"))) { addTransactionQueueListener(new TransactionQueueThreadTuner()); } }
java
public synchronized void applyProperties(PropertyMap properties) { if (properties.containsKey("max.size")) { setMaximumSize(properties.getInt("max.size")); } if (properties.containsKey("max.threads")) { setMaximumThreads(properties.getInt("max.threads")); } if (properties.containsKey("timeout.idle")) { setIdleTimeout(properties.getNumber("timeout.idle").longValue()); } if (properties.containsKey("timeout.transaction")) { setTransactionTimeout (properties.getNumber("timeout.transaction").longValue()); } if ("true".equalsIgnoreCase(properties.getString("tune.size"))) { addTransactionQueueListener(new TransactionQueueSizeTuner()); } if ("true".equalsIgnoreCase(properties.getString("tune.threads"))) { addTransactionQueueListener(new TransactionQueueThreadTuner()); } }
[ "public", "synchronized", "void", "applyProperties", "(", "PropertyMap", "properties", ")", "{", "if", "(", "properties", ".", "containsKey", "(", "\"max.size\"", ")", ")", "{", "setMaximumSize", "(", "properties", ".", "getInt", "(", "\"max.size\"", ")", ")", ";", "}", "if", "(", "properties", ".", "containsKey", "(", "\"max.threads\"", ")", ")", "{", "setMaximumThreads", "(", "properties", ".", "getInt", "(", "\"max.threads\"", ")", ")", ";", "}", "if", "(", "properties", ".", "containsKey", "(", "\"timeout.idle\"", ")", ")", "{", "setIdleTimeout", "(", "properties", ".", "getNumber", "(", "\"timeout.idle\"", ")", ".", "longValue", "(", ")", ")", ";", "}", "if", "(", "properties", ".", "containsKey", "(", "\"timeout.transaction\"", ")", ")", "{", "setTransactionTimeout", "(", "properties", ".", "getNumber", "(", "\"timeout.transaction\"", ")", ".", "longValue", "(", ")", ")", ";", "}", "if", "(", "\"true\"", ".", "equalsIgnoreCase", "(", "properties", ".", "getString", "(", "\"tune.size\"", ")", ")", ")", "{", "addTransactionQueueListener", "(", "new", "TransactionQueueSizeTuner", "(", ")", ")", ";", "}", "if", "(", "\"true\"", ".", "equalsIgnoreCase", "(", "properties", ".", "getString", "(", "\"tune.threads\"", ")", ")", ")", "{", "addTransactionQueueListener", "(", "new", "TransactionQueueThreadTuner", "(", ")", ")", ";", "}", "}" ]
Understands and applies the following integer properties. <ul> <li>max.size - setMaximumSize <li>max.threads - setMaximumThreads <li>timeout.idle - setIdleTimeout <li>timeout.transaction - setTransactionTimeout <li>tune.size - Automatically tunes queue size when "true" and transaction timeout set. <li>tune.threads - Automatically tunes maximum thread count. </ul>
[ "Understands", "and", "applies", "the", "following", "integer", "properties", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueue.java#L362-L387
221
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueue.java
TransactionQueue.nextTransactionEvent
synchronized TransactionQueueEvent nextTransactionEvent() throws InterruptedException { if (mQueue.isEmpty()) { if (mIdleTimeout != 0) { if (mIdleTimeout < 0) { wait(); } else { wait(mIdleTimeout); } } } if (mQueue.isEmpty()) { return null; } return (TransactionQueueEvent)mQueue.removeFirst(); }
java
synchronized TransactionQueueEvent nextTransactionEvent() throws InterruptedException { if (mQueue.isEmpty()) { if (mIdleTimeout != 0) { if (mIdleTimeout < 0) { wait(); } else { wait(mIdleTimeout); } } } if (mQueue.isEmpty()) { return null; } return (TransactionQueueEvent)mQueue.removeFirst(); }
[ "synchronized", "TransactionQueueEvent", "nextTransactionEvent", "(", ")", "throws", "InterruptedException", "{", "if", "(", "mQueue", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "mIdleTimeout", "!=", "0", ")", "{", "if", "(", "mIdleTimeout", "<", "0", ")", "{", "wait", "(", ")", ";", "}", "else", "{", "wait", "(", "mIdleTimeout", ")", ";", "}", "}", "}", "if", "(", "mQueue", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "return", "(", "TransactionQueueEvent", ")", "mQueue", ".", "removeFirst", "(", ")", ";", "}" ]
Returns null when the TransactionQueue should go idle.
[ "Returns", "null", "when", "the", "TransactionQueue", "should", "go", "idle", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueue.java#L410-L429
222
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/util/NameValuePair.java
NameValuePair.compareTo
public int compareTo(NameValuePair<T> other) { String otherName = other.mName; if (mName == null) { return otherName == null ? 0 : 1; } if (otherName == null) { return -1; } return mName.compareToIgnoreCase(otherName); }
java
public int compareTo(NameValuePair<T> other) { String otherName = other.mName; if (mName == null) { return otherName == null ? 0 : 1; } if (otherName == null) { return -1; } return mName.compareToIgnoreCase(otherName); }
[ "public", "int", "compareTo", "(", "NameValuePair", "<", "T", ">", "other", ")", "{", "String", "otherName", "=", "other", ".", "mName", ";", "if", "(", "mName", "==", "null", ")", "{", "return", "otherName", "==", "null", "?", "0", ":", "1", ";", "}", "if", "(", "otherName", "==", "null", ")", "{", "return", "-", "1", ";", "}", "return", "mName", ".", "compareToIgnoreCase", "(", "otherName", ")", ";", "}" ]
Comparison is based on case-insensitive ordering of "name".
[ "Comparison", "is", "based", "on", "case", "-", "insensitive", "ordering", "of", "name", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/util/NameValuePair.java#L90-L102
223
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/CompileEvent.java
CompileEvent.getDetailedMessage
public String getDetailedMessage() { String prepend = getSourceInfoMessage(); if (prepend == null || prepend.length() == 0) { return mMessage; } else { return prepend + ": " + mMessage; } }
java
public String getDetailedMessage() { String prepend = getSourceInfoMessage(); if (prepend == null || prepend.length() == 0) { return mMessage; } else { return prepend + ": " + mMessage; } }
[ "public", "String", "getDetailedMessage", "(", ")", "{", "String", "prepend", "=", "getSourceInfoMessage", "(", ")", ";", "if", "(", "prepend", "==", "null", "||", "prepend", ".", "length", "(", ")", "==", "0", ")", "{", "return", "mMessage", ";", "}", "else", "{", "return", "prepend", "+", "\": \"", "+", "mMessage", ";", "}", "}" ]
Returns the detailed message by prepending the standard message with source file information. @return The detailed message with the source file information @see #getMessage()
[ "Returns", "the", "detailed", "message", "by", "prepending", "the", "standard", "message", "with", "source", "file", "information", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/CompileEvent.java#L114-L122
224
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/CompileEvent.java
CompileEvent.getSourceInfoMessage
public String getSourceInfoMessage() { String msg; if (mUnit == null) { if (mInfo == null) { msg = ""; } else { msg = String.valueOf(mInfo.getLine()); } } else { if (mInfo == null) { msg = mUnit.getName(); } else { msg = mUnit.getName() + ':' + mInfo.getLine(); } } return msg; }
java
public String getSourceInfoMessage() { String msg; if (mUnit == null) { if (mInfo == null) { msg = ""; } else { msg = String.valueOf(mInfo.getLine()); } } else { if (mInfo == null) { msg = mUnit.getName(); } else { msg = mUnit.getName() + ':' + mInfo.getLine(); } } return msg; }
[ "public", "String", "getSourceInfoMessage", "(", ")", "{", "String", "msg", ";", "if", "(", "mUnit", "==", "null", ")", "{", "if", "(", "mInfo", "==", "null", ")", "{", "msg", "=", "\"\"", ";", "}", "else", "{", "msg", "=", "String", ".", "valueOf", "(", "mInfo", ".", "getLine", "(", ")", ")", ";", "}", "}", "else", "{", "if", "(", "mInfo", "==", "null", ")", "{", "msg", "=", "mUnit", ".", "getName", "(", ")", ";", "}", "else", "{", "msg", "=", "mUnit", ".", "getName", "(", ")", "+", "'", "'", "+", "mInfo", ".", "getLine", "(", ")", ";", "}", "}", "return", "msg", ";", "}" ]
Get the source file information associated with this event. The source file information includes the name of the associated template and potential line number. @return The source file information associated with the event
[ "Get", "the", "source", "file", "information", "associated", "with", "this", "event", ".", "The", "source", "file", "information", "includes", "the", "name", "of", "the", "associated", "template", "and", "potential", "line", "number", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/CompileEvent.java#L131-L152
225
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/net/InetAddressResolver.java
InetAddressResolver.listenFor
public static InetAddressResolver listenFor(String host, InetAddressListener listener) { synchronized (cResolvers) { InetAddressResolver resolver = (InetAddressResolver)cResolvers.get(host); if (resolver == null) { resolver = new InetAddressResolver(host); cResolvers.put(host, resolver); } resolver.addListener(listener); return resolver; } }
java
public static InetAddressResolver listenFor(String host, InetAddressListener listener) { synchronized (cResolvers) { InetAddressResolver resolver = (InetAddressResolver)cResolvers.get(host); if (resolver == null) { resolver = new InetAddressResolver(host); cResolvers.put(host, resolver); } resolver.addListener(listener); return resolver; } }
[ "public", "static", "InetAddressResolver", "listenFor", "(", "String", "host", ",", "InetAddressListener", "listener", ")", "{", "synchronized", "(", "cResolvers", ")", "{", "InetAddressResolver", "resolver", "=", "(", "InetAddressResolver", ")", "cResolvers", ".", "get", "(", "host", ")", ";", "if", "(", "resolver", "==", "null", ")", "{", "resolver", "=", "new", "InetAddressResolver", "(", "host", ")", ";", "cResolvers", ".", "put", "(", "host", ",", "resolver", ")", ";", "}", "resolver", ".", "addListener", "(", "listener", ")", ";", "return", "resolver", ";", "}", "}" ]
Resolve the host name into InetAddresses and listen for changes. The caller must save a reference to the resolver to prevent it from being reclaimed by the garbage collector. @param host host to resolve into InetAddresses @param listener listens for InetAddresses
[ "Resolve", "the", "host", "name", "into", "InetAddresses", "and", "listen", "for", "changes", ".", "The", "caller", "must", "save", "a", "reference", "to", "the", "resolver", "to", "prevent", "it", "from", "being", "reclaimed", "by", "the", "garbage", "collector", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/InetAddressResolver.java#L62-L74
226
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/net/InetAddressResolver.java
InetAddressResolver.resolveAddresses
private synchronized boolean resolveAddresses() { boolean changed; try { InetAddress[] addresses = InetAddress.getAllByName(mHost); if (mResolutionResults instanceof UnknownHostException) { changed = true; } else { // Results may be ordered differently, so keep them sorted. Arrays.sort(addresses, new Comparator() { public int compare(Object a, Object b) { return ((InetAddress)a).getHostAddress() .compareTo(((InetAddress)b).getHostAddress()); } }); changed = !Arrays.equals (addresses, (InetAddress[])mResolutionResults); } mResolutionResults = addresses; } catch (UnknownHostException e) { changed = !(mResolutionResults instanceof UnknownHostException); mResolutionResults = e; } if (changed) { int size = mListeners.size(); for (int i=0; i<size; i++) { notifyListener((InetAddressListener)mListeners.get(i)); } } return changed; }
java
private synchronized boolean resolveAddresses() { boolean changed; try { InetAddress[] addresses = InetAddress.getAllByName(mHost); if (mResolutionResults instanceof UnknownHostException) { changed = true; } else { // Results may be ordered differently, so keep them sorted. Arrays.sort(addresses, new Comparator() { public int compare(Object a, Object b) { return ((InetAddress)a).getHostAddress() .compareTo(((InetAddress)b).getHostAddress()); } }); changed = !Arrays.equals (addresses, (InetAddress[])mResolutionResults); } mResolutionResults = addresses; } catch (UnknownHostException e) { changed = !(mResolutionResults instanceof UnknownHostException); mResolutionResults = e; } if (changed) { int size = mListeners.size(); for (int i=0; i<size; i++) { notifyListener((InetAddressListener)mListeners.get(i)); } } return changed; }
[ "private", "synchronized", "boolean", "resolveAddresses", "(", ")", "{", "boolean", "changed", ";", "try", "{", "InetAddress", "[", "]", "addresses", "=", "InetAddress", ".", "getAllByName", "(", "mHost", ")", ";", "if", "(", "mResolutionResults", "instanceof", "UnknownHostException", ")", "{", "changed", "=", "true", ";", "}", "else", "{", "// Results may be ordered differently, so keep them sorted.", "Arrays", ".", "sort", "(", "addresses", ",", "new", "Comparator", "(", ")", "{", "public", "int", "compare", "(", "Object", "a", ",", "Object", "b", ")", "{", "return", "(", "(", "InetAddress", ")", "a", ")", ".", "getHostAddress", "(", ")", ".", "compareTo", "(", "(", "(", "InetAddress", ")", "b", ")", ".", "getHostAddress", "(", ")", ")", ";", "}", "}", ")", ";", "changed", "=", "!", "Arrays", ".", "equals", "(", "addresses", ",", "(", "InetAddress", "[", "]", ")", "mResolutionResults", ")", ";", "}", "mResolutionResults", "=", "addresses", ";", "}", "catch", "(", "UnknownHostException", "e", ")", "{", "changed", "=", "!", "(", "mResolutionResults", "instanceof", "UnknownHostException", ")", ";", "mResolutionResults", "=", "e", ";", "}", "if", "(", "changed", ")", "{", "int", "size", "=", "mListeners", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "notifyListener", "(", "(", "InetAddressListener", ")", "mListeners", ".", "get", "(", "i", ")", ")", ";", "}", "}", "return", "changed", ";", "}" ]
Returns true if anything changed from the last time this was invoked.
[ "Returns", "true", "if", "anything", "changed", "from", "the", "last", "time", "this", "was", "invoked", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/InetAddressResolver.java#L112-L146
227
teatrove/teatrove
build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/PropertyDoc.java
PropertyDoc.trimFirstWord
private static final String trimFirstWord(String s) { s = s.trim(); char[] chars = s.toCharArray(); int firstSpace = -1; for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (Character.isWhitespace(c)) { firstSpace = i; break; } } if (firstSpace == -1) { return s; } s = s.substring(firstSpace).trim(); s = capitalize(s); return s; }
java
private static final String trimFirstWord(String s) { s = s.trim(); char[] chars = s.toCharArray(); int firstSpace = -1; for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (Character.isWhitespace(c)) { firstSpace = i; break; } } if (firstSpace == -1) { return s; } s = s.substring(firstSpace).trim(); s = capitalize(s); return s; }
[ "private", "static", "final", "String", "trimFirstWord", "(", "String", "s", ")", "{", "s", "=", "s", ".", "trim", "(", ")", ";", "char", "[", "]", "chars", "=", "s", ".", "toCharArray", "(", ")", ";", "int", "firstSpace", "=", "-", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "chars", ".", "length", ";", "i", "++", ")", "{", "char", "c", "=", "chars", "[", "i", "]", ";", "if", "(", "Character", ".", "isWhitespace", "(", "c", ")", ")", "{", "firstSpace", "=", "i", ";", "break", ";", "}", "}", "if", "(", "firstSpace", "==", "-", "1", ")", "{", "return", "s", ";", "}", "s", "=", "s", ".", "substring", "(", "firstSpace", ")", ".", "trim", "(", ")", ";", "s", "=", "capitalize", "(", "s", ")", ";", "return", "s", ";", "}" ]
Trims off the first word of the specified string and capitalizes the new first word
[ "Trims", "off", "the", "first", "word", "of", "the", "specified", "string", "and", "capitalizes", "the", "new", "first", "word" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/PropertyDoc.java#L144-L165
228
teatrove/teatrove
build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/PropertyDoc.java
PropertyDoc.getTagValue
public String getTagValue(String tagName) { String value = null; if (mReadMethod != null) { value = mReadMethod.getTagValue(tagName); } if (value == null && mWriteMethod != null) { value = mWriteMethod.getTagValue(tagName); } return value; }
java
public String getTagValue(String tagName) { String value = null; if (mReadMethod != null) { value = mReadMethod.getTagValue(tagName); } if (value == null && mWriteMethod != null) { value = mWriteMethod.getTagValue(tagName); } return value; }
[ "public", "String", "getTagValue", "(", "String", "tagName", ")", "{", "String", "value", "=", "null", ";", "if", "(", "mReadMethod", "!=", "null", ")", "{", "value", "=", "mReadMethod", ".", "getTagValue", "(", "tagName", ")", ";", "}", "if", "(", "value", "==", "null", "&&", "mWriteMethod", "!=", "null", ")", "{", "value", "=", "mWriteMethod", ".", "getTagValue", "(", "tagName", ")", ";", "}", "return", "value", ";", "}" ]
Overridden to check both the read and write MethodDocs for the tag
[ "Overridden", "to", "check", "both", "the", "read", "and", "write", "MethodDocs", "for", "the", "tag" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/PropertyDoc.java#L295-L306
229
teatrove/teatrove
build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/PropertyDoc.java
PropertyDoc.getMethodCommentText
private String getMethodCommentText() { String text = null; // Check the read method first if (mReadMethod != null) { text = mReadMethod.getCommentText(); } if (text == null && mWriteMethod != null) { // Try the write method text = mWriteMethod.getCommentText(); } if (text == null || text.trim().length() == 0) { // Try the "@return" tag text = getTagValue("return"); } return text; }
java
private String getMethodCommentText() { String text = null; // Check the read method first if (mReadMethod != null) { text = mReadMethod.getCommentText(); } if (text == null && mWriteMethod != null) { // Try the write method text = mWriteMethod.getCommentText(); } if (text == null || text.trim().length() == 0) { // Try the "@return" tag text = getTagValue("return"); } return text; }
[ "private", "String", "getMethodCommentText", "(", ")", "{", "String", "text", "=", "null", ";", "// Check the read method first", "if", "(", "mReadMethod", "!=", "null", ")", "{", "text", "=", "mReadMethod", ".", "getCommentText", "(", ")", ";", "}", "if", "(", "text", "==", "null", "&&", "mWriteMethod", "!=", "null", ")", "{", "// Try the write method", "text", "=", "mWriteMethod", ".", "getCommentText", "(", ")", ";", "}", "if", "(", "text", "==", "null", "||", "text", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "// Try the \"@return\" tag", "text", "=", "getTagValue", "(", "\"return\"", ")", ";", "}", "return", "text", ";", "}" ]
Checks both the read and write MethodDocs for a comment
[ "Checks", "both", "the", "read", "and", "write", "MethodDocs", "for", "a", "comment" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/PropertyDoc.java#L316-L335
230
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/util/RemoteCompilationProvider.java
RemoteCompilationProvider.createTemplateServerRequest
String createTemplateServerRequest(String servletPath,String templateName) { String pathInfo = servletPath.substring(servletPath.indexOf("/",TEMPLATE_LOAD_PROTOCOL.length())); if (templateName != null) { pathInfo = pathInfo + templateName; } return pathInfo; }
java
String createTemplateServerRequest(String servletPath,String templateName) { String pathInfo = servletPath.substring(servletPath.indexOf("/",TEMPLATE_LOAD_PROTOCOL.length())); if (templateName != null) { pathInfo = pathInfo + templateName; } return pathInfo; }
[ "String", "createTemplateServerRequest", "(", "String", "servletPath", ",", "String", "templateName", ")", "{", "String", "pathInfo", "=", "servletPath", ".", "substring", "(", "servletPath", ".", "indexOf", "(", "\"/\"", ",", "TEMPLATE_LOAD_PROTOCOL", ".", "length", "(", ")", ")", ")", ";", "if", "(", "templateName", "!=", "null", ")", "{", "pathInfo", "=", "pathInfo", "+", "templateName", ";", "}", "return", "pathInfo", ";", "}" ]
turns a template name and a servlet path into a
[ "turns", "a", "template", "name", "and", "a", "servlet", "path", "into", "a" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/util/RemoteCompilationProvider.java#L128-L134
231
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/util/RemoteCompilationProvider.java
RemoteCompilationProvider.retrieveTemplateMap
private Map<String, TemplateSourceInfo> retrieveTemplateMap() { Map<String, TemplateSourceInfo> templateMap = new TreeMap<String, TemplateSourceInfo>(); String remoteSource = mRemoteSourceDir; if (!remoteSource.endsWith("/")) { remoteSource = remoteSource + "/"; } try { HttpClient tsClient = getTemplateServerClient(remoteSource); HttpClient.Response response = tsClient.setURI(createTemplateServerRequest(remoteSource,null)) .setPersistent(true).getResponse(); if (response != null && response.getStatusCode() == 200) { Reader rin = new InputStreamReader (new BufferedInputStream(response.getInputStream())); StreamTokenizer st = new StreamTokenizer(rin); st.resetSyntax(); st.wordChars('!','{'); st.wordChars('}','}'); st.whitespaceChars(0,' '); st.parseNumbers(); st.quoteChar('|'); st.eolIsSignificant(true); String templateName = null; int tokenID = 0; // ditching the headers by looking for "\r\n\r\n" /* * no longer needed now that HttpClient is being used but leave * in for the moment. * * while (!((tokenID = st.nextToken()) == StreamTokenizer.TT_EOL * && st.nextToken() == StreamTokenizer.TT_EOL) * && tokenID != StreamTokenizer.TT_EOF) { * } */ while ((tokenID = st.nextToken()) != StreamTokenizer.TT_EOF) { if (tokenID == '|' || tokenID == StreamTokenizer.TT_WORD) { templateName = st.sval; } else if (tokenID == StreamTokenizer.TT_NUMBER && templateName != null) { templateName = templateName.substring(1); //System.out.println(templateName); templateMap.put(templateName.replace('/','.'), new TemplateSourceInfo( templateName, remoteSource, (long)st.nval)); templateName = null; } } } } catch (IOException ioe) { ioe.printStackTrace(); } return templateMap; }
java
private Map<String, TemplateSourceInfo> retrieveTemplateMap() { Map<String, TemplateSourceInfo> templateMap = new TreeMap<String, TemplateSourceInfo>(); String remoteSource = mRemoteSourceDir; if (!remoteSource.endsWith("/")) { remoteSource = remoteSource + "/"; } try { HttpClient tsClient = getTemplateServerClient(remoteSource); HttpClient.Response response = tsClient.setURI(createTemplateServerRequest(remoteSource,null)) .setPersistent(true).getResponse(); if (response != null && response.getStatusCode() == 200) { Reader rin = new InputStreamReader (new BufferedInputStream(response.getInputStream())); StreamTokenizer st = new StreamTokenizer(rin); st.resetSyntax(); st.wordChars('!','{'); st.wordChars('}','}'); st.whitespaceChars(0,' '); st.parseNumbers(); st.quoteChar('|'); st.eolIsSignificant(true); String templateName = null; int tokenID = 0; // ditching the headers by looking for "\r\n\r\n" /* * no longer needed now that HttpClient is being used but leave * in for the moment. * * while (!((tokenID = st.nextToken()) == StreamTokenizer.TT_EOL * && st.nextToken() == StreamTokenizer.TT_EOL) * && tokenID != StreamTokenizer.TT_EOF) { * } */ while ((tokenID = st.nextToken()) != StreamTokenizer.TT_EOF) { if (tokenID == '|' || tokenID == StreamTokenizer.TT_WORD) { templateName = st.sval; } else if (tokenID == StreamTokenizer.TT_NUMBER && templateName != null) { templateName = templateName.substring(1); //System.out.println(templateName); templateMap.put(templateName.replace('/','.'), new TemplateSourceInfo( templateName, remoteSource, (long)st.nval)); templateName = null; } } } } catch (IOException ioe) { ioe.printStackTrace(); } return templateMap; }
[ "private", "Map", "<", "String", ",", "TemplateSourceInfo", ">", "retrieveTemplateMap", "(", ")", "{", "Map", "<", "String", ",", "TemplateSourceInfo", ">", "templateMap", "=", "new", "TreeMap", "<", "String", ",", "TemplateSourceInfo", ">", "(", ")", ";", "String", "remoteSource", "=", "mRemoteSourceDir", ";", "if", "(", "!", "remoteSource", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "remoteSource", "=", "remoteSource", "+", "\"/\"", ";", "}", "try", "{", "HttpClient", "tsClient", "=", "getTemplateServerClient", "(", "remoteSource", ")", ";", "HttpClient", ".", "Response", "response", "=", "tsClient", ".", "setURI", "(", "createTemplateServerRequest", "(", "remoteSource", ",", "null", ")", ")", ".", "setPersistent", "(", "true", ")", ".", "getResponse", "(", ")", ";", "if", "(", "response", "!=", "null", "&&", "response", ".", "getStatusCode", "(", ")", "==", "200", ")", "{", "Reader", "rin", "=", "new", "InputStreamReader", "(", "new", "BufferedInputStream", "(", "response", ".", "getInputStream", "(", ")", ")", ")", ";", "StreamTokenizer", "st", "=", "new", "StreamTokenizer", "(", "rin", ")", ";", "st", ".", "resetSyntax", "(", ")", ";", "st", ".", "wordChars", "(", "'", "'", ",", "'", "'", ")", ";", "st", ".", "wordChars", "(", "'", "'", ",", "'", "'", ")", ";", "st", ".", "whitespaceChars", "(", "0", ",", "'", "'", ")", ";", "st", ".", "parseNumbers", "(", ")", ";", "st", ".", "quoteChar", "(", "'", "'", ")", ";", "st", ".", "eolIsSignificant", "(", "true", ")", ";", "String", "templateName", "=", "null", ";", "int", "tokenID", "=", "0", ";", "// ditching the headers by looking for \"\\r\\n\\r\\n\"", "/* \n * no longer needed now that HttpClient is being used but leave\n * in for the moment.\n *\n * while (!((tokenID = st.nextToken()) == StreamTokenizer.TT_EOL \n * && st.nextToken() == StreamTokenizer.TT_EOL) \n * && tokenID != StreamTokenizer.TT_EOF) {\n * }\n */", "while", "(", "(", "tokenID", "=", "st", ".", "nextToken", "(", ")", ")", "!=", "StreamTokenizer", ".", "TT_EOF", ")", "{", "if", "(", "tokenID", "==", "'", "'", "||", "tokenID", "==", "StreamTokenizer", ".", "TT_WORD", ")", "{", "templateName", "=", "st", ".", "sval", ";", "}", "else", "if", "(", "tokenID", "==", "StreamTokenizer", ".", "TT_NUMBER", "&&", "templateName", "!=", "null", ")", "{", "templateName", "=", "templateName", ".", "substring", "(", "1", ")", ";", "//System.out.println(templateName);", "templateMap", ".", "put", "(", "templateName", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ",", "new", "TemplateSourceInfo", "(", "templateName", ",", "remoteSource", ",", "(", "long", ")", "st", ".", "nval", ")", ")", ";", "templateName", "=", "null", ";", "}", "}", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "ioe", ".", "printStackTrace", "(", ")", ";", "}", "return", "templateMap", ";", "}" ]
creates a map relating the templates found on the template server to the timestamp on the sourcecode
[ "creates", "a", "map", "relating", "the", "templates", "found", "on", "the", "template", "server", "to", "the", "timestamp", "on", "the", "sourcecode" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/util/RemoteCompilationProvider.java#L140-L204
232
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/TypeDesc.java
TypeDesc.forClass
public synchronized static TypeDesc forClass(Class<?> clazz) { if (clazz == null) { return null; } TypeDesc type = cClassesToInstances.get(clazz); if (type != null) { return type; } if (clazz.isArray()) { type = forClass(clazz.getComponentType()).toArrayType(); } else if (clazz.isPrimitive()) { if (clazz == int.class) { type = INT; } if (clazz == boolean.class) { type = BOOLEAN; } if (clazz == char.class) { type = CHAR; } if (clazz == byte.class) { type = BYTE; } if (clazz == long.class) { type = LONG; } if (clazz == float.class) { type = FLOAT; } if (clazz == double.class) { type = DOUBLE; } if (clazz == short.class) { type = SHORT; } if (clazz == void.class) { type = VOID; } } else { String name = clazz.getName(); type = intern(new ObjectType(generateDescriptor(name), name)); } cClassesToInstances.put(clazz, type); return type; }
java
public synchronized static TypeDesc forClass(Class<?> clazz) { if (clazz == null) { return null; } TypeDesc type = cClassesToInstances.get(clazz); if (type != null) { return type; } if (clazz.isArray()) { type = forClass(clazz.getComponentType()).toArrayType(); } else if (clazz.isPrimitive()) { if (clazz == int.class) { type = INT; } if (clazz == boolean.class) { type = BOOLEAN; } if (clazz == char.class) { type = CHAR; } if (clazz == byte.class) { type = BYTE; } if (clazz == long.class) { type = LONG; } if (clazz == float.class) { type = FLOAT; } if (clazz == double.class) { type = DOUBLE; } if (clazz == short.class) { type = SHORT; } if (clazz == void.class) { type = VOID; } } else { String name = clazz.getName(); type = intern(new ObjectType(generateDescriptor(name), name)); } cClassesToInstances.put(clazz, type); return type; }
[ "public", "synchronized", "static", "TypeDesc", "forClass", "(", "Class", "<", "?", ">", "clazz", ")", "{", "if", "(", "clazz", "==", "null", ")", "{", "return", "null", ";", "}", "TypeDesc", "type", "=", "cClassesToInstances", ".", "get", "(", "clazz", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "return", "type", ";", "}", "if", "(", "clazz", ".", "isArray", "(", ")", ")", "{", "type", "=", "forClass", "(", "clazz", ".", "getComponentType", "(", ")", ")", ".", "toArrayType", "(", ")", ";", "}", "else", "if", "(", "clazz", ".", "isPrimitive", "(", ")", ")", "{", "if", "(", "clazz", "==", "int", ".", "class", ")", "{", "type", "=", "INT", ";", "}", "if", "(", "clazz", "==", "boolean", ".", "class", ")", "{", "type", "=", "BOOLEAN", ";", "}", "if", "(", "clazz", "==", "char", ".", "class", ")", "{", "type", "=", "CHAR", ";", "}", "if", "(", "clazz", "==", "byte", ".", "class", ")", "{", "type", "=", "BYTE", ";", "}", "if", "(", "clazz", "==", "long", ".", "class", ")", "{", "type", "=", "LONG", ";", "}", "if", "(", "clazz", "==", "float", ".", "class", ")", "{", "type", "=", "FLOAT", ";", "}", "if", "(", "clazz", "==", "double", ".", "class", ")", "{", "type", "=", "DOUBLE", ";", "}", "if", "(", "clazz", "==", "short", ".", "class", ")", "{", "type", "=", "SHORT", ";", "}", "if", "(", "clazz", "==", "void", ".", "class", ")", "{", "type", "=", "VOID", ";", "}", "}", "else", "{", "String", "name", "=", "clazz", ".", "getName", "(", ")", ";", "type", "=", "intern", "(", "new", "ObjectType", "(", "generateDescriptor", "(", "name", ")", ",", "name", ")", ")", ";", "}", "cClassesToInstances", ".", "put", "(", "clazz", ",", "type", ")", ";", "return", "type", ";", "}" ]
Acquire a TypeDesc from any class, including primitives and arrays.
[ "Acquire", "a", "TypeDesc", "from", "any", "class", "including", "primitives", "and", "arrays", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/TypeDesc.java#L225-L274
233
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/TypeDesc.java
TypeDesc.forDescriptor
public static TypeDesc forDescriptor(String desc) throws IllegalArgumentException { // TODO: Figure out how to cache these. Using a plain IdentityMap poses // a problem. The back reference to the key causes a memory leak. TypeDesc td; int cursor = 0; int dim = 0; try { char c; while ((c = desc.charAt(cursor++)) == '[') { dim++; } switch (c) { case 'V': td = VOID; break; case 'Z': td = BOOLEAN; break; case 'C': td = CHAR; break; case 'B': td = BYTE; break; case 'S': td = SHORT; break; case 'I': td = INT; break; case 'J': td = LONG; break; case 'F': td = FLOAT; break; case 'D': td = DOUBLE; break; case 'L': if (dim > 0) { desc = desc.substring(dim); cursor = 1; } StringBuffer name = new StringBuffer(desc.length() - 2); while ((c = desc.charAt(cursor++)) != ';') { if (c == '/') { c = '.'; } name.append(c); } td = intern(new ObjectType(desc, name.toString())); break; default: throw invalidDescriptor(desc); } } catch (NullPointerException e) { throw invalidDescriptor(desc); } catch (IndexOutOfBoundsException e) { throw invalidDescriptor(desc); } if (cursor != desc.length()) { throw invalidDescriptor(desc); } while (--dim >= 0) { td = td.toArrayType(); } return td; }
java
public static TypeDesc forDescriptor(String desc) throws IllegalArgumentException { // TODO: Figure out how to cache these. Using a plain IdentityMap poses // a problem. The back reference to the key causes a memory leak. TypeDesc td; int cursor = 0; int dim = 0; try { char c; while ((c = desc.charAt(cursor++)) == '[') { dim++; } switch (c) { case 'V': td = VOID; break; case 'Z': td = BOOLEAN; break; case 'C': td = CHAR; break; case 'B': td = BYTE; break; case 'S': td = SHORT; break; case 'I': td = INT; break; case 'J': td = LONG; break; case 'F': td = FLOAT; break; case 'D': td = DOUBLE; break; case 'L': if (dim > 0) { desc = desc.substring(dim); cursor = 1; } StringBuffer name = new StringBuffer(desc.length() - 2); while ((c = desc.charAt(cursor++)) != ';') { if (c == '/') { c = '.'; } name.append(c); } td = intern(new ObjectType(desc, name.toString())); break; default: throw invalidDescriptor(desc); } } catch (NullPointerException e) { throw invalidDescriptor(desc); } catch (IndexOutOfBoundsException e) { throw invalidDescriptor(desc); } if (cursor != desc.length()) { throw invalidDescriptor(desc); } while (--dim >= 0) { td = td.toArrayType(); } return td; }
[ "public", "static", "TypeDesc", "forDescriptor", "(", "String", "desc", ")", "throws", "IllegalArgumentException", "{", "// TODO: Figure out how to cache these. Using a plain IdentityMap poses", "// a problem. The back reference to the key causes a memory leak.", "TypeDesc", "td", ";", "int", "cursor", "=", "0", ";", "int", "dim", "=", "0", ";", "try", "{", "char", "c", ";", "while", "(", "(", "c", "=", "desc", ".", "charAt", "(", "cursor", "++", ")", ")", "==", "'", "'", ")", "{", "dim", "++", ";", "}", "switch", "(", "c", ")", "{", "case", "'", "'", ":", "td", "=", "VOID", ";", "break", ";", "case", "'", "'", ":", "td", "=", "BOOLEAN", ";", "break", ";", "case", "'", "'", ":", "td", "=", "CHAR", ";", "break", ";", "case", "'", "'", ":", "td", "=", "BYTE", ";", "break", ";", "case", "'", "'", ":", "td", "=", "SHORT", ";", "break", ";", "case", "'", "'", ":", "td", "=", "INT", ";", "break", ";", "case", "'", "'", ":", "td", "=", "LONG", ";", "break", ";", "case", "'", "'", ":", "td", "=", "FLOAT", ";", "break", ";", "case", "'", "'", ":", "td", "=", "DOUBLE", ";", "break", ";", "case", "'", "'", ":", "if", "(", "dim", ">", "0", ")", "{", "desc", "=", "desc", ".", "substring", "(", "dim", ")", ";", "cursor", "=", "1", ";", "}", "StringBuffer", "name", "=", "new", "StringBuffer", "(", "desc", ".", "length", "(", ")", "-", "2", ")", ";", "while", "(", "(", "c", "=", "desc", ".", "charAt", "(", "cursor", "++", ")", ")", "!=", "'", "'", ")", "{", "if", "(", "c", "==", "'", "'", ")", "{", "c", "=", "'", "'", ";", "}", "name", ".", "append", "(", "c", ")", ";", "}", "td", "=", "intern", "(", "new", "ObjectType", "(", "desc", ",", "name", ".", "toString", "(", ")", ")", ")", ";", "break", ";", "default", ":", "throw", "invalidDescriptor", "(", "desc", ")", ";", "}", "}", "catch", "(", "NullPointerException", "e", ")", "{", "throw", "invalidDescriptor", "(", "desc", ")", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "throw", "invalidDescriptor", "(", "desc", ")", ";", "}", "if", "(", "cursor", "!=", "desc", ".", "length", "(", ")", ")", "{", "throw", "invalidDescriptor", "(", "desc", ")", ";", "}", "while", "(", "--", "dim", ">=", "0", ")", "{", "td", "=", "td", ".", "toArrayType", "(", ")", ";", "}", "return", "td", ";", "}" ]
Acquire a TypeDesc from a type descriptor. This syntax is described in section 4.3.2, Field Descriptors.
[ "Acquire", "a", "TypeDesc", "from", "a", "type", "descriptor", ".", "This", "syntax", "is", "described", "in", "section", "4", ".", "3", ".", "2", "Field", "Descriptors", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/TypeDesc.java#L377-L454
234
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/engine/ContextCreationException.java
ContextCreationException.getMessage
public String getMessage() { Throwable rock = getUndeclaredThrowable(); if (rock != null) { return rock.getMessage(); } else { return super.getMessage(); } }
java
public String getMessage() { Throwable rock = getUndeclaredThrowable(); if (rock != null) { return rock.getMessage(); } else { return super.getMessage(); } }
[ "public", "String", "getMessage", "(", ")", "{", "Throwable", "rock", "=", "getUndeclaredThrowable", "(", ")", ";", "if", "(", "rock", "!=", "null", ")", "{", "return", "rock", ".", "getMessage", "(", ")", ";", "}", "else", "{", "return", "super", ".", "getMessage", "(", ")", ";", "}", "}" ]
overridden Throwable methods
[ "overridden", "Throwable", "methods" ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/engine/ContextCreationException.java#L44-L52
235
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/ConstantClassInfo.java
ConstantClassInfo.make
static ConstantClassInfo make(ConstantPool cp, String className, int dim) { ConstantInfo ci = new ConstantClassInfo(cp, className, dim); return (ConstantClassInfo)cp.addConstant(ci); }
java
static ConstantClassInfo make(ConstantPool cp, String className, int dim) { ConstantInfo ci = new ConstantClassInfo(cp, className, dim); return (ConstantClassInfo)cp.addConstant(ci); }
[ "static", "ConstantClassInfo", "make", "(", "ConstantPool", "cp", ",", "String", "className", ",", "int", "dim", ")", "{", "ConstantInfo", "ci", "=", "new", "ConstantClassInfo", "(", "cp", ",", "className", ",", "dim", ")", ";", "return", "(", "ConstantClassInfo", ")", "cp", ".", "addConstant", "(", "ci", ")", ";", "}" ]
Used to describe an array class.
[ "Used", "to", "describe", "an", "array", "class", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ConstantClassInfo.java#L42-L45
236
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/management/HttpContextManagement.java
HttpContextManagement.addReadUrl
public void addReadUrl(String url) { // // Only cache the url data if logging is enabled. // if (readUrlLoggingEnabled == false) { return; } // // Strip off the query parameters. // int paramIndex = url.indexOf('?'); String filteredUrl = url; if (paramIndex != -1) { filteredUrl = url.substring(0, paramIndex); } // // Because Cache doesn't take advantage of the underlying concurrentMap, this code either has to (1)introduce // sync block to synchronize addReadUrl requests which would negatively impact all templates calling addReadUrl // or (2) accept potential race condition during the first add call on the same Url. This implementation takes // (2) approach as this feature is more for reporting and hence not worth the performance degradation . Also, // once the first record is added to the map, the race condition no longer exists due to the use of atomic // variable. // AtomicLong count = (AtomicLong)__UrlMap.get(filteredUrl); if (count == null) { count = new AtomicLong(1); __UrlMap.put(filteredUrl, count); } else { count.incrementAndGet(); } }
java
public void addReadUrl(String url) { // // Only cache the url data if logging is enabled. // if (readUrlLoggingEnabled == false) { return; } // // Strip off the query parameters. // int paramIndex = url.indexOf('?'); String filteredUrl = url; if (paramIndex != -1) { filteredUrl = url.substring(0, paramIndex); } // // Because Cache doesn't take advantage of the underlying concurrentMap, this code either has to (1)introduce // sync block to synchronize addReadUrl requests which would negatively impact all templates calling addReadUrl // or (2) accept potential race condition during the first add call on the same Url. This implementation takes // (2) approach as this feature is more for reporting and hence not worth the performance degradation . Also, // once the first record is added to the map, the race condition no longer exists due to the use of atomic // variable. // AtomicLong count = (AtomicLong)__UrlMap.get(filteredUrl); if (count == null) { count = new AtomicLong(1); __UrlMap.put(filteredUrl, count); } else { count.incrementAndGet(); } }
[ "public", "void", "addReadUrl", "(", "String", "url", ")", "{", "//", "// Only cache the url data if logging is enabled.", "//", "if", "(", "readUrlLoggingEnabled", "==", "false", ")", "{", "return", ";", "}", "//", "// Strip off the query parameters.", "//", "int", "paramIndex", "=", "url", ".", "indexOf", "(", "'", "'", ")", ";", "String", "filteredUrl", "=", "url", ";", "if", "(", "paramIndex", "!=", "-", "1", ")", "{", "filteredUrl", "=", "url", ".", "substring", "(", "0", ",", "paramIndex", ")", ";", "}", "//", "// Because Cache doesn't take advantage of the underlying concurrentMap, this code either has to (1)introduce ", "// sync block to synchronize addReadUrl requests which would negatively impact all templates calling addReadUrl", "// or (2) accept potential race condition during the first add call on the same Url. This implementation takes", "// (2) approach as this feature is more for reporting and hence not worth the performance degradation . Also, ", "// once the first record is added to the map, the race condition no longer exists due to the use of atomic ", "// variable.", "// ", "AtomicLong", "count", "=", "(", "AtomicLong", ")", "__UrlMap", ".", "get", "(", "filteredUrl", ")", ";", "if", "(", "count", "==", "null", ")", "{", "count", "=", "new", "AtomicLong", "(", "1", ")", ";", "__UrlMap", ".", "put", "(", "filteredUrl", ",", "count", ")", ";", "}", "else", "{", "count", ".", "incrementAndGet", "(", ")", ";", "}", "}" ]
Adds the URL to the list if it doesn't already exist. Or increment the hit count otherwise. @param url The URL requested.
[ "Adds", "the", "URL", "to", "the", "list", "if", "it", "doesn", "t", "already", "exist", ".", "Or", "increment", "the", "hit", "count", "otherwise", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/management/HttpContextManagement.java#L108-L145
237
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.getChildren
public Scope[] getChildren() { if (mChildren == null) { return new Scope[0]; } else { return mChildren.toArray(new Scope[mChildren.size()]); } }
java
public Scope[] getChildren() { if (mChildren == null) { return new Scope[0]; } else { return mChildren.toArray(new Scope[mChildren.size()]); } }
[ "public", "Scope", "[", "]", "getChildren", "(", ")", "{", "if", "(", "mChildren", "==", "null", ")", "{", "return", "new", "Scope", "[", "0", "]", ";", "}", "else", "{", "return", "mChildren", ".", "toArray", "(", "new", "Scope", "[", "mChildren", ".", "size", "(", ")", "]", ")", ";", "}", "}" ]
Returns an empty array if this scope has no children.
[ "Returns", "an", "empty", "array", "if", "this", "scope", "has", "no", "children", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L81-L88
238
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.declareVariable
public Variable declareVariable(Variable var, boolean isPrivate) { if (mVariables.containsKey(var)) { var = mVariables.get(var); } else { mVariables.put(var, var); } mDeclared.put(var.getName(), var); if (isPrivate) { if (mPrivateVars == null) { mPrivateVars = new HashSet<Variable>(7); } mPrivateVars.add(var); } else { if (mPrivateVars != null) { mPrivateVars.remove(var); } } return var; }
java
public Variable declareVariable(Variable var, boolean isPrivate) { if (mVariables.containsKey(var)) { var = mVariables.get(var); } else { mVariables.put(var, var); } mDeclared.put(var.getName(), var); if (isPrivate) { if (mPrivateVars == null) { mPrivateVars = new HashSet<Variable>(7); } mPrivateVars.add(var); } else { if (mPrivateVars != null) { mPrivateVars.remove(var); } } return var; }
[ "public", "Variable", "declareVariable", "(", "Variable", "var", ",", "boolean", "isPrivate", ")", "{", "if", "(", "mVariables", ".", "containsKey", "(", "var", ")", ")", "{", "var", "=", "mVariables", ".", "get", "(", "var", ")", ";", "}", "else", "{", "mVariables", ".", "put", "(", "var", ",", "var", ")", ";", "}", "mDeclared", ".", "put", "(", "var", ".", "getName", "(", ")", ",", "var", ")", ";", "if", "(", "isPrivate", ")", "{", "if", "(", "mPrivateVars", "==", "null", ")", "{", "mPrivateVars", "=", "new", "HashSet", "<", "Variable", ">", "(", "7", ")", ";", "}", "mPrivateVars", ".", "add", "(", "var", ")", ";", "}", "else", "{", "if", "(", "mPrivateVars", "!=", "null", ")", "{", "mPrivateVars", ".", "remove", "(", "var", ")", ";", "}", "}", "return", "var", ";", "}" ]
Declare a variable for use in this scope. If no variable of this name and type has been defined, it is added to the shared set of pooled variables. Returns the actual Variable object that should be used instead. @param isPrivate when true, variable declaration doesn't leave this scope during an intersection or promotion
[ "Declare", "a", "variable", "for", "use", "in", "this", "scope", ".", "If", "no", "variable", "of", "this", "name", "and", "type", "has", "been", "defined", "it", "is", "added", "to", "the", "shared", "set", "of", "pooled", "variables", ".", "Returns", "the", "actual", "Variable", "object", "that", "should", "be", "used", "instead", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L108-L131
239
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.declareVariables
public void declareVariables(Variable[] vars) { for (int i=0; i<vars.length; i++) { vars[i] = declareVariable(vars[i]); } }
java
public void declareVariables(Variable[] vars) { for (int i=0; i<vars.length; i++) { vars[i] = declareVariable(vars[i]); } }
[ "public", "void", "declareVariables", "(", "Variable", "[", "]", "vars", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "vars", ".", "length", ";", "i", "++", ")", "{", "vars", "[", "i", "]", "=", "declareVariable", "(", "vars", "[", "i", "]", ")", ";", "}", "}" ]
Declare new variables in this scope. Entries in the array are replaced with actual Variable objects that should be used instead.
[ "Declare", "new", "variables", "in", "this", "scope", ".", "Entries", "in", "the", "array", "are", "replaced", "with", "actual", "Variable", "objects", "that", "should", "be", "used", "instead", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L137-L141
240
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.getDeclaredVariable
public Variable getDeclaredVariable(String name, boolean publicOnly) { //private Set mPrivateVars; Variable var = mDeclared.get(name); if (var != null) { // If its okay to be private or its public then... if (!publicOnly || mPrivateVars == null || !mPrivateVars.contains(var)) { return var; } } if (mParent != null) { return mParent.getDeclaredVariable(name); } return null; }
java
public Variable getDeclaredVariable(String name, boolean publicOnly) { //private Set mPrivateVars; Variable var = mDeclared.get(name); if (var != null) { // If its okay to be private or its public then... if (!publicOnly || mPrivateVars == null || !mPrivateVars.contains(var)) { return var; } } if (mParent != null) { return mParent.getDeclaredVariable(name); } return null; }
[ "public", "Variable", "getDeclaredVariable", "(", "String", "name", ",", "boolean", "publicOnly", ")", "{", "//private Set mPrivateVars;", "Variable", "var", "=", "mDeclared", ".", "get", "(", "name", ")", ";", "if", "(", "var", "!=", "null", ")", "{", "// If its okay to be private or its public then...", "if", "(", "!", "publicOnly", "||", "mPrivateVars", "==", "null", "||", "!", "mPrivateVars", ".", "contains", "(", "var", ")", ")", "{", "return", "var", ";", "}", "}", "if", "(", "mParent", "!=", "null", ")", "{", "return", "mParent", ".", "getDeclaredVariable", "(", "name", ")", ";", "}", "return", "null", ";", "}" ]
Returns a declared variable by name. Search begins in this scope and moves up into parent scopes. If not found, null is returned. A public- only variable can be requested. @return Null if no declared variable found with the given name
[ "Returns", "a", "declared", "variable", "by", "name", ".", "Search", "begins", "in", "this", "scope", "and", "moves", "up", "into", "parent", "scopes", ".", "If", "not", "found", "null", "is", "returned", ".", "A", "public", "-", "only", "variable", "can", "be", "requested", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L161-L178
241
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.getLocallyDeclaredVariables
private Variable[] getLocallyDeclaredVariables() { Collection<Variable> vars = mDeclared.values(); return vars.toArray(new Variable[vars.size()]); }
java
private Variable[] getLocallyDeclaredVariables() { Collection<Variable> vars = mDeclared.values(); return vars.toArray(new Variable[vars.size()]); }
[ "private", "Variable", "[", "]", "getLocallyDeclaredVariables", "(", ")", "{", "Collection", "<", "Variable", ">", "vars", "=", "mDeclared", ".", "values", "(", ")", ";", "return", "vars", ".", "toArray", "(", "new", "Variable", "[", "vars", ".", "size", "(", ")", "]", ")", ";", "}" ]
Returns all the variables declared in this scope. @return non-null array of locally declared variables
[ "Returns", "all", "the", "variables", "declared", "in", "this", "scope", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L185-L188
242
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.bindToVariable
public boolean bindToVariable(VariableRef ref) { String name = ref.getName(); Variable var = getDeclaredVariable(name); if (var != null) { ref.setType(null); ref.setVariable(var); mVariableRefs.add(ref); return true; } else { return false; } }
java
public boolean bindToVariable(VariableRef ref) { String name = ref.getName(); Variable var = getDeclaredVariable(name); if (var != null) { ref.setType(null); ref.setVariable(var); mVariableRefs.add(ref); return true; } else { return false; } }
[ "public", "boolean", "bindToVariable", "(", "VariableRef", "ref", ")", "{", "String", "name", "=", "ref", ".", "getName", "(", ")", ";", "Variable", "var", "=", "getDeclaredVariable", "(", "name", ")", ";", "if", "(", "var", "!=", "null", ")", "{", "ref", ".", "setType", "(", "null", ")", ";", "ref", ".", "setVariable", "(", "var", ")", ";", "mVariableRefs", ".", "add", "(", "ref", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Attempt to bind variable reference to a variable in this scope or a parent scope. If the variable to bind to isn't available or doesn't exist, false is returned. @return true if reference has been bound
[ "Attempt", "to", "bind", "variable", "reference", "to", "a", "variable", "in", "this", "scope", "or", "a", "parent", "scope", ".", "If", "the", "variable", "to", "bind", "to", "isn", "t", "available", "or", "doesn", "t", "exist", "false", "is", "returned", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L197-L210
243
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.getVariableRefs
public VariableRef[] getVariableRefs() { Collection<VariableRef> allRefs = new ArrayList<VariableRef>(); fillVariableRefs(allRefs, this); return allRefs.toArray(new VariableRef[allRefs.size()]); }
java
public VariableRef[] getVariableRefs() { Collection<VariableRef> allRefs = new ArrayList<VariableRef>(); fillVariableRefs(allRefs, this); return allRefs.toArray(new VariableRef[allRefs.size()]); }
[ "public", "VariableRef", "[", "]", "getVariableRefs", "(", ")", "{", "Collection", "<", "VariableRef", ">", "allRefs", "=", "new", "ArrayList", "<", "VariableRef", ">", "(", ")", ";", "fillVariableRefs", "(", "allRefs", ",", "this", ")", ";", "return", "allRefs", ".", "toArray", "(", "new", "VariableRef", "[", "allRefs", ".", "size", "(", ")", "]", ")", ";", "}" ]
Returns all the variable references made from this scope and all child scopes. @return non-null array of VariableRefs.
[ "Returns", "all", "the", "variable", "references", "made", "from", "this", "scope", "and", "all", "child", "scopes", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L218-L222
244
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.getLocalVariableRefs
public VariableRef[] getLocalVariableRefs() { VariableRef[] refs = new VariableRef[mVariableRefs.size()]; return mVariableRefs.toArray(refs); }
java
public VariableRef[] getLocalVariableRefs() { VariableRef[] refs = new VariableRef[mVariableRefs.size()]; return mVariableRefs.toArray(refs); }
[ "public", "VariableRef", "[", "]", "getLocalVariableRefs", "(", ")", "{", "VariableRef", "[", "]", "refs", "=", "new", "VariableRef", "[", "mVariableRefs", ".", "size", "(", ")", "]", ";", "return", "mVariableRefs", ".", "toArray", "(", "refs", ")", ";", "}" ]
Returns all the references made from this scope to variables declared in this scope or in a parent. @return non-null array of VariableRefs.
[ "Returns", "all", "the", "references", "made", "from", "this", "scope", "to", "variables", "declared", "in", "this", "scope", "or", "in", "a", "parent", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L243-L246
245
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.getOutOfScopeVariableRefs
public VariableRef[] getOutOfScopeVariableRefs() { Scope parent; if ((parent = getParent()) == null) { return new VariableRef[0]; } Collection<VariableRef> allRefs = new ArrayList<VariableRef>(); fillVariableRefs(allRefs, this); Collection<VariableRef> refs = new ArrayList<VariableRef>(allRefs.size()); Iterator<VariableRef> it = allRefs.iterator(); while (it.hasNext()) { VariableRef ref = it.next(); Variable var = ref.getVariable(); if (var != null && parent.getDeclaredVariable(var.getName()) == var) { refs.add(ref); } } VariableRef[] refsArray = new VariableRef[refs.size()]; return refs.toArray(refsArray); }
java
public VariableRef[] getOutOfScopeVariableRefs() { Scope parent; if ((parent = getParent()) == null) { return new VariableRef[0]; } Collection<VariableRef> allRefs = new ArrayList<VariableRef>(); fillVariableRefs(allRefs, this); Collection<VariableRef> refs = new ArrayList<VariableRef>(allRefs.size()); Iterator<VariableRef> it = allRefs.iterator(); while (it.hasNext()) { VariableRef ref = it.next(); Variable var = ref.getVariable(); if (var != null && parent.getDeclaredVariable(var.getName()) == var) { refs.add(ref); } } VariableRef[] refsArray = new VariableRef[refs.size()]; return refs.toArray(refsArray); }
[ "public", "VariableRef", "[", "]", "getOutOfScopeVariableRefs", "(", ")", "{", "Scope", "parent", ";", "if", "(", "(", "parent", "=", "getParent", "(", ")", ")", "==", "null", ")", "{", "return", "new", "VariableRef", "[", "0", "]", ";", "}", "Collection", "<", "VariableRef", ">", "allRefs", "=", "new", "ArrayList", "<", "VariableRef", ">", "(", ")", ";", "fillVariableRefs", "(", "allRefs", ",", "this", ")", ";", "Collection", "<", "VariableRef", ">", "refs", "=", "new", "ArrayList", "<", "VariableRef", ">", "(", "allRefs", ".", "size", "(", ")", ")", ";", "Iterator", "<", "VariableRef", ">", "it", "=", "allRefs", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "VariableRef", "ref", "=", "it", ".", "next", "(", ")", ";", "Variable", "var", "=", "ref", ".", "getVariable", "(", ")", ";", "if", "(", "var", "!=", "null", "&&", "parent", ".", "getDeclaredVariable", "(", "var", ".", "getName", "(", ")", ")", "==", "var", ")", "{", "refs", ".", "add", "(", "ref", ")", ";", "}", "}", "VariableRef", "[", "]", "refsArray", "=", "new", "VariableRef", "[", "refs", ".", "size", "(", ")", "]", ";", "return", "refs", ".", "toArray", "(", "refsArray", ")", ";", "}" ]
Returns all the references made from this scope and all child scopes to variables declared outside of this scope.
[ "Returns", "all", "the", "references", "made", "from", "this", "scope", "and", "all", "child", "scopes", "to", "variables", "declared", "outside", "of", "this", "scope", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L252-L276
246
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.isEnclosing
public boolean isEnclosing(Scope scope) { for (; scope != null; scope = scope.getParent()) { if (this == scope) { return true; } } return false; }
java
public boolean isEnclosing(Scope scope) { for (; scope != null; scope = scope.getParent()) { if (this == scope) { return true; } } return false; }
[ "public", "boolean", "isEnclosing", "(", "Scope", "scope", ")", "{", "for", "(", ";", "scope", "!=", "null", ";", "scope", "=", "scope", ".", "getParent", "(", ")", ")", "{", "if", "(", "this", "==", "scope", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if this scope is the same as or a parent of the one given.
[ "Returns", "true", "if", "this", "scope", "is", "the", "same", "as", "or", "a", "parent", "of", "the", "one", "given", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L308-L315
247
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Scope.java
Scope.getEnclosingScope
public Scope getEnclosingScope(Scope scope) { for (Scope s = this; s != null; s = s.getParent()) { if (s.isEnclosing(scope)) { return s; } } return null; }
java
public Scope getEnclosingScope(Scope scope) { for (Scope s = this; s != null; s = s.getParent()) { if (s.isEnclosing(scope)) { return s; } } return null; }
[ "public", "Scope", "getEnclosingScope", "(", "Scope", "scope", ")", "{", "for", "(", "Scope", "s", "=", "this", ";", "s", "!=", "null", ";", "s", "=", "s", ".", "getParent", "(", ")", ")", "{", "if", "(", "s", ".", "isEnclosing", "(", "scope", ")", ")", "{", "return", "s", ";", "}", "}", "return", "null", ";", "}" ]
Returns the innermost enclosing scope of this and the one given. If no enclosing scope exists, null is returned.
[ "Returns", "the", "innermost", "enclosing", "scope", "of", "this", "and", "the", "one", "given", ".", "If", "no", "enclosing", "scope", "exists", "null", "is", "returned", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Scope.java#L321-L328
248
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.hasPrimitivePeer
public boolean hasPrimitivePeer() { if (mObjectClass == Integer.class || mObjectClass == Boolean.class || mObjectClass == Byte.class || mObjectClass == Character.class || mObjectClass == Short.class || mObjectClass == Long.class || mObjectClass == Float.class || mObjectClass == Double.class || mObjectClass == Void.class) { return true; } return false; }
java
public boolean hasPrimitivePeer() { if (mObjectClass == Integer.class || mObjectClass == Boolean.class || mObjectClass == Byte.class || mObjectClass == Character.class || mObjectClass == Short.class || mObjectClass == Long.class || mObjectClass == Float.class || mObjectClass == Double.class || mObjectClass == Void.class) { return true; } return false; }
[ "public", "boolean", "hasPrimitivePeer", "(", ")", "{", "if", "(", "mObjectClass", "==", "Integer", ".", "class", "||", "mObjectClass", "==", "Boolean", ".", "class", "||", "mObjectClass", "==", "Byte", ".", "class", "||", "mObjectClass", "==", "Character", ".", "class", "||", "mObjectClass", "==", "Short", ".", "class", "||", "mObjectClass", "==", "Long", ".", "class", "||", "mObjectClass", "==", "Float", ".", "class", "||", "mObjectClass", "==", "Double", ".", "class", "||", "mObjectClass", "==", "Void", ".", "class", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if this type is not primitive, but it has a primitive type peer.
[ "Returns", "true", "if", "this", "type", "is", "not", "primitive", "but", "it", "has", "a", "primitive", "type", "peer", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L230-L245
249
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.toPrimitive
public Type toPrimitive() { if (mPrimitive) { return this; } else { Class<?> primitive = convertToPrimitive(mObjectClass); if (primitive.isPrimitive()) { return new Type(primitive); } else { return new Type(mGenericType, primitive); } } }
java
public Type toPrimitive() { if (mPrimitive) { return this; } else { Class<?> primitive = convertToPrimitive(mObjectClass); if (primitive.isPrimitive()) { return new Type(primitive); } else { return new Type(mGenericType, primitive); } } }
[ "public", "Type", "toPrimitive", "(", ")", "{", "if", "(", "mPrimitive", ")", "{", "return", "this", ";", "}", "else", "{", "Class", "<", "?", ">", "primitive", "=", "convertToPrimitive", "(", "mObjectClass", ")", ";", "if", "(", "primitive", ".", "isPrimitive", "(", ")", ")", "{", "return", "new", "Type", "(", "primitive", ")", ";", "}", "else", "{", "return", "new", "Type", "(", "mGenericType", ",", "primitive", ")", ";", "}", "}", "}" ]
Returns a new type from this one that represents a primitive type. If this type cannot be represented by a primitive, then this is returned.
[ "Returns", "a", "new", "type", "from", "this", "one", "that", "represents", "a", "primitive", "type", ".", "If", "this", "type", "cannot", "be", "represented", "by", "a", "primitive", "then", "this", "is", "returned", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L252-L261
250
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.toNonNull
public Type toNonNull() { if (isNonNull()) { return this; } else { return new Type(this) { private static final long serialVersionUID = 1L; public boolean isNonNull() { return true; } public boolean isNullable() { return false; } public Type toNullable() { return Type.this; } }; } }
java
public Type toNonNull() { if (isNonNull()) { return this; } else { return new Type(this) { private static final long serialVersionUID = 1L; public boolean isNonNull() { return true; } public boolean isNullable() { return false; } public Type toNullable() { return Type.this; } }; } }
[ "public", "Type", "toNonNull", "(", ")", "{", "if", "(", "isNonNull", "(", ")", ")", "{", "return", "this", ";", "}", "else", "{", "return", "new", "Type", "(", "this", ")", "{", "private", "static", "final", "long", "serialVersionUID", "=", "1L", ";", "public", "boolean", "isNonNull", "(", ")", "{", "return", "true", ";", "}", "public", "boolean", "isNullable", "(", ")", "{", "return", "false", ";", "}", "public", "Type", "toNullable", "(", ")", "{", "return", "Type", ".", "this", ";", "}", "}", ";", "}", "}" ]
Returns this type converted such that it cannot reference null.
[ "Returns", "this", "type", "converted", "such", "that", "it", "cannot", "reference", "null", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L297-L318
251
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.getArrayIndexTypes
public Type[] getArrayIndexTypes() throws IntrospectionException { if (!mCheckedForArrayLookup) { checkForArrayLookup(); } return mArrayIndexTypes == null ? null : (Type[])mArrayIndexTypes.clone(); }
java
public Type[] getArrayIndexTypes() throws IntrospectionException { if (!mCheckedForArrayLookup) { checkForArrayLookup(); } return mArrayIndexTypes == null ? null : (Type[])mArrayIndexTypes.clone(); }
[ "public", "Type", "[", "]", "getArrayIndexTypes", "(", ")", "throws", "IntrospectionException", "{", "if", "(", "!", "mCheckedForArrayLookup", ")", "{", "checkForArrayLookup", "(", ")", ";", "}", "return", "mArrayIndexTypes", "==", "null", "?", "null", ":", "(", "Type", "[", "]", ")", "mArrayIndexTypes", ".", "clone", "(", ")", ";", "}" ]
If this Type supports array lookup, then return the index type. Because the index type may be overloaded, an array is returned. Null is returned if this Type doesn't support array lookup.
[ "If", "this", "Type", "supports", "array", "lookup", "then", "return", "the", "index", "type", ".", "Because", "the", "index", "type", "may", "be", "overloaded", "an", "array", "is", "returned", ".", "Null", "is", "returned", "if", "this", "Type", "doesn", "t", "support", "array", "lookup", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L353-L360
252
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.getArrayAccessMethods
public Method[] getArrayAccessMethods() throws IntrospectionException { if (!mCheckedForArrayLookup) { checkForArrayLookup(); } return mArrayAccessMethods == null ? null : (Method[])mArrayAccessMethods.clone(); }
java
public Method[] getArrayAccessMethods() throws IntrospectionException { if (!mCheckedForArrayLookup) { checkForArrayLookup(); } return mArrayAccessMethods == null ? null : (Method[])mArrayAccessMethods.clone(); }
[ "public", "Method", "[", "]", "getArrayAccessMethods", "(", ")", "throws", "IntrospectionException", "{", "if", "(", "!", "mCheckedForArrayLookup", ")", "{", "checkForArrayLookup", "(", ")", ";", "}", "return", "mArrayAccessMethods", "==", "null", "?", "null", ":", "(", "Method", "[", "]", ")", "mArrayAccessMethods", ".", "clone", "(", ")", ";", "}" ]
If this Type supports array lookup, then return all of the methods that can be called to access the array. If there are no methods, then an empty array is returned. Null is returned only if this Type doesn't support array lookup.
[ "If", "this", "Type", "supports", "array", "lookup", "then", "return", "all", "of", "the", "methods", "that", "can", "be", "called", "to", "access", "the", "array", ".", "If", "there", "are", "no", "methods", "then", "an", "empty", "array", "is", "returned", ".", "Null", "is", "returned", "only", "if", "this", "Type", "doesn", "t", "support", "array", "lookup", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L368-L375
253
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.getIterationElementType
public Type getIterationElementType() throws IntrospectionException { if (!mCheckedForIteration) { mCheckedForIteration = true; if (mIterationElementType != null) return mIterationElementType; if (mNaturalClass.isArray()) { mIterationElementType = getArrayElementType(); } else if (Collection.class.isAssignableFrom(mNaturalClass) || Map.class.isAssignableFrom(mNaturalClass)) { mIterationElementType = getIterationType(mGenericType); if (mIterationElementType == null || mIterationElementType == OBJECT_TYPE) { try { Field field = mNaturalClass.getField (BeanAnalyzer.ELEMENT_TYPE_FIELD_NAME); if (field.getType() == Class.class && Modifier.isStatic(field.getModifiers())) { mIterationElementType = new Type((Class<?>) field.get(null)); } } catch (NoSuchFieldException e) { // nothing to do } catch (IllegalAccessException e) { // nothing to do } } } if (mIterationElementType == null) { mIterationElementType = Type.OBJECT_TYPE; } } return mIterationElementType; }
java
public Type getIterationElementType() throws IntrospectionException { if (!mCheckedForIteration) { mCheckedForIteration = true; if (mIterationElementType != null) return mIterationElementType; if (mNaturalClass.isArray()) { mIterationElementType = getArrayElementType(); } else if (Collection.class.isAssignableFrom(mNaturalClass) || Map.class.isAssignableFrom(mNaturalClass)) { mIterationElementType = getIterationType(mGenericType); if (mIterationElementType == null || mIterationElementType == OBJECT_TYPE) { try { Field field = mNaturalClass.getField (BeanAnalyzer.ELEMENT_TYPE_FIELD_NAME); if (field.getType() == Class.class && Modifier.isStatic(field.getModifiers())) { mIterationElementType = new Type((Class<?>) field.get(null)); } } catch (NoSuchFieldException e) { // nothing to do } catch (IllegalAccessException e) { // nothing to do } } } if (mIterationElementType == null) { mIterationElementType = Type.OBJECT_TYPE; } } return mIterationElementType; }
[ "public", "Type", "getIterationElementType", "(", ")", "throws", "IntrospectionException", "{", "if", "(", "!", "mCheckedForIteration", ")", "{", "mCheckedForIteration", "=", "true", ";", "if", "(", "mIterationElementType", "!=", "null", ")", "return", "mIterationElementType", ";", "if", "(", "mNaturalClass", ".", "isArray", "(", ")", ")", "{", "mIterationElementType", "=", "getArrayElementType", "(", ")", ";", "}", "else", "if", "(", "Collection", ".", "class", ".", "isAssignableFrom", "(", "mNaturalClass", ")", "||", "Map", ".", "class", ".", "isAssignableFrom", "(", "mNaturalClass", ")", ")", "{", "mIterationElementType", "=", "getIterationType", "(", "mGenericType", ")", ";", "if", "(", "mIterationElementType", "==", "null", "||", "mIterationElementType", "==", "OBJECT_TYPE", ")", "{", "try", "{", "Field", "field", "=", "mNaturalClass", ".", "getField", "(", "BeanAnalyzer", ".", "ELEMENT_TYPE_FIELD_NAME", ")", ";", "if", "(", "field", ".", "getType", "(", ")", "==", "Class", ".", "class", "&&", "Modifier", ".", "isStatic", "(", "field", ".", "getModifiers", "(", ")", ")", ")", "{", "mIterationElementType", "=", "new", "Type", "(", "(", "Class", "<", "?", ">", ")", "field", ".", "get", "(", "null", ")", ")", ";", "}", "}", "catch", "(", "NoSuchFieldException", "e", ")", "{", "// nothing to do", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "// nothing to do", "}", "}", "}", "if", "(", "mIterationElementType", "==", "null", ")", "{", "mIterationElementType", "=", "Type", ".", "OBJECT_TYPE", ";", "}", "}", "return", "mIterationElementType", ";", "}" ]
If this type supports iteration, then the element type is returned. Otherwise, null is returned.
[ "If", "this", "type", "supports", "iteration", "then", "the", "element", "type", "is", "returned", ".", "Otherwise", "null", "is", "returned", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L381-L422
254
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.isReverseIterationSupported
public boolean isReverseIterationSupported() { return mNaturalClass.isArray() || List.class.isAssignableFrom(mNaturalClass) || Set.class.isAssignableFrom(mNaturalClass) || Map.class.isAssignableFrom(mNaturalClass) ; }
java
public boolean isReverseIterationSupported() { return mNaturalClass.isArray() || List.class.isAssignableFrom(mNaturalClass) || Set.class.isAssignableFrom(mNaturalClass) || Map.class.isAssignableFrom(mNaturalClass) ; }
[ "public", "boolean", "isReverseIterationSupported", "(", ")", "{", "return", "mNaturalClass", ".", "isArray", "(", ")", "||", "List", ".", "class", ".", "isAssignableFrom", "(", "mNaturalClass", ")", "||", "Set", ".", "class", ".", "isAssignableFrom", "(", "mNaturalClass", ")", "||", "Map", ".", "class", ".", "isAssignableFrom", "(", "mNaturalClass", ")", ";", "}" ]
Returns true if this type supports iteration in the reverse direction.
[ "Returns", "true", "if", "this", "type", "supports", "iteration", "in", "the", "reverse", "direction", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L467-L472
255
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.setArrayElementType
public Type setArrayElementType(Type elementType) throws IntrospectionException { Type type = new Type(mGenericType, mNaturalClass); type.checkForArrayLookup(); type.mArrayElementType = elementType; return type; }
java
public Type setArrayElementType(Type elementType) throws IntrospectionException { Type type = new Type(mGenericType, mNaturalClass); type.checkForArrayLookup(); type.mArrayElementType = elementType; return type; }
[ "public", "Type", "setArrayElementType", "(", "Type", "elementType", ")", "throws", "IntrospectionException", "{", "Type", "type", "=", "new", "Type", "(", "mGenericType", ",", "mNaturalClass", ")", ";", "type", ".", "checkForArrayLookup", "(", ")", ";", "type", ".", "mArrayElementType", "=", "elementType", ";", "return", "type", ";", "}" ]
Accessed by the TypeChecker, to override the default.
[ "Accessed", "by", "the", "TypeChecker", "to", "override", "the", "default", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L516-L522
256
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.getCompatibleType
public Type getCompatibleType(Type other) { if (other == null) { return null; } if (equals(other)) { if (this == NULL_TYPE) { return other; } else { return this; } } Class<?> classA = mObjectClass; Class<?> classB = other.mObjectClass; Type compat; if (classA == Void.class) { if (classB == Void.class) { compat = this; } else { return null; } } else if (classB == Void.class) { return null; } else if (other == NULL_TYPE) { compat = this.toNullable(); } else if (this == NULL_TYPE) { compat = other.toNullable(); } else if (Number.class.isAssignableFrom(classA) && Number.class.isAssignableFrom(classB)) { Class<?> clazz = compatibleNumber(classA, classB); if (isPrimitive() && other.isPrimitive()) { compat = new Type(clazz, convertToPrimitive(clazz)); } else { compat = new Type(clazz); } } else { // TODO: ensure generics are matched // ie: List<Number> and List<Integer> = List<Number> compat = new Type(findCommonBaseClass(classA, classB)); } if (isNonNull() && other.isNonNull()) { compat = compat.toNonNull(); } return compat; }
java
public Type getCompatibleType(Type other) { if (other == null) { return null; } if (equals(other)) { if (this == NULL_TYPE) { return other; } else { return this; } } Class<?> classA = mObjectClass; Class<?> classB = other.mObjectClass; Type compat; if (classA == Void.class) { if (classB == Void.class) { compat = this; } else { return null; } } else if (classB == Void.class) { return null; } else if (other == NULL_TYPE) { compat = this.toNullable(); } else if (this == NULL_TYPE) { compat = other.toNullable(); } else if (Number.class.isAssignableFrom(classA) && Number.class.isAssignableFrom(classB)) { Class<?> clazz = compatibleNumber(classA, classB); if (isPrimitive() && other.isPrimitive()) { compat = new Type(clazz, convertToPrimitive(clazz)); } else { compat = new Type(clazz); } } else { // TODO: ensure generics are matched // ie: List<Number> and List<Integer> = List<Number> compat = new Type(findCommonBaseClass(classA, classB)); } if (isNonNull() && other.isNonNull()) { compat = compat.toNonNull(); } return compat; }
[ "public", "Type", "getCompatibleType", "(", "Type", "other", ")", "{", "if", "(", "other", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "equals", "(", "other", ")", ")", "{", "if", "(", "this", "==", "NULL_TYPE", ")", "{", "return", "other", ";", "}", "else", "{", "return", "this", ";", "}", "}", "Class", "<", "?", ">", "classA", "=", "mObjectClass", ";", "Class", "<", "?", ">", "classB", "=", "other", ".", "mObjectClass", ";", "Type", "compat", ";", "if", "(", "classA", "==", "Void", ".", "class", ")", "{", "if", "(", "classB", "==", "Void", ".", "class", ")", "{", "compat", "=", "this", ";", "}", "else", "{", "return", "null", ";", "}", "}", "else", "if", "(", "classB", "==", "Void", ".", "class", ")", "{", "return", "null", ";", "}", "else", "if", "(", "other", "==", "NULL_TYPE", ")", "{", "compat", "=", "this", ".", "toNullable", "(", ")", ";", "}", "else", "if", "(", "this", "==", "NULL_TYPE", ")", "{", "compat", "=", "other", ".", "toNullable", "(", ")", ";", "}", "else", "if", "(", "Number", ".", "class", ".", "isAssignableFrom", "(", "classA", ")", "&&", "Number", ".", "class", ".", "isAssignableFrom", "(", "classB", ")", ")", "{", "Class", "<", "?", ">", "clazz", "=", "compatibleNumber", "(", "classA", ",", "classB", ")", ";", "if", "(", "isPrimitive", "(", ")", "&&", "other", ".", "isPrimitive", "(", ")", ")", "{", "compat", "=", "new", "Type", "(", "clazz", ",", "convertToPrimitive", "(", "clazz", ")", ")", ";", "}", "else", "{", "compat", "=", "new", "Type", "(", "clazz", ")", ";", "}", "}", "else", "{", "// TODO: ensure generics are matched", "// ie: List<Number> and List<Integer> = List<Number>", "compat", "=", "new", "Type", "(", "findCommonBaseClass", "(", "classA", ",", "classB", ")", ")", ";", "}", "if", "(", "isNonNull", "(", ")", "&&", "other", ".", "isNonNull", "(", ")", ")", "{", "compat", "=", "compat", ".", "toNonNull", "(", ")", ";", "}", "return", "compat", ";", "}" ]
Returns a type that is compatible with this type, and the one passed in. The type returned is selected using a best-fit algorithm. <p>If the type passed in represents a primitive type, but this type is not, the type returned is an object (or a subclass of), but never a primitive type. Compatible primitive types are returned when both this and the parameter type were already primitive types. <p>Input types which are arrays are also supported by this method. <p>Returns null if the given type isn't compatible with this one.
[ "Returns", "a", "type", "that", "is", "compatible", "with", "this", "type", "and", "the", "one", "passed", "in", ".", "The", "type", "returned", "is", "selected", "using", "a", "best", "-", "fit", "algorithm", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L677-L735
257
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.preserveType
public static Type preserveType(Type currentType, Type newType) { Type result = newType; if (newType != null && currentType != null && currentType.getObjectClass() == newType.getObjectClass()) { if (newType.getGenericType().getGenericType() instanceof Class && !(currentType.getGenericType().getGenericType() instanceof Class)) { if (newType.isNonNull() && !currentType.isNonNull()) { result = currentType.toNonNull(); } else if (!newType.isNonNull() && currentType.isNonNull()) { result = currentType.toNullable(); } } } return result; }
java
public static Type preserveType(Type currentType, Type newType) { Type result = newType; if (newType != null && currentType != null && currentType.getObjectClass() == newType.getObjectClass()) { if (newType.getGenericType().getGenericType() instanceof Class && !(currentType.getGenericType().getGenericType() instanceof Class)) { if (newType.isNonNull() && !currentType.isNonNull()) { result = currentType.toNonNull(); } else if (!newType.isNonNull() && currentType.isNonNull()) { result = currentType.toNullable(); } } } return result; }
[ "public", "static", "Type", "preserveType", "(", "Type", "currentType", ",", "Type", "newType", ")", "{", "Type", "result", "=", "newType", ";", "if", "(", "newType", "!=", "null", "&&", "currentType", "!=", "null", "&&", "currentType", ".", "getObjectClass", "(", ")", "==", "newType", ".", "getObjectClass", "(", ")", ")", "{", "if", "(", "newType", ".", "getGenericType", "(", ")", ".", "getGenericType", "(", ")", "instanceof", "Class", "&&", "!", "(", "currentType", ".", "getGenericType", "(", ")", ".", "getGenericType", "(", ")", "instanceof", "Class", ")", ")", "{", "if", "(", "newType", ".", "isNonNull", "(", ")", "&&", "!", "currentType", ".", "isNonNull", "(", ")", ")", "{", "result", "=", "currentType", ".", "toNonNull", "(", ")", ";", "}", "else", "if", "(", "!", "newType", ".", "isNonNull", "(", ")", "&&", "currentType", ".", "isNonNull", "(", ")", ")", "{", "result", "=", "currentType", ".", "toNullable", "(", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
Preserve the current type's generic information with the specified new type if they have the same class.
[ "Preserve", "the", "current", "type", "s", "generic", "information", "with", "the", "specified", "new", "type", "if", "they", "have", "the", "same", "class", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L803-L819
258
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.findCommonBaseClass
public static Class<?> findCommonBaseClass(Class<?> a, Class<?> b) { Class<?> clazz = findCommonBaseClass0(a, b); if (clazz != null && clazz.isInterface()) { // Only return interface if it actually defines something. if (clazz.getMethods().length <= 0) { //clazz = Object.class; } } return clazz; }
java
public static Class<?> findCommonBaseClass(Class<?> a, Class<?> b) { Class<?> clazz = findCommonBaseClass0(a, b); if (clazz != null && clazz.isInterface()) { // Only return interface if it actually defines something. if (clazz.getMethods().length <= 0) { //clazz = Object.class; } } return clazz; }
[ "public", "static", "Class", "<", "?", ">", "findCommonBaseClass", "(", "Class", "<", "?", ">", "a", ",", "Class", "<", "?", ">", "b", ")", "{", "Class", "<", "?", ">", "clazz", "=", "findCommonBaseClass0", "(", "a", ",", "b", ")", ";", "if", "(", "clazz", "!=", "null", "&&", "clazz", ".", "isInterface", "(", ")", ")", "{", "// Only return interface if it actually defines something.", "if", "(", "clazz", ".", "getMethods", "(", ")", ".", "length", "<=", "0", ")", "{", "//clazz = Object.class;", "}", "}", "return", "clazz", ";", "}" ]
Returns the most specific common superclass or interface that can be used to represent both of the specified classes. Null is only returned if either class refers to a primitive type and isn't the same as the other class.
[ "Returns", "the", "most", "specific", "common", "superclass", "or", "interface", "that", "can", "be", "used", "to", "represent", "both", "of", "the", "specified", "classes", ".", "Null", "is", "only", "returned", "if", "either", "class", "refers", "to", "a", "primitive", "type", "and", "isn", "t", "the", "same", "as", "the", "other", "class", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L827-L838
259
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.convertToObject
private static Class<?> convertToObject(Class<?> type) { if (type == int.class) { return Integer.class; } else if (type == boolean.class) { return Boolean.class; } else if (type == byte.class) { return Byte.class; } else if (type == char.class) { return Character.class; } else if (type == short.class) { return Short.class; } else if (type == long.class) { return Long.class; } else if (type == float.class) { return Float.class; } else if (type == double.class) { return Double.class; } else if (type == void.class) { return Void.class; } else { return type; } }
java
private static Class<?> convertToObject(Class<?> type) { if (type == int.class) { return Integer.class; } else if (type == boolean.class) { return Boolean.class; } else if (type == byte.class) { return Byte.class; } else if (type == char.class) { return Character.class; } else if (type == short.class) { return Short.class; } else if (type == long.class) { return Long.class; } else if (type == float.class) { return Float.class; } else if (type == double.class) { return Double.class; } else if (type == void.class) { return Void.class; } else { return type; } }
[ "private", "static", "Class", "<", "?", ">", "convertToObject", "(", "Class", "<", "?", ">", "type", ")", "{", "if", "(", "type", "==", "int", ".", "class", ")", "{", "return", "Integer", ".", "class", ";", "}", "else", "if", "(", "type", "==", "boolean", ".", "class", ")", "{", "return", "Boolean", ".", "class", ";", "}", "else", "if", "(", "type", "==", "byte", ".", "class", ")", "{", "return", "Byte", ".", "class", ";", "}", "else", "if", "(", "type", "==", "char", ".", "class", ")", "{", "return", "Character", ".", "class", ";", "}", "else", "if", "(", "type", "==", "short", ".", "class", ")", "{", "return", "Short", ".", "class", ";", "}", "else", "if", "(", "type", "==", "long", ".", "class", ")", "{", "return", "Long", ".", "class", ";", "}", "else", "if", "(", "type", "==", "float", ".", "class", ")", "{", "return", "Float", ".", "class", ";", "}", "else", "if", "(", "type", "==", "double", ".", "class", ")", "{", "return", "Double", ".", "class", ";", "}", "else", "if", "(", "type", "==", "void", ".", "class", ")", "{", "return", "Void", ".", "class", ";", "}", "else", "{", "return", "type", ";", "}", "}" ]
If class passed in represents a primitive type, its object peer is returned. Otherwise, it is returned unchanged.
[ "If", "class", "passed", "in", "represents", "a", "primitive", "type", "its", "object", "peer", "is", "returned", ".", "Otherwise", "it", "is", "returned", "unchanged", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L985-L1016
260
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Type.java
Type.convertableFrom
public int convertableFrom(Type other, boolean vararg) { int cost = convertableFrom(other); if (cost < 0) { return cost; } return (vararg ? cost + 40 : cost); }
java
public int convertableFrom(Type other, boolean vararg) { int cost = convertableFrom(other); if (cost < 0) { return cost; } return (vararg ? cost + 40 : cost); }
[ "public", "int", "convertableFrom", "(", "Type", "other", ",", "boolean", "vararg", ")", "{", "int", "cost", "=", "convertableFrom", "(", "other", ")", ";", "if", "(", "cost", "<", "0", ")", "{", "return", "cost", ";", "}", "return", "(", "vararg", "?", "cost", "+", "40", ":", "cost", ")", ";", "}" ]
Check if a type is convertable including support for varargs. If varargs is true, then this will add 40 to the total cost such that non-varargs will always take precedence. @see #convertableFrom(Type)
[ "Check", "if", "a", "type", "is", "convertable", "including", "support", "for", "varargs", ".", "If", "varargs", "is", "true", "then", "this", "will", "add", "40", "to", "the", "total", "cost", "such", "that", "non", "-", "varargs", "will", "always", "take", "precedence", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Type.java#L1180-L1185
261
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/ConstantIntegerInfo.java
ConstantIntegerInfo.make
static ConstantIntegerInfo make(ConstantPool cp, int value) { ConstantInfo ci = new ConstantIntegerInfo(value); return (ConstantIntegerInfo)cp.addConstant(ci); }
java
static ConstantIntegerInfo make(ConstantPool cp, int value) { ConstantInfo ci = new ConstantIntegerInfo(value); return (ConstantIntegerInfo)cp.addConstant(ci); }
[ "static", "ConstantIntegerInfo", "make", "(", "ConstantPool", "cp", ",", "int", "value", ")", "{", "ConstantInfo", "ci", "=", "new", "ConstantIntegerInfo", "(", "value", ")", ";", "return", "(", "ConstantIntegerInfo", ")", "cp", ".", "addConstant", "(", "ci", ")", ";", "}" ]
Will return either a new ConstantIntegerInfo object or one already in the constant pool. If it is a new ConstantIntegerInfo, it will be inserted into the pool.
[ "Will", "return", "either", "a", "new", "ConstantIntegerInfo", "object", "or", "one", "already", "in", "the", "constant", "pool", ".", "If", "it", "is", "a", "new", "ConstantIntegerInfo", "it", "will", "be", "inserted", "into", "the", "pool", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ConstantIntegerInfo.java#L35-L38
262
teatrove/teatrove
build-tools/teatools/src/main/java/org/teatrove/teatools/IssueCollector.java
IssueCollector.getErrors
public List<CompileEvent> getErrors() { List<CompileEvent> errors = new ArrayList<CompileEvent>(); for (CompileEvent event : mIssues) { if (event.isError()) { errors.add(event); } } return errors; }
java
public List<CompileEvent> getErrors() { List<CompileEvent> errors = new ArrayList<CompileEvent>(); for (CompileEvent event : mIssues) { if (event.isError()) { errors.add(event); } } return errors; }
[ "public", "List", "<", "CompileEvent", ">", "getErrors", "(", ")", "{", "List", "<", "CompileEvent", ">", "errors", "=", "new", "ArrayList", "<", "CompileEvent", ">", "(", ")", ";", "for", "(", "CompileEvent", "event", ":", "mIssues", ")", "{", "if", "(", "event", ".", "isError", "(", ")", ")", "{", "errors", ".", "add", "(", "event", ")", ";", "}", "}", "return", "errors", ";", "}" ]
Retrieves the set of errors that were reported via the compileError method. @return a List of CompileEvent error objects
[ "Retrieves", "the", "set", "of", "errors", "that", "were", "reported", "via", "the", "compileError", "method", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/teatools/src/main/java/org/teatrove/teatools/IssueCollector.java#L68-L75
263
teatrove/teatrove
build-tools/teatools/src/main/java/org/teatrove/teatools/IssueCollector.java
IssueCollector.getWarnings
public List<CompileEvent> getWarnings() { List<CompileEvent> warnings = new ArrayList<CompileEvent>(); for (CompileEvent event : mIssues) { if (event.isWarning()) { warnings.add(event); } } return warnings; }
java
public List<CompileEvent> getWarnings() { List<CompileEvent> warnings = new ArrayList<CompileEvent>(); for (CompileEvent event : mIssues) { if (event.isWarning()) { warnings.add(event); } } return warnings; }
[ "public", "List", "<", "CompileEvent", ">", "getWarnings", "(", ")", "{", "List", "<", "CompileEvent", ">", "warnings", "=", "new", "ArrayList", "<", "CompileEvent", ">", "(", ")", ";", "for", "(", "CompileEvent", "event", ":", "mIssues", ")", "{", "if", "(", "event", ".", "isWarning", "(", ")", ")", "{", "warnings", ".", "add", "(", "event", ")", ";", "}", "}", "return", "warnings", ";", "}" ]
Retrieves the set of warnings that were reported via the compileWarning method. @return a List of CompileEvent warning objects
[ "Retrieves", "the", "set", "of", "warnings", "that", "were", "reported", "via", "the", "compileWarning", "method", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/teatools/src/main/java/org/teatrove/teatools/IssueCollector.java#L83-L90
264
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/HTMLContext.java
HTMLContext.getPagination
public String[] getPagination(String text, int maxChars, String splitValue, String[] HTMLBalanceTags) { int count; int lastSplitCount; String tempHolder = " "; List<String> list = new ArrayList<String>(); boolean secondRunThrough = false; // if the story will not be broken up because it's too small, // just return it without doing all the logic. if ((getCharCount(text) <= maxChars)) { list.add(text); return list.toArray(new String[list.size()]); } //JVM 1.4 version //String[] splits = text.split(splitValue); //Will need an HTMLBalance function if implemented. //JVM 1.3 version String[] splits = split(text, splitValue, HTMLBalanceTags); int len = splits.length; for (int i = 0; i < len;i++) { //Check to see if last page would not be at least half filled. // If so, add to previous page. if (i == len-2){ lastSplitCount = getCharCount(splits[i+1]); if (lastSplitCount <= maxChars/2) { splits[i] = splits[i]+" "+splits[i+1]; list.add(tempHolder+splits[i]); return list.toArray(new String[list.size()]); } } if (secondRunThrough){ count = getCharCount(tempHolder+splits[i]); } else{ count = getCharCount(splits[i]); } if (count >= maxChars || i+1 == len) { list.add(tempHolder+splits[i]); secondRunThrough = false; tempHolder = " "; } else{ tempHolder = tempHolder+splits[i]; secondRunThrough = true; } } return list.toArray(new String[list.size()]); }
java
public String[] getPagination(String text, int maxChars, String splitValue, String[] HTMLBalanceTags) { int count; int lastSplitCount; String tempHolder = " "; List<String> list = new ArrayList<String>(); boolean secondRunThrough = false; // if the story will not be broken up because it's too small, // just return it without doing all the logic. if ((getCharCount(text) <= maxChars)) { list.add(text); return list.toArray(new String[list.size()]); } //JVM 1.4 version //String[] splits = text.split(splitValue); //Will need an HTMLBalance function if implemented. //JVM 1.3 version String[] splits = split(text, splitValue, HTMLBalanceTags); int len = splits.length; for (int i = 0; i < len;i++) { //Check to see if last page would not be at least half filled. // If so, add to previous page. if (i == len-2){ lastSplitCount = getCharCount(splits[i+1]); if (lastSplitCount <= maxChars/2) { splits[i] = splits[i]+" "+splits[i+1]; list.add(tempHolder+splits[i]); return list.toArray(new String[list.size()]); } } if (secondRunThrough){ count = getCharCount(tempHolder+splits[i]); } else{ count = getCharCount(splits[i]); } if (count >= maxChars || i+1 == len) { list.add(tempHolder+splits[i]); secondRunThrough = false; tempHolder = " "; } else{ tempHolder = tempHolder+splits[i]; secondRunThrough = true; } } return list.toArray(new String[list.size()]); }
[ "public", "String", "[", "]", "getPagination", "(", "String", "text", ",", "int", "maxChars", ",", "String", "splitValue", ",", "String", "[", "]", "HTMLBalanceTags", ")", "{", "int", "count", ";", "int", "lastSplitCount", ";", "String", "tempHolder", "=", "\" \"", ";", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "boolean", "secondRunThrough", "=", "false", ";", "// if the story will not be broken up because it's too small, ", "// just return it without doing all the logic.", "if", "(", "(", "getCharCount", "(", "text", ")", "<=", "maxChars", ")", ")", "{", "list", ".", "add", "(", "text", ")", ";", "return", "list", ".", "toArray", "(", "new", "String", "[", "list", ".", "size", "(", ")", "]", ")", ";", "}", "//JVM 1.4 version", "//String[] splits = text.split(splitValue);", "//Will need an HTMLBalance function if implemented.", "//JVM 1.3 version", "String", "[", "]", "splits", "=", "split", "(", "text", ",", "splitValue", ",", "HTMLBalanceTags", ")", ";", "int", "len", "=", "splits", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "//Check to see if last page would not be at least half filled. ", "// If so, add to previous page.", "if", "(", "i", "==", "len", "-", "2", ")", "{", "lastSplitCount", "=", "getCharCount", "(", "splits", "[", "i", "+", "1", "]", ")", ";", "if", "(", "lastSplitCount", "<=", "maxChars", "/", "2", ")", "{", "splits", "[", "i", "]", "=", "splits", "[", "i", "]", "+", "\" \"", "+", "splits", "[", "i", "+", "1", "]", ";", "list", ".", "add", "(", "tempHolder", "+", "splits", "[", "i", "]", ")", ";", "return", "list", ".", "toArray", "(", "new", "String", "[", "list", ".", "size", "(", ")", "]", ")", ";", "}", "}", "if", "(", "secondRunThrough", ")", "{", "count", "=", "getCharCount", "(", "tempHolder", "+", "splits", "[", "i", "]", ")", ";", "}", "else", "{", "count", "=", "getCharCount", "(", "splits", "[", "i", "]", ")", ";", "}", "if", "(", "count", ">=", "maxChars", "||", "i", "+", "1", "==", "len", ")", "{", "list", ".", "add", "(", "tempHolder", "+", "splits", "[", "i", "]", ")", ";", "secondRunThrough", "=", "false", ";", "tempHolder", "=", "\" \"", ";", "}", "else", "{", "tempHolder", "=", "tempHolder", "+", "splits", "[", "i", "]", ";", "secondRunThrough", "=", "true", ";", "}", "}", "return", "list", ".", "toArray", "(", "new", "String", "[", "list", ".", "size", "(", ")", "]", ")", ";", "}" ]
Paginate the given text input so that each page contains no more than the given maximum number of characters. The length of each page is based on the text only ignoring any HTML tags. @param text The text to paginate against @param maxChars The maximum characters per page @param splitValue The split characters for splitting on page breaks @param HTMLBalanceTags Set of tags to ensure are opened/closed properly @return The array of strings per page @see #getCharCount(String)
[ "Paginate", "the", "given", "text", "input", "so", "that", "each", "page", "contains", "no", "more", "than", "the", "given", "maximum", "number", "of", "characters", ".", "The", "length", "of", "each", "page", "is", "based", "on", "the", "text", "only", "ignoring", "any", "HTML", "tags", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/HTMLContext.java#L51-L104
265
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/HTMLContext.java
HTMLContext.split
public String[] split(String text, String splitValue, String[] HTMLBalanceTags) { String restOfText = text; int nextBreakIndex = 0; List<String> list = new ArrayList<String>(); int splitValueLength = splitValue.length(); while (restOfText.length() > 0) { nextBreakIndex = restOfText.indexOf(splitValue); if (nextBreakIndex < 0) { list.add(restOfText); break; } list.add(restOfText.substring(0, nextBreakIndex+splitValueLength)); restOfText = restOfText.substring(nextBreakIndex+splitValueLength); } // This code makes sure that no ending HTML </> tags are left out // causing malfomed pages. if (HTMLBalanceTags.length > 0) { List<String> balancedList = new ArrayList<String>(); for (int t = 0; t < HTMLBalanceTags.length; t++) { // first tag pass through if (t < 1) { balancedList = getBalancedList(HTMLBalanceTags[t], list); } else if (balancedList.size() > 1) { // after the first pass through keep trying on each // subsequent tag. balancedList = getBalancedList(HTMLBalanceTags[t], balancedList); } } return balancedList.toArray(new String[balancedList.size()]); } else { return list.toArray(new String[list.size()]); } }
java
public String[] split(String text, String splitValue, String[] HTMLBalanceTags) { String restOfText = text; int nextBreakIndex = 0; List<String> list = new ArrayList<String>(); int splitValueLength = splitValue.length(); while (restOfText.length() > 0) { nextBreakIndex = restOfText.indexOf(splitValue); if (nextBreakIndex < 0) { list.add(restOfText); break; } list.add(restOfText.substring(0, nextBreakIndex+splitValueLength)); restOfText = restOfText.substring(nextBreakIndex+splitValueLength); } // This code makes sure that no ending HTML </> tags are left out // causing malfomed pages. if (HTMLBalanceTags.length > 0) { List<String> balancedList = new ArrayList<String>(); for (int t = 0; t < HTMLBalanceTags.length; t++) { // first tag pass through if (t < 1) { balancedList = getBalancedList(HTMLBalanceTags[t], list); } else if (balancedList.size() > 1) { // after the first pass through keep trying on each // subsequent tag. balancedList = getBalancedList(HTMLBalanceTags[t], balancedList); } } return balancedList.toArray(new String[balancedList.size()]); } else { return list.toArray(new String[list.size()]); } }
[ "public", "String", "[", "]", "split", "(", "String", "text", ",", "String", "splitValue", ",", "String", "[", "]", "HTMLBalanceTags", ")", "{", "String", "restOfText", "=", "text", ";", "int", "nextBreakIndex", "=", "0", ";", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "int", "splitValueLength", "=", "splitValue", ".", "length", "(", ")", ";", "while", "(", "restOfText", ".", "length", "(", ")", ">", "0", ")", "{", "nextBreakIndex", "=", "restOfText", ".", "indexOf", "(", "splitValue", ")", ";", "if", "(", "nextBreakIndex", "<", "0", ")", "{", "list", ".", "add", "(", "restOfText", ")", ";", "break", ";", "}", "list", ".", "add", "(", "restOfText", ".", "substring", "(", "0", ",", "nextBreakIndex", "+", "splitValueLength", ")", ")", ";", "restOfText", "=", "restOfText", ".", "substring", "(", "nextBreakIndex", "+", "splitValueLength", ")", ";", "}", "// This code makes sure that no ending HTML </> tags are left out ", "// causing malfomed pages.", "if", "(", "HTMLBalanceTags", ".", "length", ">", "0", ")", "{", "List", "<", "String", ">", "balancedList", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "t", "=", "0", ";", "t", "<", "HTMLBalanceTags", ".", "length", ";", "t", "++", ")", "{", "// first tag pass through", "if", "(", "t", "<", "1", ")", "{", "balancedList", "=", "getBalancedList", "(", "HTMLBalanceTags", "[", "t", "]", ",", "list", ")", ";", "}", "else", "if", "(", "balancedList", ".", "size", "(", ")", ">", "1", ")", "{", "// after the first pass through keep trying on each", "// subsequent tag.", "balancedList", "=", "getBalancedList", "(", "HTMLBalanceTags", "[", "t", "]", ",", "balancedList", ")", ";", "}", "}", "return", "balancedList", ".", "toArray", "(", "new", "String", "[", "balancedList", ".", "size", "(", ")", "]", ")", ";", "}", "else", "{", "return", "list", ".", "toArray", "(", "new", "String", "[", "list", ".", "size", "(", ")", "]", ")", ";", "}", "}" ]
Split the given string around the given split value. This will also ensure any of the given HTML tags are properly closed. @param text The text value to split @param splitValue The values to be split on @param HTMLBalanceTags The HTML tags to ensure are closed properly @return The array of string values per the splitting
[ "Split", "the", "given", "string", "around", "the", "given", "split", "value", ".", "This", "will", "also", "ensure", "any", "of", "the", "given", "HTML", "tags", "are", "properly", "closed", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/HTMLContext.java#L116-L157
266
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/classfile/ParameterAnnotationsAttr.java
ParameterAnnotationsAttr.getAnnotations
public Annotation[][] getAnnotations() { Annotation[][] copy = new Annotation[mParameterAnnotations.size()][]; for (int i=copy.length; --i>=0; ) { Vector<Annotation> annotations = mParameterAnnotations.get(i); if (annotations == null) { copy[i] = new Annotation[0]; } else { copy[i] = annotations.toArray(new Annotation[annotations.size()]); } } return copy; }
java
public Annotation[][] getAnnotations() { Annotation[][] copy = new Annotation[mParameterAnnotations.size()][]; for (int i=copy.length; --i>=0; ) { Vector<Annotation> annotations = mParameterAnnotations.get(i); if (annotations == null) { copy[i] = new Annotation[0]; } else { copy[i] = annotations.toArray(new Annotation[annotations.size()]); } } return copy; }
[ "public", "Annotation", "[", "]", "[", "]", "getAnnotations", "(", ")", "{", "Annotation", "[", "]", "[", "]", "copy", "=", "new", "Annotation", "[", "mParameterAnnotations", ".", "size", "(", ")", "]", "[", "", "]", ";", "for", "(", "int", "i", "=", "copy", ".", "length", ";", "--", "i", ">=", "0", ";", ")", "{", "Vector", "<", "Annotation", ">", "annotations", "=", "mParameterAnnotations", ".", "get", "(", "i", ")", ";", "if", "(", "annotations", "==", "null", ")", "{", "copy", "[", "i", "]", "=", "new", "Annotation", "[", "0", "]", ";", "}", "else", "{", "copy", "[", "i", "]", "=", "annotations", ".", "toArray", "(", "new", "Annotation", "[", "annotations", ".", "size", "(", ")", "]", ")", ";", "}", "}", "return", "copy", ";", "}" ]
First array index is zero-based parameter number.
[ "First", "array", "index", "is", "zero", "-", "based", "parameter", "number", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/classfile/ParameterAnnotationsAttr.java#L63-L74
267
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/util/cluster/ClusterManager.java
ClusterManager.launchAuto
public void launchAuto(boolean active) { killAuto(); if (mSock != null) { try { mAuto = new AutomaticClusterManagementThread(this, mCluster .getClusterName(), active); } catch (Exception e) { mAuto = new AutomaticClusterManagementThread(this, active); } if (mAuto != null) { mAuto.start(); } } }
java
public void launchAuto(boolean active) { killAuto(); if (mSock != null) { try { mAuto = new AutomaticClusterManagementThread(this, mCluster .getClusterName(), active); } catch (Exception e) { mAuto = new AutomaticClusterManagementThread(this, active); } if (mAuto != null) { mAuto.start(); } } }
[ "public", "void", "launchAuto", "(", "boolean", "active", ")", "{", "killAuto", "(", ")", ";", "if", "(", "mSock", "!=", "null", ")", "{", "try", "{", "mAuto", "=", "new", "AutomaticClusterManagementThread", "(", "this", ",", "mCluster", ".", "getClusterName", "(", ")", ",", "active", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "mAuto", "=", "new", "AutomaticClusterManagementThread", "(", "this", ",", "active", ")", ";", "}", "if", "(", "mAuto", "!=", "null", ")", "{", "mAuto", ".", "start", "(", ")", ";", "}", "}", "}" ]
Allows the management thread to passively take part in the cluster operations. Other cluster members will not be made aware of this instance.
[ "Allows", "the", "management", "thread", "to", "passively", "take", "part", "in", "the", "cluster", "operations", ".", "Other", "cluster", "members", "will", "not", "be", "made", "aware", "of", "this", "instance", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/util/cluster/ClusterManager.java#L440-L455
268
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/util/cluster/ClusterManager.java
ClusterManager.launchAuto
public void launchAuto(AutomaticClusterManagementThread auto) { killAuto(); if (mSock != null) { mAuto = auto; if (mAuto != null) { mAuto.start(); } } }
java
public void launchAuto(AutomaticClusterManagementThread auto) { killAuto(); if (mSock != null) { mAuto = auto; if (mAuto != null) { mAuto.start(); } } }
[ "public", "void", "launchAuto", "(", "AutomaticClusterManagementThread", "auto", ")", "{", "killAuto", "(", ")", ";", "if", "(", "mSock", "!=", "null", ")", "{", "mAuto", "=", "auto", ";", "if", "(", "mAuto", "!=", "null", ")", "{", "mAuto", ".", "start", "(", ")", ";", "}", "}", "}" ]
permits the AutomaticClusterManagementThread to be subclassed and used into the ClusterManager.
[ "permits", "the", "AutomaticClusterManagementThread", "to", "be", "subclassed", "and", "used", "into", "the", "ClusterManager", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/util/cluster/ClusterManager.java#L461-L469
269
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/util/cluster/ClusterManager.java
ClusterManager.convertIPBytes
public long convertIPBytes(byte[] ipBytes) { if (ipBytes.length == 4) { long ipLong = (((long)ipBytes[0]) << 24); ipLong |= (((long)ipBytes[1]) << 16); ipLong |= (((long)ipBytes[2]) << 8); ipLong |= (long)ipBytes[3]; return ipLong; } return -1; }
java
public long convertIPBytes(byte[] ipBytes) { if (ipBytes.length == 4) { long ipLong = (((long)ipBytes[0]) << 24); ipLong |= (((long)ipBytes[1]) << 16); ipLong |= (((long)ipBytes[2]) << 8); ipLong |= (long)ipBytes[3]; return ipLong; } return -1; }
[ "public", "long", "convertIPBytes", "(", "byte", "[", "]", "ipBytes", ")", "{", "if", "(", "ipBytes", ".", "length", "==", "4", ")", "{", "long", "ipLong", "=", "(", "(", "(", "long", ")", "ipBytes", "[", "0", "]", ")", "<<", "24", ")", ";", "ipLong", "|=", "(", "(", "(", "long", ")", "ipBytes", "[", "1", "]", ")", "<<", "16", ")", ";", "ipLong", "|=", "(", "(", "(", "long", ")", "ipBytes", "[", "2", "]", ")", "<<", "8", ")", ";", "ipLong", "|=", "(", "long", ")", "ipBytes", "[", "3", "]", ";", "return", "ipLong", ";", "}", "return", "-", "1", ";", "}" ]
converts an array of four bytes to a long. @return the converted bytes as a lon or -1 on error.
[ "converts", "an", "array", "of", "four", "bytes", "to", "a", "long", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/util/cluster/ClusterManager.java#L679-L688
270
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/util/cluster/ClusterManager.java
ClusterManager.convertIPString
public long convertIPString(String ip) throws NumberFormatException, IllegalArgumentException { StringTokenizer st = new StringTokenizer(ip,"."); if (st.countTokens() == 4) { long ipLong = (Long.parseLong(st.nextToken()) << 24); ipLong += (Long.parseLong(st.nextToken()) << 16); ipLong += (Long.parseLong(st.nextToken()) << 8); ipLong += Long.parseLong(st.nextToken()); return ipLong; } else { throw new IllegalArgumentException("Invalid IP string"); } }
java
public long convertIPString(String ip) throws NumberFormatException, IllegalArgumentException { StringTokenizer st = new StringTokenizer(ip,"."); if (st.countTokens() == 4) { long ipLong = (Long.parseLong(st.nextToken()) << 24); ipLong += (Long.parseLong(st.nextToken()) << 16); ipLong += (Long.parseLong(st.nextToken()) << 8); ipLong += Long.parseLong(st.nextToken()); return ipLong; } else { throw new IllegalArgumentException("Invalid IP string"); } }
[ "public", "long", "convertIPString", "(", "String", "ip", ")", "throws", "NumberFormatException", ",", "IllegalArgumentException", "{", "StringTokenizer", "st", "=", "new", "StringTokenizer", "(", "ip", ",", "\".\"", ")", ";", "if", "(", "st", ".", "countTokens", "(", ")", "==", "4", ")", "{", "long", "ipLong", "=", "(", "Long", ".", "parseLong", "(", "st", ".", "nextToken", "(", ")", ")", "<<", "24", ")", ";", "ipLong", "+=", "(", "Long", ".", "parseLong", "(", "st", ".", "nextToken", "(", ")", ")", "<<", "16", ")", ";", "ipLong", "+=", "(", "Long", ".", "parseLong", "(", "st", ".", "nextToken", "(", ")", ")", "<<", "8", ")", ";", "ipLong", "+=", "Long", ".", "parseLong", "(", "st", ".", "nextToken", "(", ")", ")", ";", "return", "ipLong", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid IP string\"", ")", ";", "}", "}" ]
turns a dot delimited IP address string into a long.
[ "turns", "a", "dot", "delimited", "IP", "address", "string", "into", "a", "long", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/util/cluster/ClusterManager.java#L693-L707
271
teatrove/teatrove
teaservlet/src/main/java/org/teatrove/teaservlet/util/cluster/ClusterManager.java
ClusterManager.convertIPBackToString
public String convertIPBackToString(long ip) { StringBuffer sb = new StringBuffer(16); sb.append(Long.toString((ip >> 24)& 0xFF)); sb.append('.'); sb.append(Long.toString((ip >> 16)& 0xFF)); sb.append('.'); sb.append(Long.toString((ip >> 8) & 0xFF)); sb.append('.'); sb.append(Long.toString(ip & 0xFF)); return sb.toString(); }
java
public String convertIPBackToString(long ip) { StringBuffer sb = new StringBuffer(16); sb.append(Long.toString((ip >> 24)& 0xFF)); sb.append('.'); sb.append(Long.toString((ip >> 16)& 0xFF)); sb.append('.'); sb.append(Long.toString((ip >> 8) & 0xFF)); sb.append('.'); sb.append(Long.toString(ip & 0xFF)); return sb.toString(); }
[ "public", "String", "convertIPBackToString", "(", "long", "ip", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", "16", ")", ";", "sb", ".", "append", "(", "Long", ".", "toString", "(", "(", "ip", ">>", "24", ")", "&", "0xFF", ")", ")", ";", "sb", ".", "append", "(", "'", "'", ")", ";", "sb", ".", "append", "(", "Long", ".", "toString", "(", "(", "ip", ">>", "16", ")", "&", "0xFF", ")", ")", ";", "sb", ".", "append", "(", "'", "'", ")", ";", "sb", ".", "append", "(", "Long", ".", "toString", "(", "(", "ip", ">>", "8", ")", "&", "0xFF", ")", ")", ";", "sb", ".", "append", "(", "'", "'", ")", ";", "sb", ".", "append", "(", "Long", ".", "toString", "(", "ip", "&", "0xFF", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
converts a long to a dot delimited IP address string.
[ "converts", "a", "long", "to", "a", "dot", "delimited", "IP", "address", "string", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/util/cluster/ClusterManager.java#L712-L722
272
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Compiler.java
Compiler.loadClass
public Class<?> loadClass(String name) throws ClassNotFoundException { while (true) { try { if (mClassLoader == null) { return Class.forName(name); } else { return mClassLoader.loadClass(name); } } catch (ClassNotFoundException e) { int index = name.lastIndexOf('.'); if (index < 0) { throw e; } // Search for inner class. name = name.substring(0, index) + '$' + name.substring(index + 1); } } }
java
public Class<?> loadClass(String name) throws ClassNotFoundException { while (true) { try { if (mClassLoader == null) { return Class.forName(name); } else { return mClassLoader.loadClass(name); } } catch (ClassNotFoundException e) { int index = name.lastIndexOf('.'); if (index < 0) { throw e; } // Search for inner class. name = name.substring(0, index) + '$' + name.substring(index + 1); } } }
[ "public", "Class", "<", "?", ">", "loadClass", "(", "String", "name", ")", "throws", "ClassNotFoundException", "{", "while", "(", "true", ")", "{", "try", "{", "if", "(", "mClassLoader", "==", "null", ")", "{", "return", "Class", ".", "forName", "(", "name", ")", ";", "}", "else", "{", "return", "mClassLoader", ".", "loadClass", "(", "name", ")", ";", "}", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "int", "index", "=", "name", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "index", "<", "0", ")", "{", "throw", "e", ";", "}", "// Search for inner class.", "name", "=", "name", ".", "substring", "(", "0", ",", "index", ")", "+", "'", "'", "+", "name", ".", "substring", "(", "index", "+", "1", ")", ";", "}", "}", "}" ]
Loads and returns a class by the fully qualified name given. If a ClassLoader is specified, it is used to load the class. Otherwise, the class is loaded via Class.forName. @see #setClassLoader(ClassLoader)
[ "Loads", "and", "returns", "a", "class", "by", "the", "fully", "qualified", "name", "given", ".", "If", "a", "ClassLoader", "is", "specified", "it", "is", "used", "to", "load", "the", "class", ".", "Otherwise", "the", "class", "is", "loaded", "via", "Class", ".", "forName", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Compiler.java#L367-L386
273
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Compiler.java
Compiler.preserveParseTree
public void preserveParseTree(String name) { if (mPreserveTree == null) { mPreserveTree = new HashSet<String>(); } mPreserveTree.add(name); }
java
public void preserveParseTree(String name) { if (mPreserveTree == null) { mPreserveTree = new HashSet<String>(); } mPreserveTree.add(name); }
[ "public", "void", "preserveParseTree", "(", "String", "name", ")", "{", "if", "(", "mPreserveTree", "==", "null", ")", "{", "mPreserveTree", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "}", "mPreserveTree", ".", "add", "(", "name", ")", ";", "}" ]
After a template is compiled, all but the root node of its parse tree is clipped, in order to save memory. Applications that wish to traverse CompilationUnit parse trees should call this method to preserve them. This method must be called prior to compilation and prior to requesting a parse tree from a CompilationUnit. @param name fully qualified name of template whose parse tree is to be preserved.
[ "After", "a", "template", "is", "compiled", "all", "but", "the", "root", "node", "of", "its", "parse", "tree", "is", "clipped", "in", "order", "to", "save", "memory", ".", "Applications", "that", "wish", "to", "traverse", "CompilationUnit", "parse", "trees", "should", "call", "this", "method", "to", "preserve", "them", ".", "This", "method", "must", "be", "called", "prior", "to", "compilation", "and", "prior", "to", "requesting", "a", "parse", "tree", "from", "a", "CompilationUnit", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Compiler.java#L398-L403
274
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Compiler.java
Compiler.compile
public String[] compile(String[] names) throws IOException { if (!TemplateRepository.isInitialized()) { return compile0(names); } String[] compNames = compile0(names); ArrayList<String> compList = new ArrayList<String>(Arrays.asList(compNames)); TemplateRepository rep = TemplateRepository.getInstance(); String[] callers = rep.getCallersNeedingRecompile(compNames, this); if (callers.length > 0) compList.addAll(Arrays.asList(compile0(callers))); String[] compiled = compList.toArray(new String[compList.size()]); // JoshY - There's a VM bug in JVM 1.4.2 that can cause the repository // update to throw a NullPointerException when it shouldn't. There's a // workaround in place and we also put a catch here, to allow the // TeaServlet init to finish just in case try { rep.update(compiled); } catch (Exception e) { System.err.println("Unable to update repository"); e.printStackTrace(System.err); } return compiled; }
java
public String[] compile(String[] names) throws IOException { if (!TemplateRepository.isInitialized()) { return compile0(names); } String[] compNames = compile0(names); ArrayList<String> compList = new ArrayList<String>(Arrays.asList(compNames)); TemplateRepository rep = TemplateRepository.getInstance(); String[] callers = rep.getCallersNeedingRecompile(compNames, this); if (callers.length > 0) compList.addAll(Arrays.asList(compile0(callers))); String[] compiled = compList.toArray(new String[compList.size()]); // JoshY - There's a VM bug in JVM 1.4.2 that can cause the repository // update to throw a NullPointerException when it shouldn't. There's a // workaround in place and we also put a catch here, to allow the // TeaServlet init to finish just in case try { rep.update(compiled); } catch (Exception e) { System.err.println("Unable to update repository"); e.printStackTrace(System.err); } return compiled; }
[ "public", "String", "[", "]", "compile", "(", "String", "[", "]", "names", ")", "throws", "IOException", "{", "if", "(", "!", "TemplateRepository", ".", "isInitialized", "(", ")", ")", "{", "return", "compile0", "(", "names", ")", ";", "}", "String", "[", "]", "compNames", "=", "compile0", "(", "names", ")", ";", "ArrayList", "<", "String", ">", "compList", "=", "new", "ArrayList", "<", "String", ">", "(", "Arrays", ".", "asList", "(", "compNames", ")", ")", ";", "TemplateRepository", "rep", "=", "TemplateRepository", ".", "getInstance", "(", ")", ";", "String", "[", "]", "callers", "=", "rep", ".", "getCallersNeedingRecompile", "(", "compNames", ",", "this", ")", ";", "if", "(", "callers", ".", "length", ">", "0", ")", "compList", ".", "addAll", "(", "Arrays", ".", "asList", "(", "compile0", "(", "callers", ")", ")", ")", ";", "String", "[", "]", "compiled", "=", "compList", ".", "toArray", "(", "new", "String", "[", "compList", ".", "size", "(", ")", "]", ")", ";", "// JoshY - There's a VM bug in JVM 1.4.2 that can cause the repository ", "// update to throw a NullPointerException when it shouldn't. There's a ", "// workaround in place and we also put a catch here, to allow the ", "// TeaServlet init to finish just in case", "try", "{", "rep", ".", "update", "(", "compiled", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"Unable to update repository\"", ")", ";", "e", ".", "printStackTrace", "(", "System", ".", "err", ")", ";", "}", "return", "compiled", ";", "}" ]
Compile a list of compilation units. This method can be called multiple times, but it will not compile compilation units that have already been compiled. @param names an array of fully qualified template names @return The names of all the sources compiled by this compiler @exception IOException
[ "Compile", "a", "list", "of", "compilation", "units", ".", "This", "method", "can", "be", "called", "multiple", "times", "but", "it", "will", "not", "compile", "compilation", "units", "that", "have", "already", "been", "compiled", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Compiler.java#L519-L544
275
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Compiler.java
Compiler.getCompilationUnit
public CompilationUnit getCompilationUnit(String name, CompilationUnit from) { String fqName = determineQualifiedName(name, from); // Templates with source will always override compiled templates boolean compiled = false; if (fqName == null && (compiled = CompiledTemplate.exists(this, name, from))) { fqName = CompiledTemplate.getFullyQualifiedName(name); } if (fqName == null) return null; CompilationUnit unit = mCompilationUnitMap.get(fqName); if (unit == null) { if (!compiled) { unit = createCompilationUnit(fqName); if (unit != null) mCompilationUnitMap.put(fqName, unit); } else { unit = new CompiledTemplate(name, this, from); // if the CompiledTemplate class was precompiled (is valid) return the unit, otherwise return null to signify 'not found' if( ((CompiledTemplate)unit).isValid() ) { mCompilationUnitMap.put(fqName, unit); } else { // TODO: flag the template class for removal unit = null; } } } return unit; }
java
public CompilationUnit getCompilationUnit(String name, CompilationUnit from) { String fqName = determineQualifiedName(name, from); // Templates with source will always override compiled templates boolean compiled = false; if (fqName == null && (compiled = CompiledTemplate.exists(this, name, from))) { fqName = CompiledTemplate.getFullyQualifiedName(name); } if (fqName == null) return null; CompilationUnit unit = mCompilationUnitMap.get(fqName); if (unit == null) { if (!compiled) { unit = createCompilationUnit(fqName); if (unit != null) mCompilationUnitMap.put(fqName, unit); } else { unit = new CompiledTemplate(name, this, from); // if the CompiledTemplate class was precompiled (is valid) return the unit, otherwise return null to signify 'not found' if( ((CompiledTemplate)unit).isValid() ) { mCompilationUnitMap.put(fqName, unit); } else { // TODO: flag the template class for removal unit = null; } } } return unit; }
[ "public", "CompilationUnit", "getCompilationUnit", "(", "String", "name", ",", "CompilationUnit", "from", ")", "{", "String", "fqName", "=", "determineQualifiedName", "(", "name", ",", "from", ")", ";", "// Templates with source will always override compiled templates", "boolean", "compiled", "=", "false", ";", "if", "(", "fqName", "==", "null", "&&", "(", "compiled", "=", "CompiledTemplate", ".", "exists", "(", "this", ",", "name", ",", "from", ")", ")", ")", "{", "fqName", "=", "CompiledTemplate", ".", "getFullyQualifiedName", "(", "name", ")", ";", "}", "if", "(", "fqName", "==", "null", ")", "return", "null", ";", "CompilationUnit", "unit", "=", "mCompilationUnitMap", ".", "get", "(", "fqName", ")", ";", "if", "(", "unit", "==", "null", ")", "{", "if", "(", "!", "compiled", ")", "{", "unit", "=", "createCompilationUnit", "(", "fqName", ")", ";", "if", "(", "unit", "!=", "null", ")", "mCompilationUnitMap", ".", "put", "(", "fqName", ",", "unit", ")", ";", "}", "else", "{", "unit", "=", "new", "CompiledTemplate", "(", "name", ",", "this", ",", "from", ")", ";", "// if the CompiledTemplate class was precompiled (is valid) return the unit, otherwise return null to signify 'not found'", "if", "(", "(", "(", "CompiledTemplate", ")", "unit", ")", ".", "isValid", "(", ")", ")", "{", "mCompilationUnitMap", ".", "put", "(", "fqName", ",", "unit", ")", ";", "}", "else", "{", "// TODO: flag the template class for removal", "unit", "=", "null", ";", "}", "}", "}", "return", "unit", ";", "}" ]
Returns a compilation unit associated with the given name, or null if not found. @param name the requested name @param from optional CompilationUnit is passed because requested name should be found relative to it.
[ "Returns", "a", "compilation", "unit", "associated", "with", "the", "given", "name", "or", "null", "if", "not", "found", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Compiler.java#L603-L634
276
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Compiler.java
Compiler.addImportedPackages
public void addImportedPackages(String[] imports) { if (imports == null) { return; } for (String imported : imports) { this.mImports.add(imported); } }
java
public void addImportedPackages(String[] imports) { if (imports == null) { return; } for (String imported : imports) { this.mImports.add(imported); } }
[ "public", "void", "addImportedPackages", "(", "String", "[", "]", "imports", ")", "{", "if", "(", "imports", "==", "null", ")", "{", "return", ";", "}", "for", "(", "String", "imported", ":", "imports", ")", "{", "this", ".", "mImports", ".", "add", "(", "imported", ")", ";", "}", "}" ]
Add all imported packages that all templates will have. @param imports The fully-qualified package name
[ "Add", "all", "imported", "packages", "that", "all", "templates", "will", "have", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Compiler.java#L658-L664
277
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Compiler.java
Compiler.getStringConverterMethods
public final Method[] getStringConverterMethods() { if (mStringConverters == null) { String name = getRuntimeStringConverter(); Vector<Method> methods = new Vector<Method>(); if (name != null) { Method[] contextMethods = getRuntimeContextMethods(); for (int i=0; i<contextMethods.length; i++) { Method m = contextMethods[i]; if (m.getName().equals(name) && m.getReturnType() == String.class && m.getParameterTypes().length == 1) { methods.addElement(m); } } } int customSize = methods.size(); Method[] stringMethods = String.class.getMethods(); for (int i=0; i<stringMethods.length; i++) { Method m = stringMethods[i]; if (m.getName().equals("valueOf") && m.getReturnType() == String.class && m.getParameterTypes().length == 1 && Modifier.isStatic(m.getModifiers())) { // Don't add to list if a custom converter already handles // this method's parameter type. Class<?> type = m.getParameterTypes()[0]; int j; for (j=0; j<customSize; j++) { Method cm = methods.elementAt(j); if (cm.getParameterTypes()[0] == type) { break; } } if (j == customSize) { methods.addElement(m); } } } mStringConverters = new Method[methods.size()]; methods.copyInto(mStringConverters); } return mStringConverters.clone(); }
java
public final Method[] getStringConverterMethods() { if (mStringConverters == null) { String name = getRuntimeStringConverter(); Vector<Method> methods = new Vector<Method>(); if (name != null) { Method[] contextMethods = getRuntimeContextMethods(); for (int i=0; i<contextMethods.length; i++) { Method m = contextMethods[i]; if (m.getName().equals(name) && m.getReturnType() == String.class && m.getParameterTypes().length == 1) { methods.addElement(m); } } } int customSize = methods.size(); Method[] stringMethods = String.class.getMethods(); for (int i=0; i<stringMethods.length; i++) { Method m = stringMethods[i]; if (m.getName().equals("valueOf") && m.getReturnType() == String.class && m.getParameterTypes().length == 1 && Modifier.isStatic(m.getModifiers())) { // Don't add to list if a custom converter already handles // this method's parameter type. Class<?> type = m.getParameterTypes()[0]; int j; for (j=0; j<customSize; j++) { Method cm = methods.elementAt(j); if (cm.getParameterTypes()[0] == type) { break; } } if (j == customSize) { methods.addElement(m); } } } mStringConverters = new Method[methods.size()]; methods.copyInto(mStringConverters); } return mStringConverters.clone(); }
[ "public", "final", "Method", "[", "]", "getStringConverterMethods", "(", ")", "{", "if", "(", "mStringConverters", "==", "null", ")", "{", "String", "name", "=", "getRuntimeStringConverter", "(", ")", ";", "Vector", "<", "Method", ">", "methods", "=", "new", "Vector", "<", "Method", ">", "(", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "Method", "[", "]", "contextMethods", "=", "getRuntimeContextMethods", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "contextMethods", ".", "length", ";", "i", "++", ")", "{", "Method", "m", "=", "contextMethods", "[", "i", "]", ";", "if", "(", "m", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", "&&", "m", ".", "getReturnType", "(", ")", "==", "String", ".", "class", "&&", "m", ".", "getParameterTypes", "(", ")", ".", "length", "==", "1", ")", "{", "methods", ".", "addElement", "(", "m", ")", ";", "}", "}", "}", "int", "customSize", "=", "methods", ".", "size", "(", ")", ";", "Method", "[", "]", "stringMethods", "=", "String", ".", "class", ".", "getMethods", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "stringMethods", ".", "length", ";", "i", "++", ")", "{", "Method", "m", "=", "stringMethods", "[", "i", "]", ";", "if", "(", "m", ".", "getName", "(", ")", ".", "equals", "(", "\"valueOf\"", ")", "&&", "m", ".", "getReturnType", "(", ")", "==", "String", ".", "class", "&&", "m", ".", "getParameterTypes", "(", ")", ".", "length", "==", "1", "&&", "Modifier", ".", "isStatic", "(", "m", ".", "getModifiers", "(", ")", ")", ")", "{", "// Don't add to list if a custom converter already handles", "// this method's parameter type.", "Class", "<", "?", ">", "type", "=", "m", ".", "getParameterTypes", "(", ")", "[", "0", "]", ";", "int", "j", ";", "for", "(", "j", "=", "0", ";", "j", "<", "customSize", ";", "j", "++", ")", "{", "Method", "cm", "=", "methods", ".", "elementAt", "(", "j", ")", ";", "if", "(", "cm", ".", "getParameterTypes", "(", ")", "[", "0", "]", "==", "type", ")", "{", "break", ";", "}", "}", "if", "(", "j", "==", "customSize", ")", "{", "methods", ".", "addElement", "(", "m", ")", ";", "}", "}", "}", "mStringConverters", "=", "new", "Method", "[", "methods", ".", "size", "(", ")", "]", ";", "methods", ".", "copyInto", "(", "mStringConverters", ")", ";", "}", "return", "mStringConverters", ".", "clone", "(", ")", ";", "}" ]
Returns the set of methods that are used to perform conversion to strings. The compiler will bind to the closest matching method based on its parameter type.
[ "Returns", "the", "set", "of", "methods", "that", "are", "used", "to", "perform", "conversion", "to", "strings", ".", "The", "compiler", "will", "bind", "to", "the", "closest", "matching", "method", "based", "on", "its", "parameter", "type", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Compiler.java#L733-L784
278
teatrove/teatrove
tea/src/main/java/org/teatrove/tea/compiler/Compiler.java
Compiler.determineQualifiedName
private String determineQualifiedName(String name, CompilationUnit from) { if (from != null) { // Determine qualified name as being relative to "from" String fromName = from.getName(); int index = fromName.lastIndexOf('.'); if (index >= 0) { String qual = fromName.substring(0, index + 1) + name; if (sourceExists(qual)) { return qual; } } } if (sourceExists(name)) { return name; } return null; }
java
private String determineQualifiedName(String name, CompilationUnit from) { if (from != null) { // Determine qualified name as being relative to "from" String fromName = from.getName(); int index = fromName.lastIndexOf('.'); if (index >= 0) { String qual = fromName.substring(0, index + 1) + name; if (sourceExists(qual)) { return qual; } } } if (sourceExists(name)) { return name; } return null; }
[ "private", "String", "determineQualifiedName", "(", "String", "name", ",", "CompilationUnit", "from", ")", "{", "if", "(", "from", "!=", "null", ")", "{", "// Determine qualified name as being relative to \"from\"", "String", "fromName", "=", "from", ".", "getName", "(", ")", ";", "int", "index", "=", "fromName", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "index", ">=", "0", ")", "{", "String", "qual", "=", "fromName", ".", "substring", "(", "0", ",", "index", "+", "1", ")", "+", "name", ";", "if", "(", "sourceExists", "(", "qual", ")", ")", "{", "return", "qual", ";", "}", "}", "}", "if", "(", "sourceExists", "(", "name", ")", ")", "{", "return", "name", ";", "}", "return", "null", ";", "}" ]
Given a name, as requested by the given CompilationUnit, return a fully qualified name or null if the name could not be found. @param name requested name @param from optional CompilationUnit
[ "Given", "a", "name", "as", "requested", "by", "the", "given", "CompilationUnit", "return", "a", "fully", "qualified", "name", "or", "null", "if", "the", "name", "could", "not", "be", "found", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/compiler/Compiler.java#L793-L812
279
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/PatternMatcher.java
PatternMatcher.getMatch
public Result getMatch(String lookup) { int strLen = lookup.length(); char[] chars = new char[strLen + 1]; lookup.getChars(0, strLen, chars, 0); chars[strLen] = '\uffff'; TinyList resultList = new TinyList(); fillMatchResults(chars, 1, resultList); return (Result)resultList.mElement; }
java
public Result getMatch(String lookup) { int strLen = lookup.length(); char[] chars = new char[strLen + 1]; lookup.getChars(0, strLen, chars, 0); chars[strLen] = '\uffff'; TinyList resultList = new TinyList(); fillMatchResults(chars, 1, resultList); return (Result)resultList.mElement; }
[ "public", "Result", "getMatch", "(", "String", "lookup", ")", "{", "int", "strLen", "=", "lookup", ".", "length", "(", ")", ";", "char", "[", "]", "chars", "=", "new", "char", "[", "strLen", "+", "1", "]", ";", "lookup", ".", "getChars", "(", "0", ",", "strLen", ",", "chars", ",", "0", ")", ";", "chars", "[", "strLen", "]", "=", "'", "'", ";", "TinyList", "resultList", "=", "new", "TinyList", "(", ")", ";", "fillMatchResults", "(", "chars", ",", "1", ",", "resultList", ")", ";", "return", "(", "Result", ")", "resultList", ".", "mElement", ";", "}" ]
Returns null if no match.
[ "Returns", "null", "if", "no", "match", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/PatternMatcher.java#L128-L138
280
teatrove/teatrove
trove/src/main/java/org/teatrove/trove/util/PatternMatcher.java
PatternMatcher.addMatchResult
protected static boolean addMatchResult(int limit, List results, String pattern, Object value, int[] positions, int len) { int size = results.size(); if (size < limit) { if (positions == null || len == 0) { positions = NO_POSITIONS; } else { int[] original = positions; positions = new int[len]; for (int i=0; i<len; i++) { positions[i] = original[i]; } } results.add(new Result(pattern, value, positions)); return size + 1 < limit; } else { return false; } }
java
protected static boolean addMatchResult(int limit, List results, String pattern, Object value, int[] positions, int len) { int size = results.size(); if (size < limit) { if (positions == null || len == 0) { positions = NO_POSITIONS; } else { int[] original = positions; positions = new int[len]; for (int i=0; i<len; i++) { positions[i] = original[i]; } } results.add(new Result(pattern, value, positions)); return size + 1 < limit; } else { return false; } }
[ "protected", "static", "boolean", "addMatchResult", "(", "int", "limit", ",", "List", "results", ",", "String", "pattern", ",", "Object", "value", ",", "int", "[", "]", "positions", ",", "int", "len", ")", "{", "int", "size", "=", "results", ".", "size", "(", ")", ";", "if", "(", "size", "<", "limit", ")", "{", "if", "(", "positions", "==", "null", "||", "len", "==", "0", ")", "{", "positions", "=", "NO_POSITIONS", ";", "}", "else", "{", "int", "[", "]", "original", "=", "positions", ";", "positions", "=", "new", "int", "[", "len", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "positions", "[", "i", "]", "=", "original", "[", "i", "]", ";", "}", "}", "results", ".", "add", "(", "new", "Result", "(", "pattern", ",", "value", ",", "positions", ")", ")", ";", "return", "size", "+", "1", "<", "limit", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Returns false if no more results should be added.
[ "Returns", "false", "if", "no", "more", "results", "should", "be", "added", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/PatternMatcher.java#L161-L186
281
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.endsWith
public boolean endsWith(String str, String suffix) { return (str == null || suffix == null) ? (str == suffix) : str.endsWith(suffix); }
java
public boolean endsWith(String str, String suffix) { return (str == null || suffix == null) ? (str == suffix) : str.endsWith(suffix); }
[ "public", "boolean", "endsWith", "(", "String", "str", ",", "String", "suffix", ")", "{", "return", "(", "str", "==", "null", "||", "suffix", "==", "null", ")", "?", "(", "str", "==", "suffix", ")", ":", "str", ".", "endsWith", "(", "suffix", ")", ";", "}" ]
Tests if the given string ends with the given suffix. Returns true if the given string ends with the given suffix. @param str the source string @param suffix the suffix to test for @return true if the given string ends with the given suffix
[ "Tests", "if", "the", "given", "string", "ends", "with", "the", "given", "suffix", ".", "Returns", "true", "if", "the", "given", "string", "ends", "with", "the", "given", "suffix", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L55-L58
282
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.find
public int[] find(String str, String search, int fromIndex) { if (str == null || search == null) { return new int[0]; } int[] indices = new int[10]; int size = 0; int index = fromIndex; while ((index = str.indexOf(search, index)) >= 0) { if (size >= indices.length) { // Expand capacity. int[] newArray = new int[indices.length * 2]; System.arraycopy(indices, 0, newArray, 0, indices.length); indices = newArray; } indices[size++] = index; index += search.length(); } if (size < indices.length) { // Trim capacity. int[] newArray = new int[size]; System.arraycopy(indices, 0, newArray, 0, size); indices = newArray; } return indices; }
java
public int[] find(String str, String search, int fromIndex) { if (str == null || search == null) { return new int[0]; } int[] indices = new int[10]; int size = 0; int index = fromIndex; while ((index = str.indexOf(search, index)) >= 0) { if (size >= indices.length) { // Expand capacity. int[] newArray = new int[indices.length * 2]; System.arraycopy(indices, 0, newArray, 0, indices.length); indices = newArray; } indices[size++] = index; index += search.length(); } if (size < indices.length) { // Trim capacity. int[] newArray = new int[size]; System.arraycopy(indices, 0, newArray, 0, size); indices = newArray; } return indices; }
[ "public", "int", "[", "]", "find", "(", "String", "str", ",", "String", "search", ",", "int", "fromIndex", ")", "{", "if", "(", "str", "==", "null", "||", "search", "==", "null", ")", "{", "return", "new", "int", "[", "0", "]", ";", "}", "int", "[", "]", "indices", "=", "new", "int", "[", "10", "]", ";", "int", "size", "=", "0", ";", "int", "index", "=", "fromIndex", ";", "while", "(", "(", "index", "=", "str", ".", "indexOf", "(", "search", ",", "index", ")", ")", ">=", "0", ")", "{", "if", "(", "size", ">=", "indices", ".", "length", ")", "{", "// Expand capacity.", "int", "[", "]", "newArray", "=", "new", "int", "[", "indices", ".", "length", "*", "2", "]", ";", "System", ".", "arraycopy", "(", "indices", ",", "0", ",", "newArray", ",", "0", ",", "indices", ".", "length", ")", ";", "indices", "=", "newArray", ";", "}", "indices", "[", "size", "++", "]", "=", "index", ";", "index", "+=", "search", ".", "length", "(", ")", ";", "}", "if", "(", "size", "<", "indices", ".", "length", ")", "{", "// Trim capacity.", "int", "[", "]", "newArray", "=", "new", "int", "[", "size", "]", ";", "System", ".", "arraycopy", "(", "indices", ",", "0", ",", "newArray", ",", "0", ",", "size", ")", ";", "indices", "=", "newArray", ";", "}", "return", "indices", ";", "}" ]
Finds the indices for each occurrence of the given search string in the source string, starting from the given index. @param str the source string @param search the string to search for @param fromIndex index to start the find @return an array of indices, which is empty if the search string wasn't found
[ "Finds", "the", "indices", "for", "each", "occurrence", "of", "the", "given", "search", "string", "in", "the", "source", "string", "starting", "from", "the", "given", "index", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L86-L114
283
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.findFirst
public int findFirst(String str, String search) { return (str == null || search == null) ? -1 : str.indexOf(search); }
java
public int findFirst(String str, String search) { return (str == null || search == null) ? -1 : str.indexOf(search); }
[ "public", "int", "findFirst", "(", "String", "str", ",", "String", "search", ")", "{", "return", "(", "str", "==", "null", "||", "search", "==", "null", ")", "?", "-", "1", ":", "str", ".", "indexOf", "(", "search", ")", ";", "}" ]
Finds the index of the first occurrence of the given search string in the source string, or -1 if not found. @param str the source string @param search the string to search for @return the start index of the found string or -1 if not found
[ "Finds", "the", "index", "of", "the", "first", "occurrence", "of", "the", "given", "search", "string", "in", "the", "source", "string", "or", "-", "1", "if", "not", "found", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L125-L128
284
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.substring
public String substring(String str, int startIndex, int endIndex) { return (str == null) ? null : str.substring(startIndex, endIndex); }
java
public String substring(String str, int startIndex, int endIndex) { return (str == null) ? null : str.substring(startIndex, endIndex); }
[ "public", "String", "substring", "(", "String", "str", ",", "int", "startIndex", ",", "int", "endIndex", ")", "{", "return", "(", "str", "==", "null", ")", "?", "null", ":", "str", ".", "substring", "(", "startIndex", ",", "endIndex", ")", ";", "}" ]
Returns a sub-portion of the given string for the characters that are at or after the starting index, and are before the end index. @param str the source string @param startIndex the start index, inclusive @param endIndex the ending index, exclusive @return the specified substring.
[ "Returns", "a", "sub", "-", "portion", "of", "the", "given", "string", "for", "the", "characters", "that", "are", "at", "or", "after", "the", "starting", "index", "and", "are", "before", "the", "end", "index", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L197-L199
285
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.trimLeading
public String trimLeading(String str) { if (str == null) { return null; } int length = str.length(); for (int i=0; i<length; i++) { if (str.charAt(i) > ' ') { return str.substring(i); } } return ""; }
java
public String trimLeading(String str) { if (str == null) { return null; } int length = str.length(); for (int i=0; i<length; i++) { if (str.charAt(i) > ' ') { return str.substring(i); } } return ""; }
[ "public", "String", "trimLeading", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "null", ";", "}", "int", "length", "=", "str", ".", "length", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "str", ".", "charAt", "(", "i", ")", ">", "'", "'", ")", "{", "return", "str", ".", "substring", "(", "i", ")", ";", "}", "}", "return", "\"\"", ";", "}" ]
Trims all leading whitespace characters from the given string. @param str the string to trim @return the trimmed string
[ "Trims", "all", "leading", "whitespace", "characters", "from", "the", "given", "string", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L242-L255
286
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.trimTrailing
public String trimTrailing(String str) { if (str == null) { return null; } int length = str.length(); for (int i=length-1; i>=0; i--) { if (str.charAt(i) > ' ') { return str.substring(0, i + 1); } } return ""; }
java
public String trimTrailing(String str) { if (str == null) { return null; } int length = str.length(); for (int i=length-1; i>=0; i--) { if (str.charAt(i) > ' ') { return str.substring(0, i + 1); } } return ""; }
[ "public", "String", "trimTrailing", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "null", ";", "}", "int", "length", "=", "str", ".", "length", "(", ")", ";", "for", "(", "int", "i", "=", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "str", ".", "charAt", "(", "i", ")", ">", "'", "'", ")", "{", "return", "str", ".", "substring", "(", "0", ",", "i", "+", "1", ")", ";", "}", "}", "return", "\"\"", ";", "}" ]
Trims all trailing whitespace characters from the given string. @param str the string to trim @return the trimmed string
[ "Trims", "all", "trailing", "whitespace", "characters", "from", "the", "given", "string", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L264-L277
287
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.split
public String[] split(String str, String regex, int limit) { return str.split(regex, limit); }
java
public String[] split(String str, String regex, int limit) { return str.split(regex, limit); }
[ "public", "String", "[", "]", "split", "(", "String", "str", ",", "String", "regex", ",", "int", "limit", ")", "{", "return", "str", ".", "split", "(", "regex", ",", "limit", ")", ";", "}" ]
Split the given string with the given regular expression returning the array of strings after splitting. @param str The string to split @param regex The regular expression to split on @param limit The maximum number of split values @return The array of split strings @see String#split(String)
[ "Split", "the", "given", "string", "with", "the", "given", "regular", "expression", "returning", "the", "array", "of", "strings", "after", "splitting", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L432-L434
288
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.splitString
public String[] splitString(String text, int maxChars) { String[] splitVals = {" "}; return splitString(text,maxChars,splitVals); }
java
public String[] splitString(String text, int maxChars) { String[] splitVals = {" "}; return splitString(text,maxChars,splitVals); }
[ "public", "String", "[", "]", "splitString", "(", "String", "text", ",", "int", "maxChars", ")", "{", "String", "[", "]", "splitVals", "=", "{", "\" \"", "}", ";", "return", "splitString", "(", "text", ",", "maxChars", ",", "splitVals", ")", ";", "}" ]
Split the given string on spaces ensuring the maximum number of characters in each token. @param text The value to split @param maxChars The maximum required characters in each split token @return The array of tokens from splitting the string @see #splitString(String, int, String[])
[ "Split", "the", "given", "string", "on", "spaces", "ensuring", "the", "maximum", "number", "of", "characters", "in", "each", "token", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L471-L474
289
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.splitString
public String[] splitString(String text, int maxChars, String[] splitValues) { String restOfText = text; List<String> list = new ArrayList<String>(); while (restOfText.length() > maxChars) { String thisLine = restOfText.substring(0,maxChars); int lineEnd = 0; for (int i = 0; i < splitValues.length;i++) { int lastIndex = thisLine.lastIndexOf(splitValues[i]); if (lastIndex > lineEnd) { lineEnd = lastIndex; } } if (lineEnd == 0) { list.add(thisLine); restOfText = restOfText.substring(maxChars); } else { list.add(thisLine.substring(0,lineEnd)); restOfText = restOfText.substring(lineEnd); } } list.add(restOfText); return list.toArray(new String[list.size()]); }
java
public String[] splitString(String text, int maxChars, String[] splitValues) { String restOfText = text; List<String> list = new ArrayList<String>(); while (restOfText.length() > maxChars) { String thisLine = restOfText.substring(0,maxChars); int lineEnd = 0; for (int i = 0; i < splitValues.length;i++) { int lastIndex = thisLine.lastIndexOf(splitValues[i]); if (lastIndex > lineEnd) { lineEnd = lastIndex; } } if (lineEnd == 0) { list.add(thisLine); restOfText = restOfText.substring(maxChars); } else { list.add(thisLine.substring(0,lineEnd)); restOfText = restOfText.substring(lineEnd); } } list.add(restOfText); return list.toArray(new String[list.size()]); }
[ "public", "String", "[", "]", "splitString", "(", "String", "text", ",", "int", "maxChars", ",", "String", "[", "]", "splitValues", ")", "{", "String", "restOfText", "=", "text", ";", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "while", "(", "restOfText", ".", "length", "(", ")", ">", "maxChars", ")", "{", "String", "thisLine", "=", "restOfText", ".", "substring", "(", "0", ",", "maxChars", ")", ";", "int", "lineEnd", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "splitValues", ".", "length", ";", "i", "++", ")", "{", "int", "lastIndex", "=", "thisLine", ".", "lastIndexOf", "(", "splitValues", "[", "i", "]", ")", ";", "if", "(", "lastIndex", ">", "lineEnd", ")", "{", "lineEnd", "=", "lastIndex", ";", "}", "}", "if", "(", "lineEnd", "==", "0", ")", "{", "list", ".", "add", "(", "thisLine", ")", ";", "restOfText", "=", "restOfText", ".", "substring", "(", "maxChars", ")", ";", "}", "else", "{", "list", ".", "add", "(", "thisLine", ".", "substring", "(", "0", ",", "lineEnd", ")", ")", ";", "restOfText", "=", "restOfText", ".", "substring", "(", "lineEnd", ")", ";", "}", "}", "list", ".", "add", "(", "restOfText", ")", ";", "return", "list", ".", "toArray", "(", "new", "String", "[", "list", ".", "size", "(", ")", "]", ")", ";", "}" ]
Split the given string on the given split values ensuring the maximum number of characters in each token. @param text The value to split @param maxChars The maximum required characters in each split token @param splitValues The set of values to split on @return The array of tokens from splitting the string
[ "Split", "the", "given", "string", "on", "the", "given", "split", "values", "ensuring", "the", "maximum", "number", "of", "characters", "in", "each", "token", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L486-L511
290
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.tokenize
public String[] tokenize(String string, String token) { String[] result; try { StringTokenizer st = new StringTokenizer(string, token); List<String> list = new ArrayList<String>(); while (st.hasMoreTokens()) { list.add(st.nextToken()); } result = list.toArray(new String[list.size()]); } catch (Exception e) { result = null; } return result; }
java
public String[] tokenize(String string, String token) { String[] result; try { StringTokenizer st = new StringTokenizer(string, token); List<String> list = new ArrayList<String>(); while (st.hasMoreTokens()) { list.add(st.nextToken()); } result = list.toArray(new String[list.size()]); } catch (Exception e) { result = null; } return result; }
[ "public", "String", "[", "]", "tokenize", "(", "String", "string", ",", "String", "token", ")", "{", "String", "[", "]", "result", ";", "try", "{", "StringTokenizer", "st", "=", "new", "StringTokenizer", "(", "string", ",", "token", ")", ";", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "while", "(", "st", ".", "hasMoreTokens", "(", ")", ")", "{", "list", ".", "add", "(", "st", ".", "nextToken", "(", ")", ")", ";", "}", "result", "=", "list", ".", "toArray", "(", "new", "String", "[", "list", ".", "size", "(", ")", "]", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "result", "=", "null", ";", "}", "return", "result", ";", "}" ]
Tokenize the given string with the given token. This will return an array of strings containing each token delimited by the given value. @param string The string to tokenize @param token The token delimiter to delimit on @return The array of tokens based on the delimiter @see StringTokenizer
[ "Tokenize", "the", "given", "string", "with", "the", "given", "token", ".", "This", "will", "return", "an", "array", "of", "strings", "containing", "each", "token", "delimited", "by", "the", "given", "value", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L524-L537
291
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.addToStringArray
public String[] addToStringArray(String[] strArray, String str) { String[] result = null; if (strArray != null) { result = new String[strArray.length + 1]; System.arraycopy(strArray, 0, result, 0, strArray.length); result[strArray.length] = str; } return result; }
java
public String[] addToStringArray(String[] strArray, String str) { String[] result = null; if (strArray != null) { result = new String[strArray.length + 1]; System.arraycopy(strArray, 0, result, 0, strArray.length); result[strArray.length] = str; } return result; }
[ "public", "String", "[", "]", "addToStringArray", "(", "String", "[", "]", "strArray", ",", "String", "str", ")", "{", "String", "[", "]", "result", "=", "null", ";", "if", "(", "strArray", "!=", "null", ")", "{", "result", "=", "new", "String", "[", "strArray", ".", "length", "+", "1", "]", ";", "System", ".", "arraycopy", "(", "strArray", ",", "0", ",", "result", ",", "0", ",", "strArray", ".", "length", ")", ";", "result", "[", "strArray", ".", "length", "]", "=", "str", ";", "}", "return", "result", ";", "}" ]
Add the given string to the string array. This will create a new array expanded by one element, copy the existing array, add the given value, and return the resulting array. @param strArray The array of strings to add to @param str The string to add @return A new array containing the string array and the given string
[ "Add", "the", "given", "string", "to", "the", "string", "array", ".", "This", "will", "create", "a", "new", "array", "expanded", "by", "one", "element", "copy", "the", "existing", "array", "add", "the", "given", "value", "and", "return", "the", "resulting", "array", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L549-L557
292
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.removeFromStringArray
public String[] removeFromStringArray(String[] strArray, String str) { String[] result = null; if (strArray != null && strArray.length > 0) { List<String> list = new ArrayList<String>(); for (int i=0; i < strArray.length; i++) { if (!strArray[i].equals(str)) { list.add(strArray[i]); } } int size = list.size(); if (size > 0) { result = list.toArray(new String[size]); } } return result; }
java
public String[] removeFromStringArray(String[] strArray, String str) { String[] result = null; if (strArray != null && strArray.length > 0) { List<String> list = new ArrayList<String>(); for (int i=0; i < strArray.length; i++) { if (!strArray[i].equals(str)) { list.add(strArray[i]); } } int size = list.size(); if (size > 0) { result = list.toArray(new String[size]); } } return result; }
[ "public", "String", "[", "]", "removeFromStringArray", "(", "String", "[", "]", "strArray", ",", "String", "str", ")", "{", "String", "[", "]", "result", "=", "null", ";", "if", "(", "strArray", "!=", "null", "&&", "strArray", ".", "length", ">", "0", ")", "{", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "strArray", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "strArray", "[", "i", "]", ".", "equals", "(", "str", ")", ")", "{", "list", ".", "add", "(", "strArray", "[", "i", "]", ")", ";", "}", "}", "int", "size", "=", "list", ".", "size", "(", ")", ";", "if", "(", "size", ">", "0", ")", "{", "result", "=", "list", ".", "toArray", "(", "new", "String", "[", "size", "]", ")", ";", "}", "}", "return", "result", ";", "}" ]
Remove all occurrences of the given string from the given array. This will create a new array containing all elements of the given array except for those matching the given value. @param strArray The array of strings to remove from @param str The value to remove @return A new array containing the given array excluding the given string
[ "Remove", "all", "occurrences", "of", "the", "given", "string", "from", "the", "given", "array", ".", "This", "will", "create", "a", "new", "array", "containing", "all", "elements", "of", "the", "given", "array", "except", "for", "those", "matching", "the", "given", "value", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L580-L595
293
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.removeFromStringArray
public String[] removeFromStringArray(String[] strArray, int index) { String[] result = null; if (strArray != null && index > 0 && index < strArray.length) { result = new String[strArray.length - 1]; for (int i=0, j=0; i < strArray.length; i++) { if (i != index) { result[j++] = strArray[i]; } } } return result; }
java
public String[] removeFromStringArray(String[] strArray, int index) { String[] result = null; if (strArray != null && index > 0 && index < strArray.length) { result = new String[strArray.length - 1]; for (int i=0, j=0; i < strArray.length; i++) { if (i != index) { result[j++] = strArray[i]; } } } return result; }
[ "public", "String", "[", "]", "removeFromStringArray", "(", "String", "[", "]", "strArray", ",", "int", "index", ")", "{", "String", "[", "]", "result", "=", "null", ";", "if", "(", "strArray", "!=", "null", "&&", "index", ">", "0", "&&", "index", "<", "strArray", ".", "length", ")", "{", "result", "=", "new", "String", "[", "strArray", ".", "length", "-", "1", "]", ";", "for", "(", "int", "i", "=", "0", ",", "j", "=", "0", ";", "i", "<", "strArray", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "index", ")", "{", "result", "[", "j", "++", "]", "=", "strArray", "[", "i", "]", ";", "}", "}", "}", "return", "result", ";", "}" ]
Remove the string at the given index from the given array. This will return a new array containing the given array excluding the element at the given index. @param strArray The string array to remove from @param index The index of the element to remove @return A new array containing the given array excluding the given index
[ "Remove", "the", "string", "at", "the", "given", "index", "from", "the", "given", "array", ".", "This", "will", "return", "a", "new", "array", "containing", "the", "given", "array", "excluding", "the", "element", "at", "the", "given", "index", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L607-L618
294
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.setInStringArray
public boolean setInStringArray(String[] strArray, int index, String str) { boolean result = false; if (strArray != null && index >= 0 && index < strArray.length) { strArray[index] = str; result = true; } return result; }
java
public boolean setInStringArray(String[] strArray, int index, String str) { boolean result = false; if (strArray != null && index >= 0 && index < strArray.length) { strArray[index] = str; result = true; } return result; }
[ "public", "boolean", "setInStringArray", "(", "String", "[", "]", "strArray", ",", "int", "index", ",", "String", "str", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "strArray", "!=", "null", "&&", "index", ">=", "0", "&&", "index", "<", "strArray", ".", "length", ")", "{", "strArray", "[", "index", "]", "=", "str", ";", "result", "=", "true", ";", "}", "return", "result", ";", "}" ]
Set the given string in the given array at the given index. This will overwrite the existing value at the given index. @param strArray The array to set in @param index The index of the element to overwrite @param str The string value to set @return <code>true</code> if the index was valid and the value was set, <code>false</code> otherwise
[ "Set", "the", "given", "string", "in", "the", "given", "array", "at", "the", "given", "index", ".", "This", "will", "overwrite", "the", "existing", "value", "at", "the", "given", "index", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L631-L638
295
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.convertToEncoding
public String convertToEncoding(String subject, String encoding) throws UnsupportedEncodingException { return new String(subject.getBytes(encoding), encoding); }
java
public String convertToEncoding(String subject, String encoding) throws UnsupportedEncodingException { return new String(subject.getBytes(encoding), encoding); }
[ "public", "String", "convertToEncoding", "(", "String", "subject", ",", "String", "encoding", ")", "throws", "UnsupportedEncodingException", "{", "return", "new", "String", "(", "subject", ".", "getBytes", "(", "encoding", ")", ",", "encoding", ")", ";", "}" ]
Convert the given string to the given encoding. @param subject The value to convert @param encoding The name of the encoding/character set @return A new string in the given encoding @throws UnsupportedEncodingException if the encoding is invalid
[ "Convert", "the", "given", "string", "to", "the", "given", "encoding", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L735-L739
296
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.replaceFirstRegex
public String replaceFirstRegex(String subject, String regex, String replacement) { return subject.replaceFirst(regex, replacement); }
java
public String replaceFirstRegex(String subject, String regex, String replacement) { return subject.replaceFirst(regex, replacement); }
[ "public", "String", "replaceFirstRegex", "(", "String", "subject", ",", "String", "regex", ",", "String", "replacement", ")", "{", "return", "subject", ".", "replaceFirst", "(", "regex", ",", "replacement", ")", ";", "}" ]
Replace the given regular expression pattern with the given replacement. Only the first match will be replaced. @param subject The value to replace @param regex The regular expression pattern to match @param replacement The replacement value @return A new string based on the replacement of the expression @see String#replaceFirst(String, String)
[ "Replace", "the", "given", "regular", "expression", "pattern", "with", "the", "given", "replacement", ".", "Only", "the", "first", "match", "will", "be", "replaced", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L753-L756
297
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.replaceAllRegex
public String replaceAllRegex(String subject, String regex, String replacement) { return subject.replaceAll(regex, replacement); }
java
public String replaceAllRegex(String subject, String regex, String replacement) { return subject.replaceAll(regex, replacement); }
[ "public", "String", "replaceAllRegex", "(", "String", "subject", ",", "String", "regex", ",", "String", "replacement", ")", "{", "return", "subject", ".", "replaceAll", "(", "regex", ",", "replacement", ")", ";", "}" ]
Replace the given regular expression pattern with the given replacement. This will replace all matches in the given string. @param subject The value to replace @param regex The regular expression pattern to match @param replacement The replacement value @return A new string based on the replacement of the expression @see String#replaceAll(String, String)
[ "Replace", "the", "given", "regular", "expression", "pattern", "with", "the", "given", "replacement", ".", "This", "will", "replace", "all", "matches", "in", "the", "given", "string", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L770-L773
298
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.append
public void append(StringBuilder buffer, Object value) { if (buffer == null) { throw new NullPointerException("buffer"); } buffer.append(value); }
java
public void append(StringBuilder buffer, Object value) { if (buffer == null) { throw new NullPointerException("buffer"); } buffer.append(value); }
[ "public", "void", "append", "(", "StringBuilder", "buffer", ",", "Object", "value", ")", "{", "if", "(", "buffer", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"buffer\"", ")", ";", "}", "buffer", ".", "append", "(", "value", ")", ";", "}" ]
A function to append a value to an existing buffer. @param buffer the buffer to append to @param value the value to append
[ "A", "function", "to", "append", "a", "value", "to", "an", "existing", "buffer", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L803-L809
299
teatrove/teatrove
teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java
StringContext.prepend
public void prepend(StringBuilder buffer, Object value) { if (buffer == null) { throw new NullPointerException("buffer"); } buffer.insert(0, value); }
java
public void prepend(StringBuilder buffer, Object value) { if (buffer == null) { throw new NullPointerException("buffer"); } buffer.insert(0, value); }
[ "public", "void", "prepend", "(", "StringBuilder", "buffer", ",", "Object", "value", ")", "{", "if", "(", "buffer", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"buffer\"", ")", ";", "}", "buffer", ".", "insert", "(", "0", ",", "value", ")", ";", "}" ]
A function to prepend a value to an existing buffer. @param buffer the buffer to prepend to @param value the value to prepend
[ "A", "function", "to", "prepend", "a", "value", "to", "an", "existing", "buffer", "." ]
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/StringContext.java#L817-L823