id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
154,600
jbundle/jbundle
thin/base/db/misc/src/main/java/org/jbundle/thin/base/db/client/CachedRemoteTable.java
CachedRemoteTable.setCache
public boolean setCache(Object objTargetRow, Object data) { if (objTargetRow != NONE) { if (m_mapCache != null) { int iTargetRow = ((Integer)objTargetRow).intValue(); int iCurrentPhysicalRecord = ((Integer)m_objCurrentPhysicalRecord).intValue(); if (iTargetRow == iCurrentPhysicalRecord) { // Reset the current record m_objCurrentPhysicalRecord = NONE; m_objCurrentCacheRecord = NONE; m_objCurrentLockedRecord = NONE; } if (m_iPhysicalLastRecordPlusOne == iTargetRow) m_iPhysicalLastRecordPlusOne++; m_mapCache.set(iTargetRow, data); // Make sure the cache matches the actual return true; } if (m_htCache != null) { if (objTargetRow.equals(m_objCurrentPhysicalRecord)) { // Reset the current record. m_objCurrentPhysicalRecord = NONE; m_objCurrentCacheRecord = NONE; m_objCurrentLockedRecord = NONE; } if (data != null) m_htCache.put(objTargetRow, data); // Make sure the cache matches the actual else m_htCache.remove(objTargetRow); return true; } } return false; // nothing updated }
java
public boolean setCache(Object objTargetRow, Object data) { if (objTargetRow != NONE) { if (m_mapCache != null) { int iTargetRow = ((Integer)objTargetRow).intValue(); int iCurrentPhysicalRecord = ((Integer)m_objCurrentPhysicalRecord).intValue(); if (iTargetRow == iCurrentPhysicalRecord) { // Reset the current record m_objCurrentPhysicalRecord = NONE; m_objCurrentCacheRecord = NONE; m_objCurrentLockedRecord = NONE; } if (m_iPhysicalLastRecordPlusOne == iTargetRow) m_iPhysicalLastRecordPlusOne++; m_mapCache.set(iTargetRow, data); // Make sure the cache matches the actual return true; } if (m_htCache != null) { if (objTargetRow.equals(m_objCurrentPhysicalRecord)) { // Reset the current record. m_objCurrentPhysicalRecord = NONE; m_objCurrentCacheRecord = NONE; m_objCurrentLockedRecord = NONE; } if (data != null) m_htCache.put(objTargetRow, data); // Make sure the cache matches the actual else m_htCache.remove(objTargetRow); return true; } } return false; // nothing updated }
[ "public", "boolean", "setCache", "(", "Object", "objTargetRow", ",", "Object", "data", ")", "{", "if", "(", "objTargetRow", "!=", "NONE", ")", "{", "if", "(", "m_mapCache", "!=", "null", ")", "{", "int", "iTargetRow", "=", "(", "(", "Integer", ")", "objTargetRow", ")", ".", "intValue", "(", ")", ";", "int", "iCurrentPhysicalRecord", "=", "(", "(", "Integer", ")", "m_objCurrentPhysicalRecord", ")", ".", "intValue", "(", ")", ";", "if", "(", "iTargetRow", "==", "iCurrentPhysicalRecord", ")", "{", "// Reset the current record", "m_objCurrentPhysicalRecord", "=", "NONE", ";", "m_objCurrentCacheRecord", "=", "NONE", ";", "m_objCurrentLockedRecord", "=", "NONE", ";", "}", "if", "(", "m_iPhysicalLastRecordPlusOne", "==", "iTargetRow", ")", "m_iPhysicalLastRecordPlusOne", "++", ";", "m_mapCache", ".", "set", "(", "iTargetRow", ",", "data", ")", ";", "// Make sure the cache matches the actual", "return", "true", ";", "}", "if", "(", "m_htCache", "!=", "null", ")", "{", "if", "(", "objTargetRow", ".", "equals", "(", "m_objCurrentPhysicalRecord", ")", ")", "{", "// Reset the current record.", "m_objCurrentPhysicalRecord", "=", "NONE", ";", "m_objCurrentCacheRecord", "=", "NONE", ";", "m_objCurrentLockedRecord", "=", "NONE", ";", "}", "if", "(", "data", "!=", "null", ")", "m_htCache", ".", "put", "(", "objTargetRow", ",", "data", ")", ";", "// Make sure the cache matches the actual", "else", "m_htCache", ".", "remove", "(", "objTargetRow", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "// nothing updated", "}" ]
Clear this entry in the cache, so the next access will get the remote data. @param iTargetRow Row that needs to be updated. @param data Data that this row should contain (null to clear the cache entry).
[ "Clear", "this", "entry", "in", "the", "cache", "so", "the", "next", "access", "will", "get", "the", "remote", "data", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/misc/src/main/java/org/jbundle/thin/base/db/client/CachedRemoteTable.java#L592-L627
154,601
jbundle/jbundle
thin/base/db/misc/src/main/java/org/jbundle/thin/base/db/client/CachedRemoteTable.java
CachedRemoteTable.makeFieldList
public org.jbundle.thin.base.db.FieldList makeFieldList(String strFieldsToInclude) throws RemoteException { return m_tableRemote.makeFieldList(strFieldsToInclude); }
java
public org.jbundle.thin.base.db.FieldList makeFieldList(String strFieldsToInclude) throws RemoteException { return m_tableRemote.makeFieldList(strFieldsToInclude); }
[ "public", "org", ".", "jbundle", ".", "thin", ".", "base", ".", "db", ".", "FieldList", "makeFieldList", "(", "String", "strFieldsToInclude", ")", "throws", "RemoteException", "{", "return", "m_tableRemote", ".", "makeFieldList", "(", "strFieldsToInclude", ")", ";", "}" ]
make a thin FieldList for this table. Usually used for special queries that don't have a field list available.
[ "make", "a", "thin", "FieldList", "for", "this", "table", ".", "Usually", "used", "for", "special", "queries", "that", "don", "t", "have", "a", "field", "list", "available", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/misc/src/main/java/org/jbundle/thin/base/db/client/CachedRemoteTable.java#L658-L661
154,602
jbundle/jbundle
thin/base/db/misc/src/main/java/org/jbundle/thin/base/db/client/CachedRemoteTable.java
CachedRemoteTable.setCacheMode
public CacheMode setCacheMode(CacheMode cacheMode, FieldList record) { CacheMode oldCacheMode = this.cacheMode; this.cacheMode = cacheMode; if ((cacheMode == CacheMode.PASSIVE_CACHE) && (oldCacheMode != CacheMode.PASSIVE_CACHE)) { // Need to make sure current record is read. m_mapCache = null; m_htCache = null; if (record != null) { try { if (record.getEditMode() == Constants.EDIT_CURRENT) { record.getTable().setHandle(record.getCounterField().getData(), 0); } if (record.getEditMode() == Constants.EDIT_IN_PROGRESS) { record.getTable().setHandle(record.getCounterField().getData(), 0); record.getTable().edit(); // Re-read the current record. } } catch (DBException e) { e.printStackTrace(); } } } return oldCacheMode; }
java
public CacheMode setCacheMode(CacheMode cacheMode, FieldList record) { CacheMode oldCacheMode = this.cacheMode; this.cacheMode = cacheMode; if ((cacheMode == CacheMode.PASSIVE_CACHE) && (oldCacheMode != CacheMode.PASSIVE_CACHE)) { // Need to make sure current record is read. m_mapCache = null; m_htCache = null; if (record != null) { try { if (record.getEditMode() == Constants.EDIT_CURRENT) { record.getTable().setHandle(record.getCounterField().getData(), 0); } if (record.getEditMode() == Constants.EDIT_IN_PROGRESS) { record.getTable().setHandle(record.getCounterField().getData(), 0); record.getTable().edit(); // Re-read the current record. } } catch (DBException e) { e.printStackTrace(); } } } return oldCacheMode; }
[ "public", "CacheMode", "setCacheMode", "(", "CacheMode", "cacheMode", ",", "FieldList", "record", ")", "{", "CacheMode", "oldCacheMode", "=", "this", ".", "cacheMode", ";", "this", ".", "cacheMode", "=", "cacheMode", ";", "if", "(", "(", "cacheMode", "==", "CacheMode", ".", "PASSIVE_CACHE", ")", "&&", "(", "oldCacheMode", "!=", "CacheMode", ".", "PASSIVE_CACHE", ")", ")", "{", "// Need to make sure current record is read.", "m_mapCache", "=", "null", ";", "m_htCache", "=", "null", ";", "if", "(", "record", "!=", "null", ")", "{", "try", "{", "if", "(", "record", ".", "getEditMode", "(", ")", "==", "Constants", ".", "EDIT_CURRENT", ")", "{", "record", ".", "getTable", "(", ")", ".", "setHandle", "(", "record", ".", "getCounterField", "(", ")", ".", "getData", "(", ")", ",", "0", ")", ";", "}", "if", "(", "record", ".", "getEditMode", "(", ")", "==", "Constants", ".", "EDIT_IN_PROGRESS", ")", "{", "record", ".", "getTable", "(", ")", ".", "setHandle", "(", "record", ".", "getCounterField", "(", ")", ".", "getData", "(", ")", ",", "0", ")", ";", "record", ".", "getTable", "(", ")", ".", "edit", "(", ")", ";", "// Re-read the current record.", "}", "}", "catch", "(", "DBException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "return", "oldCacheMode", ";", "}" ]
Change the cache mode @param cacheMode @param record @return The old cache mode
[ "Change", "the", "cache", "mode" ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/misc/src/main/java/org/jbundle/thin/base/db/client/CachedRemoteTable.java#L720-L746
154,603
tvesalainen/util
util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java
FilterByteBuffer.getString
public String getString(Charset charset) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte cc = get(); while (cc != 0) { baos.write(cc); cc = get(); } byte[] buf = baos.toByteArray(); return new String(buf, charset); }
java
public String getString(Charset charset) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte cc = get(); while (cc != 0) { baos.write(cc); cc = get(); } byte[] buf = baos.toByteArray(); return new String(buf, charset); }
[ "public", "String", "getString", "(", "Charset", "charset", ")", "throws", "IOException", "{", "ByteArrayOutputStream", "baos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "byte", "cc", "=", "get", "(", ")", ";", "while", "(", "cc", "!=", "0", ")", "{", "baos", ".", "write", "(", "cc", ")", ";", "cc", "=", "get", "(", ")", ";", "}", "byte", "[", "]", "buf", "=", "baos", ".", "toByteArray", "(", ")", ";", "return", "new", "String", "(", "buf", ",", "charset", ")", ";", "}" ]
returns null terminated string @param charset @return @throws IOException
[ "returns", "null", "terminated", "string" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java#L161-L172
154,604
tvesalainen/util
util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java
FilterByteBuffer.putString
public FilterByteBuffer putString(String str, Charset charset) throws IOException { byte[] bytes = str.getBytes(charset); put(bytes).put((byte)0); return this; }
java
public FilterByteBuffer putString(String str, Charset charset) throws IOException { byte[] bytes = str.getBytes(charset); put(bytes).put((byte)0); return this; }
[ "public", "FilterByteBuffer", "putString", "(", "String", "str", ",", "Charset", "charset", ")", "throws", "IOException", "{", "byte", "[", "]", "bytes", "=", "str", ".", "getBytes", "(", "charset", ")", ";", "put", "(", "bytes", ")", ".", "put", "(", "(", "byte", ")", "0", ")", ";", "return", "this", ";", "}" ]
Puts string as null terminated byte array @param str @param charset @return @throws IOException
[ "Puts", "string", "as", "null", "terminated", "byte", "array" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java#L190-L195
154,605
tvesalainen/util
util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java
FilterByteBuffer.get
public FilterByteBuffer get(ByteBuffer bb) throws IOException { byte[] buf = new byte[BUFSIZE]; while (bb.hasRemaining()) { int lim = Math.min(BUFSIZE, bb.remaining()); get(buf, 0, lim); bb.put(buf, 0, lim); } return this; }
java
public FilterByteBuffer get(ByteBuffer bb) throws IOException { byte[] buf = new byte[BUFSIZE]; while (bb.hasRemaining()) { int lim = Math.min(BUFSIZE, bb.remaining()); get(buf, 0, lim); bb.put(buf, 0, lim); } return this; }
[ "public", "FilterByteBuffer", "get", "(", "ByteBuffer", "bb", ")", "throws", "IOException", "{", "byte", "[", "]", "buf", "=", "new", "byte", "[", "BUFSIZE", "]", ";", "while", "(", "bb", ".", "hasRemaining", "(", ")", ")", "{", "int", "lim", "=", "Math", ".", "min", "(", "BUFSIZE", ",", "bb", ".", "remaining", "(", ")", ")", ";", "get", "(", "buf", ",", "0", ",", "lim", ")", ";", "bb", ".", "put", "(", "buf", ",", "0", ",", "lim", ")", ";", "}", "return", "this", ";", "}" ]
Tries to read remaining bytes into ByteBuffer. @param bb @return @throws IOException @throws EOFException If get request couldn't be filled.
[ "Tries", "to", "read", "remaining", "bytes", "into", "ByteBuffer", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java#L203-L213
154,606
tvesalainen/util
util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java
FilterByteBuffer.get
public FilterByteBuffer get(byte[] dst, int offset, int length) throws IOException { checkIn(); int len = length; int count = 100; while (len > 0 && count > 0) { int rc = in.read(dst, offset+length-len, len); if (rc == -1) { throw new EOFException(); } len -= rc; count--; } if (count == 0) { throw new IOException("couldn't fill buffer after 100 tries"); } position += length; return this; }
java
public FilterByteBuffer get(byte[] dst, int offset, int length) throws IOException { checkIn(); int len = length; int count = 100; while (len > 0 && count > 0) { int rc = in.read(dst, offset+length-len, len); if (rc == -1) { throw new EOFException(); } len -= rc; count--; } if (count == 0) { throw new IOException("couldn't fill buffer after 100 tries"); } position += length; return this; }
[ "public", "FilterByteBuffer", "get", "(", "byte", "[", "]", "dst", ",", "int", "offset", ",", "int", "length", ")", "throws", "IOException", "{", "checkIn", "(", ")", ";", "int", "len", "=", "length", ";", "int", "count", "=", "100", ";", "while", "(", "len", ">", "0", "&&", "count", ">", "0", ")", "{", "int", "rc", "=", "in", ".", "read", "(", "dst", ",", "offset", "+", "length", "-", "len", ",", "len", ")", ";", "if", "(", "rc", "==", "-", "1", ")", "{", "throw", "new", "EOFException", "(", ")", ";", "}", "len", "-=", "rc", ";", "count", "--", ";", "}", "if", "(", "count", "==", "0", ")", "{", "throw", "new", "IOException", "(", "\"couldn't fill buffer after 100 tries\"", ")", ";", "}", "position", "+=", "length", ";", "return", "this", ";", "}" ]
Tries to read length bytes to dst. @param dst @param offset @param length @return @throws IOException @throws EOFException If get request couldn't be filled.
[ "Tries", "to", "read", "length", "bytes", "to", "dst", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java#L267-L288
154,607
tvesalainen/util
util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java
FilterByteBuffer.get
public FilterByteBuffer get(byte[] dst) throws IOException { checkIn(); int rc = in.read(dst); if (rc != dst.length) { throw new EOFException(); } position += dst.length; return this; }
java
public FilterByteBuffer get(byte[] dst) throws IOException { checkIn(); int rc = in.read(dst); if (rc != dst.length) { throw new EOFException(); } position += dst.length; return this; }
[ "public", "FilterByteBuffer", "get", "(", "byte", "[", "]", "dst", ")", "throws", "IOException", "{", "checkIn", "(", ")", ";", "int", "rc", "=", "in", ".", "read", "(", "dst", ")", ";", "if", "(", "rc", "!=", "dst", ".", "length", ")", "{", "throw", "new", "EOFException", "(", ")", ";", "}", "position", "+=", "dst", ".", "length", ";", "return", "this", ";", "}" ]
Tries to fill dst. @param dst @return @throws IOException @throws EOFException If get request couldn't be filled.
[ "Tries", "to", "fill", "dst", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java#L296-L306
154,608
tvesalainen/util
util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java
FilterByteBuffer.put
public FilterByteBuffer put(byte[] src, int offset, int length) throws IOException { checkOut(); out.write(src, offset, length); position += length; return this; }
java
public FilterByteBuffer put(byte[] src, int offset, int length) throws IOException { checkOut(); out.write(src, offset, length); position += length; return this; }
[ "public", "FilterByteBuffer", "put", "(", "byte", "[", "]", "src", ",", "int", "offset", ",", "int", "length", ")", "throws", "IOException", "{", "checkOut", "(", ")", ";", "out", ".", "write", "(", "src", ",", "offset", ",", "length", ")", ";", "position", "+=", "length", ";", "return", "this", ";", "}" ]
Puts length bytes. @param src @param offset @param length @return @throws IOException @throws BufferOverflowException If not enough room in ByteBuffer.
[ "Puts", "length", "bytes", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java#L316-L322
154,609
tvesalainen/util
util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java
FilterByteBuffer.put
public FilterByteBuffer put(byte[] src) throws IOException { checkOut(); out.write(src); position += src.length; return this; }
java
public FilterByteBuffer put(byte[] src) throws IOException { checkOut(); out.write(src); position += src.length; return this; }
[ "public", "FilterByteBuffer", "put", "(", "byte", "[", "]", "src", ")", "throws", "IOException", "{", "checkOut", "(", ")", ";", "out", ".", "write", "(", "src", ")", ";", "position", "+=", "src", ".", "length", ";", "return", "this", ";", "}" ]
Puts whole dst. @param src @return @throws IOException @throws BufferOverflowException If not enough room in ByteBuffer.
[ "Puts", "whole", "dst", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java#L330-L336
154,610
tvesalainen/util
util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java
FilterByteBuffer.close
@Override public void close() throws IOException { if (out != null) { out.close(); out = null; } if (in != null) { in.close(); in = null; } }
java
@Override public void close() throws IOException { if (out != null) { out.close(); out = null; } if (in != null) { in.close(); in = null; } }
[ "@", "Override", "public", "void", "close", "(", ")", "throws", "IOException", "{", "if", "(", "out", "!=", "null", ")", "{", "out", ".", "close", "(", ")", ";", "out", "=", "null", ";", "}", "if", "(", "in", "!=", "null", ")", "{", "in", ".", "close", "(", ")", ";", "in", "=", "null", ";", "}", "}" ]
Closes underlying streams. @throws Exception
[ "Closes", "underlying", "streams", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/FilterByteBuffer.java#L497-L510
154,611
aequologica/geppaequo
geppaequo-cmis/src/main/java/net/aequologica/neo/geppaequo/jndi/JndiUtil.java
JndiUtil.dumpContext
public void dumpContext(PrintWriter writer) { try { NamingEnumeration<NameClassPair> list = context.list("/"); writer.print("\n{\n name: \""); /*writer.print(this.namespace); writer.print(" ");*/ writer.print(this.root); writer.println("\",\n children: ["); enumerate(list, "/", writer); writer.println("]}"); writer.flush(); } catch (NamingException e) { e.printStackTrace(writer); } }
java
public void dumpContext(PrintWriter writer) { try { NamingEnumeration<NameClassPair> list = context.list("/"); writer.print("\n{\n name: \""); /*writer.print(this.namespace); writer.print(" ");*/ writer.print(this.root); writer.println("\",\n children: ["); enumerate(list, "/", writer); writer.println("]}"); writer.flush(); } catch (NamingException e) { e.printStackTrace(writer); } }
[ "public", "void", "dumpContext", "(", "PrintWriter", "writer", ")", "{", "try", "{", "NamingEnumeration", "<", "NameClassPair", ">", "list", "=", "context", ".", "list", "(", "\"/\"", ")", ";", "writer", ".", "print", "(", "\"\\n{\\n name: \\\"\"", ")", ";", "/*writer.print(this.namespace);\n writer.print(\" \");*/", "writer", ".", "print", "(", "this", ".", "root", ")", ";", "writer", ".", "println", "(", "\"\\\",\\n children: [\"", ")", ";", "enumerate", "(", "list", ",", "\"/\"", ",", "writer", ")", ";", "writer", ".", "println", "(", "\"]}\"", ")", ";", "writer", ".", "flush", "(", ")", ";", "}", "catch", "(", "NamingException", "e", ")", "{", "e", ".", "printStackTrace", "(", "writer", ")", ";", "}", "}" ]
dump the current context to a PrintWriter
[ "dump", "the", "current", "context", "to", "a", "PrintWriter" ]
b72e5f6356535fd045a931f8c544d4a8ea6e35a2
https://github.com/aequologica/geppaequo/blob/b72e5f6356535fd045a931f8c544d4a8ea6e35a2/geppaequo-cmis/src/main/java/net/aequologica/neo/geppaequo/jndi/JndiUtil.java#L58-L72
154,612
carewebframework/carewebframework-vista
org.carewebframework.vista.security-parent/org.carewebframework.vista.security.base/src/main/java/org/carewebframework/vista/security/base/BaseSecurityService.java
BaseSecurityService.changePassword
@Override public String changePassword(final String oldPassword, final String newPassword) { return Security.changePassword(brokerSession, oldPassword, newPassword); }
java
@Override public String changePassword(final String oldPassword, final String newPassword) { return Security.changePassword(brokerSession, oldPassword, newPassword); }
[ "@", "Override", "public", "String", "changePassword", "(", "final", "String", "oldPassword", ",", "final", "String", "newPassword", ")", "{", "return", "Security", ".", "changePassword", "(", "brokerSession", ",", "oldPassword", ",", "newPassword", ")", ";", "}" ]
Changes the user's password. @param oldPassword Current password. @param newPassword New password. @return Null or empty if succeeded. Otherwise, displayable reason why change failed.
[ "Changes", "the", "user", "s", "password", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.security-parent/org.carewebframework.vista.security.base/src/main/java/org/carewebframework/vista/security/base/BaseSecurityService.java#L59-L62
154,613
carewebframework/carewebframework-vista
org.carewebframework.vista.security-parent/org.carewebframework.vista.security.base/src/main/java/org/carewebframework/vista/security/base/BaseSecurityService.java
BaseSecurityService.loginDisabled
@Override public String loginDisabled() { AuthResult result = brokerSession.authenticate("dummy", "dummy", null); return result.status == AuthStatus.NOLOGINS ? result.reason : null; }
java
@Override public String loginDisabled() { AuthResult result = brokerSession.authenticate("dummy", "dummy", null); return result.status == AuthStatus.NOLOGINS ? result.reason : null; }
[ "@", "Override", "public", "String", "loginDisabled", "(", ")", "{", "AuthResult", "result", "=", "brokerSession", ".", "authenticate", "(", "\"dummy\"", ",", "\"dummy\"", ",", "null", ")", ";", "return", "result", ".", "status", "==", "AuthStatus", ".", "NOLOGINS", "?", "result", ".", "reason", ":", "null", ";", "}" ]
Return login disabled message.
[ "Return", "login", "disabled", "message", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.security-parent/org.carewebframework.vista.security.base/src/main/java/org/carewebframework/vista/security/base/BaseSecurityService.java#L67-L71
154,614
carewebframework/carewebframework-vista
org.carewebframework.vista.security-parent/org.carewebframework.vista.security.base/src/main/java/org/carewebframework/vista/security/base/BaseSecurityService.java
BaseSecurityService.logout
@Override public boolean logout(boolean force, String target, String message) { boolean result = super.logout(force, target, message); if (result) { brokerSession.disconnect(); } return result; }
java
@Override public boolean logout(boolean force, String target, String message) { boolean result = super.logout(force, target, message); if (result) { brokerSession.disconnect(); } return result; }
[ "@", "Override", "public", "boolean", "logout", "(", "boolean", "force", ",", "String", "target", ",", "String", "message", ")", "{", "boolean", "result", "=", "super", ".", "logout", "(", "force", ",", "target", ",", "message", ")", ";", "if", "(", "result", ")", "{", "brokerSession", ".", "disconnect", "(", ")", ";", "}", "return", "result", ";", "}" ]
Override to disconnect broker.
[ "Override", "to", "disconnect", "broker", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.security-parent/org.carewebframework.vista.security.base/src/main/java/org/carewebframework/vista/security/base/BaseSecurityService.java#L76-L85
154,615
tvesalainen/util
util/src/main/java/org/vesalainen/math/matrix/PermutationMatrix.java
PermutationMatrix.getInstance
public static PermutationMatrix getInstance(int n) { PermutationMatrix pm = map.get(n); if (pm == null) { pm = new PermutationMatrix(n); map.put(n, pm); } return pm; }
java
public static PermutationMatrix getInstance(int n) { PermutationMatrix pm = map.get(n); if (pm == null) { pm = new PermutationMatrix(n); map.put(n, pm); } return pm; }
[ "public", "static", "PermutationMatrix", "getInstance", "(", "int", "n", ")", "{", "PermutationMatrix", "pm", "=", "map", ".", "get", "(", "n", ")", ";", "if", "(", "pm", "==", "null", ")", "{", "pm", "=", "new", "PermutationMatrix", "(", "n", ")", ";", "map", ".", "put", "(", "n", ",", "pm", ")", ";", "}", "return", "pm", ";", "}" ]
Returns immutable PermutationMatrix possibly from cache. @param n @return
[ "Returns", "immutable", "PermutationMatrix", "possibly", "from", "cache", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/matrix/PermutationMatrix.java#L49-L58
154,616
jbundle/jbundle
thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/JGridScreenToolbar.java
JGridScreenToolbar.addButtons
public void addButtons() { this.addButton(Constants.BACK); this.addButton(Constants.FORM); this.addButton(Constants.DELETE); this.addButton(Constants.HELP); }
java
public void addButtons() { this.addButton(Constants.BACK); this.addButton(Constants.FORM); this.addButton(Constants.DELETE); this.addButton(Constants.HELP); }
[ "public", "void", "addButtons", "(", ")", "{", "this", ".", "addButton", "(", "Constants", ".", "BACK", ")", ";", "this", ".", "addButton", "(", "Constants", ".", "FORM", ")", ";", "this", ".", "addButton", "(", "Constants", ".", "DELETE", ")", ";", "this", ".", "addButton", "(", "Constants", ".", "HELP", ")", ";", "}" ]
Add the buttons to this window. Override this to include buttons other than the default buttons.
[ "Add", "the", "buttons", "to", "this", "window", ".", "Override", "this", "to", "include", "buttons", "other", "than", "the", "default", "buttons", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/JGridScreenToolbar.java#L53-L59
154,617
jbundle/jbundle
thin/base/screen/cal/other/src/main/java/org/jbundle/thin/base/screen/cal/opt/TaskCalendarStatusHandler.java
TaskCalendarStatusHandler.setStatusText
@Override public void setStatusText(String status) { if (status != null) oldStatusText = task.getStatusText(0); else status = oldStatusText; task.setStatusText(status); }
java
@Override public void setStatusText(String status) { if (status != null) oldStatusText = task.getStatusText(0); else status = oldStatusText; task.setStatusText(status); }
[ "@", "Override", "public", "void", "setStatusText", "(", "String", "status", ")", "{", "if", "(", "status", "!=", "null", ")", "oldStatusText", "=", "task", ".", "getStatusText", "(", "0", ")", ";", "else", "status", "=", "oldStatusText", ";", "task", ".", "setStatusText", "(", "status", ")", ";", "}" ]
Change the status display. @param status
[ "Change", "the", "status", "display", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/cal/other/src/main/java/org/jbundle/thin/base/screen/cal/opt/TaskCalendarStatusHandler.java#L46-L53
154,618
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java
JPAUtils.count
public static <T> Long count(EntityManager em, CriteriaQuery<T> criteria) { return em.createQuery(countCriteria(em, criteria)).getSingleResult(); }
java
public static <T> Long count(EntityManager em, CriteriaQuery<T> criteria) { return em.createQuery(countCriteria(em, criteria)).getSingleResult(); }
[ "public", "static", "<", "T", ">", "Long", "count", "(", "EntityManager", "em", ",", "CriteriaQuery", "<", "T", ">", "criteria", ")", "{", "return", "em", ".", "createQuery", "(", "countCriteria", "(", "em", ",", "criteria", ")", ")", ".", "getSingleResult", "(", ")", ";", "}" ]
Result count from a CriteriaQuery @param em Entity Manager @param criteria Criteria Query to count results @return row count
[ "Result", "count", "from", "a", "CriteriaQuery" ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java#L61-L64
154,619
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java
JPAUtils.countCriteria
public static <T> CriteriaQuery<Long> countCriteria(EntityManager em, CriteriaQuery<T> criteria) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Long> countCriteria = builder.createQuery(Long.class); copyCriteriaNoSelection(criteria, countCriteria); countCriteria.select(builder.count(findRoot(countCriteria, criteria.getResultType()))); return countCriteria; }
java
public static <T> CriteriaQuery<Long> countCriteria(EntityManager em, CriteriaQuery<T> criteria) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Long> countCriteria = builder.createQuery(Long.class); copyCriteriaNoSelection(criteria, countCriteria); countCriteria.select(builder.count(findRoot(countCriteria, criteria.getResultType()))); return countCriteria; }
[ "public", "static", "<", "T", ">", "CriteriaQuery", "<", "Long", ">", "countCriteria", "(", "EntityManager", "em", ",", "CriteriaQuery", "<", "T", ">", "criteria", ")", "{", "CriteriaBuilder", "builder", "=", "em", ".", "getCriteriaBuilder", "(", ")", ";", "CriteriaQuery", "<", "Long", ">", "countCriteria", "=", "builder", ".", "createQuery", "(", "Long", ".", "class", ")", ";", "copyCriteriaNoSelection", "(", "criteria", ",", "countCriteria", ")", ";", "countCriteria", ".", "select", "(", "builder", ".", "count", "(", "findRoot", "(", "countCriteria", ",", "criteria", ".", "getResultType", "(", ")", ")", ")", ")", ";", "return", "countCriteria", ";", "}" ]
Create a row count CriteriaQuery from a CriteriaQuery @param em entity manager @param criteria source criteria @return row count CriteriaQuery
[ "Create", "a", "row", "count", "CriteriaQuery", "from", "a", "CriteriaQuery" ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java#L73-L80
154,620
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java
JPAUtils.getOrCreateAlias
public static synchronized <T> String getOrCreateAlias(Selection<T> selection) { // reset alias count if (aliasCount > 1000) aliasCount = 0; String alias = selection.getAlias(); if (alias == null) { alias = "JDAL_generatedAlias" + aliasCount++; selection.alias(alias); } return alias; }
java
public static synchronized <T> String getOrCreateAlias(Selection<T> selection) { // reset alias count if (aliasCount > 1000) aliasCount = 0; String alias = selection.getAlias(); if (alias == null) { alias = "JDAL_generatedAlias" + aliasCount++; selection.alias(alias); } return alias; }
[ "public", "static", "synchronized", "<", "T", ">", "String", "getOrCreateAlias", "(", "Selection", "<", "T", ">", "selection", ")", "{", "// reset alias count", "if", "(", "aliasCount", ">", "1000", ")", "aliasCount", "=", "0", ";", "String", "alias", "=", "selection", ".", "getAlias", "(", ")", ";", "if", "(", "alias", "==", "null", ")", "{", "alias", "=", "\"JDAL_generatedAlias\"", "+", "aliasCount", "++", ";", "selection", ".", "alias", "(", "alias", ")", ";", "}", "return", "alias", ";", "}" ]
Gets The result alias, if none set a default one and return it @param selection @return root alias or generated one
[ "Gets", "The", "result", "alias", "if", "none", "set", "a", "default", "one", "and", "return", "it" ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java#L88-L99
154,621
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java
JPAUtils.findRoot
public static <T> Root<T> findRoot(CriteriaQuery<T> query) { return findRoot(query, query.getResultType()); }
java
public static <T> Root<T> findRoot(CriteriaQuery<T> query) { return findRoot(query, query.getResultType()); }
[ "public", "static", "<", "T", ">", "Root", "<", "T", ">", "findRoot", "(", "CriteriaQuery", "<", "T", ">", "query", ")", "{", "return", "findRoot", "(", "query", ",", "query", ".", "getResultType", "(", ")", ")", ";", "}" ]
Find Root of result type @param query criteria query @return the root of result type or null if none
[ "Find", "Root", "of", "result", "type" ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java#L107-L109
154,622
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java
JPAUtils.findRoot
public static <T> Root<T> findRoot(CriteriaQuery<?> query, Class<T> clazz) { for (Root<?> r : query.getRoots()) { if (clazz.equals(r.getJavaType())) { return (Root<T>) r.as(clazz); } } return null; }
java
public static <T> Root<T> findRoot(CriteriaQuery<?> query, Class<T> clazz) { for (Root<?> r : query.getRoots()) { if (clazz.equals(r.getJavaType())) { return (Root<T>) r.as(clazz); } } return null; }
[ "public", "static", "<", "T", ">", "Root", "<", "T", ">", "findRoot", "(", "CriteriaQuery", "<", "?", ">", "query", ",", "Class", "<", "T", ">", "clazz", ")", "{", "for", "(", "Root", "<", "?", ">", "r", ":", "query", ".", "getRoots", "(", ")", ")", "{", "if", "(", "clazz", ".", "equals", "(", "r", ".", "getJavaType", "(", ")", ")", ")", "{", "return", "(", "Root", "<", "T", ">", ")", "r", ".", "as", "(", "clazz", ")", ";", "}", "}", "return", "null", ";", "}" ]
Find the Root with type class on CriteriaQuery Root Set @param <T> root type @param query criteria query @param clazz root type @return Root<T> of null if none
[ "Find", "the", "Root", "with", "type", "class", "on", "CriteriaQuery", "Root", "Set" ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java#L119-L127
154,623
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java
JPAUtils.getPath
public static Path<?> getPath(Path<?> path, String propertyPath) { if (StringUtils.isEmpty(propertyPath)) return path; String name = StringUtils.substringBefore(propertyPath, PropertyUtils.PROPERTY_SEPARATOR); Path<?> p = path.get(name); return getPath(p, StringUtils.substringAfter(propertyPath, PropertyUtils.PROPERTY_SEPARATOR)); }
java
public static Path<?> getPath(Path<?> path, String propertyPath) { if (StringUtils.isEmpty(propertyPath)) return path; String name = StringUtils.substringBefore(propertyPath, PropertyUtils.PROPERTY_SEPARATOR); Path<?> p = path.get(name); return getPath(p, StringUtils.substringAfter(propertyPath, PropertyUtils.PROPERTY_SEPARATOR)); }
[ "public", "static", "Path", "<", "?", ">", "getPath", "(", "Path", "<", "?", ">", "path", ",", "String", "propertyPath", ")", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "propertyPath", ")", ")", "return", "path", ";", "String", "name", "=", "StringUtils", ".", "substringBefore", "(", "propertyPath", ",", "PropertyUtils", ".", "PROPERTY_SEPARATOR", ")", ";", "Path", "<", "?", ">", "p", "=", "path", ".", "get", "(", "name", ")", ";", "return", "getPath", "(", "p", ",", "StringUtils", ".", "substringAfter", "(", "propertyPath", ",", "PropertyUtils", ".", "PROPERTY_SEPARATOR", ")", ")", ";", "}" ]
Gets a Path from Path using property path @param path the base path @param propertyPath property path String like "customer.order.price" @return a new Path for property
[ "Gets", "a", "Path", "from", "Path", "using", "property", "path" ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java#L170-L178
154,624
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java
JPAUtils.getAlias
public static String getAlias(String queryString) { Matcher m = ALIAS_PATTERN.matcher(queryString); return m.find() ? m.group(1) : null; }
java
public static String getAlias(String queryString) { Matcher m = ALIAS_PATTERN.matcher(queryString); return m.find() ? m.group(1) : null; }
[ "public", "static", "String", "getAlias", "(", "String", "queryString", ")", "{", "Matcher", "m", "=", "ALIAS_PATTERN", ".", "matcher", "(", "queryString", ")", ";", "return", "m", ".", "find", "(", ")", "?", "m", ".", "group", "(", "1", ")", ":", "null", ";", "}" ]
Gets the alias of root entity of JQL query @param queryString JQL query @return alias of root entity.
[ "Gets", "the", "alias", "of", "root", "entity", "of", "JQL", "query" ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java#L196-L199
154,625
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java
JPAUtils.addOrder
public static String addOrder(String queryString, String propertyPath, boolean asc) { if (StringUtils.containsIgnoreCase(queryString, "order by")) { return queryString; } StringBuilder sb = new StringBuilder(queryString); sb.append(" ORDER BY "); sb.append(getAlias(queryString)); sb.append("."); sb.append(propertyPath); sb.append(" "); sb.append(asc ? "ASC" : "DESC"); return sb.toString(); }
java
public static String addOrder(String queryString, String propertyPath, boolean asc) { if (StringUtils.containsIgnoreCase(queryString, "order by")) { return queryString; } StringBuilder sb = new StringBuilder(queryString); sb.append(" ORDER BY "); sb.append(getAlias(queryString)); sb.append("."); sb.append(propertyPath); sb.append(" "); sb.append(asc ? "ASC" : "DESC"); return sb.toString(); }
[ "public", "static", "String", "addOrder", "(", "String", "queryString", ",", "String", "propertyPath", ",", "boolean", "asc", ")", "{", "if", "(", "StringUtils", ".", "containsIgnoreCase", "(", "queryString", ",", "\"order by\"", ")", ")", "{", "return", "queryString", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "queryString", ")", ";", "sb", ".", "append", "(", "\" ORDER BY \"", ")", ";", "sb", ".", "append", "(", "getAlias", "(", "queryString", ")", ")", ";", "sb", ".", "append", "(", "\".\"", ")", ";", "sb", ".", "append", "(", "propertyPath", ")", ";", "sb", ".", "append", "(", "\" \"", ")", ";", "sb", ".", "append", "(", "asc", "?", "\"ASC\"", ":", "\"DESC\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Add order by clause to queryString @param queryString JPL Query String @param propertyPath Order properti @param asc true if ascending @return JQL Query String with Order clause appened.
[ "Add", "order", "by", "clause", "to", "queryString" ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java#L209-L224
154,626
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java
JPAUtils.getKeyQuery
public static String getKeyQuery(String queryString, String name) { Matcher m = FROM_PATTERN.matcher(queryString); if (m.find()) { StringBuilder sb = new StringBuilder("SELECT "); sb.append(getAlias(queryString)); sb.append("."); sb.append(name); sb.append(" "); sb.append(m.group()); return sb.toString(); } return null; }
java
public static String getKeyQuery(String queryString, String name) { Matcher m = FROM_PATTERN.matcher(queryString); if (m.find()) { StringBuilder sb = new StringBuilder("SELECT "); sb.append(getAlias(queryString)); sb.append("."); sb.append(name); sb.append(" "); sb.append(m.group()); return sb.toString(); } return null; }
[ "public", "static", "String", "getKeyQuery", "(", "String", "queryString", ",", "String", "name", ")", "{", "Matcher", "m", "=", "FROM_PATTERN", ".", "matcher", "(", "queryString", ")", ";", "if", "(", "m", ".", "find", "(", ")", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"SELECT \"", ")", ";", "sb", ".", "append", "(", "getAlias", "(", "queryString", ")", ")", ";", "sb", ".", "append", "(", "\".\"", ")", ";", "sb", ".", "append", "(", "name", ")", ";", "sb", ".", "append", "(", "\" \"", ")", ";", "sb", ".", "append", "(", "m", ".", "group", "(", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "return", "null", ";", "}" ]
Gets Query String for selecting primary keys @param queryString the original query @param name primary key name @return query string
[ "Gets", "Query", "String", "for", "selecting", "primary", "keys" ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java#L233-L246
154,627
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java
JPAUtils.copyCriteriaNoSelection
public static void copyCriteriaNoSelection(CriteriaQuery<?> from, CriteriaQuery<?> to) { // Copy Roots for (Root<?> root : from.getRoots()) { Root<?> dest = to.from(root.getJavaType()); dest.alias(getOrCreateAlias(root)); copyJoins(root, dest); } if (from.getGroupList() != null) to.groupBy(from.getGroupList()); to.distinct(from.isDistinct()); if (from.getGroupRestriction() != null) to.having(from.getGroupRestriction()); if (from.getRestriction() != null) to.where(from.getRestriction()); if (from.getOrderList() != null) to.orderBy(from.getOrderList()); }
java
public static void copyCriteriaNoSelection(CriteriaQuery<?> from, CriteriaQuery<?> to) { // Copy Roots for (Root<?> root : from.getRoots()) { Root<?> dest = to.from(root.getJavaType()); dest.alias(getOrCreateAlias(root)); copyJoins(root, dest); } if (from.getGroupList() != null) to.groupBy(from.getGroupList()); to.distinct(from.isDistinct()); if (from.getGroupRestriction() != null) to.having(from.getGroupRestriction()); if (from.getRestriction() != null) to.where(from.getRestriction()); if (from.getOrderList() != null) to.orderBy(from.getOrderList()); }
[ "public", "static", "void", "copyCriteriaNoSelection", "(", "CriteriaQuery", "<", "?", ">", "from", ",", "CriteriaQuery", "<", "?", ">", "to", ")", "{", "// Copy Roots", "for", "(", "Root", "<", "?", ">", "root", ":", "from", ".", "getRoots", "(", ")", ")", "{", "Root", "<", "?", ">", "dest", "=", "to", ".", "from", "(", "root", ".", "getJavaType", "(", ")", ")", ";", "dest", ".", "alias", "(", "getOrCreateAlias", "(", "root", ")", ")", ";", "copyJoins", "(", "root", ",", "dest", ")", ";", "}", "if", "(", "from", ".", "getGroupList", "(", ")", "!=", "null", ")", "to", ".", "groupBy", "(", "from", ".", "getGroupList", "(", ")", ")", ";", "to", ".", "distinct", "(", "from", ".", "isDistinct", "(", ")", ")", ";", "if", "(", "from", ".", "getGroupRestriction", "(", ")", "!=", "null", ")", "to", ".", "having", "(", "from", ".", "getGroupRestriction", "(", ")", ")", ";", "if", "(", "from", ".", "getRestriction", "(", ")", "!=", "null", ")", "to", ".", "where", "(", "from", ".", "getRestriction", "(", ")", ")", ";", "if", "(", "from", ".", "getOrderList", "(", ")", "!=", "null", ")", "to", ".", "orderBy", "(", "from", ".", "getOrderList", "(", ")", ")", ";", "}" ]
Copy Criteria without Selection @param from source Criteria @param to destination Criteria
[ "Copy", "Criteria", "without", "Selection" ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/utils/JPAUtils.java#L254-L268
154,628
agmip/agmip-core
src/main/java/org/agmip/util/MapUtil.java
MapUtil.listBucketNames
public static ArrayList<String> listBucketNames(Map<String, Object> m) { ArrayList<String> acc = new ArrayList<String>(); for(Map.Entry<String, Object> entry : m.entrySet()) { if( isValidBucket(entry.getValue()) ) { acc.add(entry.getKey()); } } return acc; }
java
public static ArrayList<String> listBucketNames(Map<String, Object> m) { ArrayList<String> acc = new ArrayList<String>(); for(Map.Entry<String, Object> entry : m.entrySet()) { if( isValidBucket(entry.getValue()) ) { acc.add(entry.getKey()); } } return acc; }
[ "public", "static", "ArrayList", "<", "String", ">", "listBucketNames", "(", "Map", "<", "String", ",", "Object", ">", "m", ")", "{", "ArrayList", "<", "String", ">", "acc", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Object", ">", "entry", ":", "m", ".", "entrySet", "(", ")", ")", "{", "if", "(", "isValidBucket", "(", "entry", ".", "getValue", "(", ")", ")", ")", "{", "acc", ".", "add", "(", "entry", ".", "getKey", "(", ")", ")", ";", "}", "}", "return", "acc", ";", "}" ]
Returns a list of all bucket names in the provided Map.
[ "Returns", "a", "list", "of", "all", "bucket", "names", "in", "the", "provided", "Map", "." ]
b1bc48fe8b41f170aa5f366fee8696bf9b274f55
https://github.com/agmip/agmip-core/blob/b1bc48fe8b41f170aa5f366fee8696bf9b274f55/src/main/java/org/agmip/util/MapUtil.java#L160-L168
154,629
dmfs/http-client-interfaces
src/org/dmfs/httpclientinterfaces/requestutils/ByteArrayOutputStream.java
ByteArrayOutputStream.requestChunk
private byte[] requestChunk(int requestedSize) { mPosInChunk = 0; if (mCurrentChunkIndex++ < mChunkList.size() - 1) { // there is one more unused buffer in the list, return it return mCurrentChunk = mChunkList.get(mCurrentChunkIndex); } mChunkList.add(mCurrentChunk = new byte[Math.max(requestedSize, mMinChunkSize)]); return mCurrentChunk; }
java
private byte[] requestChunk(int requestedSize) { mPosInChunk = 0; if (mCurrentChunkIndex++ < mChunkList.size() - 1) { // there is one more unused buffer in the list, return it return mCurrentChunk = mChunkList.get(mCurrentChunkIndex); } mChunkList.add(mCurrentChunk = new byte[Math.max(requestedSize, mMinChunkSize)]); return mCurrentChunk; }
[ "private", "byte", "[", "]", "requestChunk", "(", "int", "requestedSize", ")", "{", "mPosInChunk", "=", "0", ";", "if", "(", "mCurrentChunkIndex", "++", "<", "mChunkList", ".", "size", "(", ")", "-", "1", ")", "{", "// there is one more unused buffer in the list, return it", "return", "mCurrentChunk", "=", "mChunkList", ".", "get", "(", "mCurrentChunkIndex", ")", ";", "}", "mChunkList", ".", "add", "(", "mCurrentChunk", "=", "new", "byte", "[", "Math", ".", "max", "(", "requestedSize", ",", "mMinChunkSize", ")", "]", ")", ";", "return", "mCurrentChunk", ";", "}" ]
Request a new current chunk. @param requestedSize The minimal size of the new buffer. @return The new or recycled buffer.
[ "Request", "a", "new", "current", "chunk", "." ]
10896c71270ccaf32ac4ed5d706dfa0001fd3862
https://github.com/dmfs/http-client-interfaces/blob/10896c71270ccaf32ac4ed5d706dfa0001fd3862/src/org/dmfs/httpclientinterfaces/requestutils/ByteArrayOutputStream.java#L172-L183
154,630
dmfs/http-client-interfaces
src/org/dmfs/httpclientinterfaces/requestutils/ByteArrayOutputStream.java
ByteArrayOutputStream.trim
public void trim() { List<byte[]> chunkList = mChunkList; while (chunkList.size() - 1 > mCurrentChunkIndex) { chunkList.remove(chunkList.size() - 1); } }
java
public void trim() { List<byte[]> chunkList = mChunkList; while (chunkList.size() - 1 > mCurrentChunkIndex) { chunkList.remove(chunkList.size() - 1); } }
[ "public", "void", "trim", "(", ")", "{", "List", "<", "byte", "[", "]", ">", "chunkList", "=", "mChunkList", ";", "while", "(", "chunkList", ".", "size", "(", ")", "-", "1", ">", "mCurrentChunkIndex", ")", "{", "chunkList", ".", "remove", "(", "chunkList", ".", "size", "(", ")", "-", "1", ")", ";", "}", "}" ]
Reduce the memory allocated by this object by freeing all unused chunks.
[ "Reduce", "the", "memory", "allocated", "by", "this", "object", "by", "freeing", "all", "unused", "chunks", "." ]
10896c71270ccaf32ac4ed5d706dfa0001fd3862
https://github.com/dmfs/http-client-interfaces/blob/10896c71270ccaf32ac4ed5d706dfa0001fd3862/src/org/dmfs/httpclientinterfaces/requestutils/ByteArrayOutputStream.java#L236-L243
154,631
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/parsetable/AbstractParserTable.java
AbstractParserTable.addExactActions
private void addExactActions(Construction construction, ParserActionSet set, Map<Construction, ParserActionSet> actions) { for (Entry<Construction, ParserActionSet> entry : actions.entrySet()) { Construction c = entry.getKey(); if (!c.getName().equals(construction.getName())) { // if name is not equal, it does obviously not fit... continue; } if (c.isNonTerminal() != construction.isNonTerminal()) { // if the type is different, they do not fit either... continue; } if (construction.isNonTerminal()) { /* * if both are non-terminals, the names are the only criterion * for an exact match */ set.addActions(entry.getValue()); continue; } Terminal terminal = (Terminal) construction; if (terminal.getText() == null) { continue; } Terminal t = (Terminal) c; if (grammar.isIgnoreCase()) { if (terminal.getText().equalsIgnoreCase(t.getText())) { set.addActions(entry.getValue()); } } else { if (terminal.getText().equals(t.getText())) { set.addActions(entry.getValue()); } } } }
java
private void addExactActions(Construction construction, ParserActionSet set, Map<Construction, ParserActionSet> actions) { for (Entry<Construction, ParserActionSet> entry : actions.entrySet()) { Construction c = entry.getKey(); if (!c.getName().equals(construction.getName())) { // if name is not equal, it does obviously not fit... continue; } if (c.isNonTerminal() != construction.isNonTerminal()) { // if the type is different, they do not fit either... continue; } if (construction.isNonTerminal()) { /* * if both are non-terminals, the names are the only criterion * for an exact match */ set.addActions(entry.getValue()); continue; } Terminal terminal = (Terminal) construction; if (terminal.getText() == null) { continue; } Terminal t = (Terminal) c; if (grammar.isIgnoreCase()) { if (terminal.getText().equalsIgnoreCase(t.getText())) { set.addActions(entry.getValue()); } } else { if (terminal.getText().equals(t.getText())) { set.addActions(entry.getValue()); } } } }
[ "private", "void", "addExactActions", "(", "Construction", "construction", ",", "ParserActionSet", "set", ",", "Map", "<", "Construction", ",", "ParserActionSet", ">", "actions", ")", "{", "for", "(", "Entry", "<", "Construction", ",", "ParserActionSet", ">", "entry", ":", "actions", ".", "entrySet", "(", ")", ")", "{", "Construction", "c", "=", "entry", ".", "getKey", "(", ")", ";", "if", "(", "!", "c", ".", "getName", "(", ")", ".", "equals", "(", "construction", ".", "getName", "(", ")", ")", ")", "{", "// if name is not equal, it does obviously not fit...", "continue", ";", "}", "if", "(", "c", ".", "isNonTerminal", "(", ")", "!=", "construction", ".", "isNonTerminal", "(", ")", ")", "{", "// if the type is different, they do not fit either...", "continue", ";", "}", "if", "(", "construction", ".", "isNonTerminal", "(", ")", ")", "{", "/*\n\t\t * if both are non-terminals, the names are the only criterion\n\t\t * for an exact match\n\t\t */", "set", ".", "addActions", "(", "entry", ".", "getValue", "(", ")", ")", ";", "continue", ";", "}", "Terminal", "terminal", "=", "(", "Terminal", ")", "construction", ";", "if", "(", "terminal", ".", "getText", "(", ")", "==", "null", ")", "{", "continue", ";", "}", "Terminal", "t", "=", "(", "Terminal", ")", "c", ";", "if", "(", "grammar", ".", "isIgnoreCase", "(", ")", ")", "{", "if", "(", "terminal", ".", "getText", "(", ")", ".", "equalsIgnoreCase", "(", "t", ".", "getText", "(", ")", ")", ")", "{", "set", ".", "addActions", "(", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "else", "{", "if", "(", "terminal", ".", "getText", "(", ")", ".", "equals", "(", "t", ".", "getText", "(", ")", ")", ")", "{", "set", ".", "addActions", "(", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "}", "}" ]
This method adds all actions which are concrete, what means that name and content match exactly. This method is needed for grammars which ignore the case of letters. A simple Map.get() is not working due to the fact, that the equals method can not be easily created for case-ignorance. It could easily violate the contract for equals and hashCode. @param construction @param set @param actions
[ "This", "method", "adds", "all", "actions", "which", "are", "concrete", "what", "means", "that", "name", "and", "content", "match", "exactly", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/parsetable/AbstractParserTable.java#L181-L216
154,632
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/parsetable/AbstractParserTable.java
AbstractParserTable.addNonExcactActions
private void addNonExcactActions(Construction construction, ParserActionSet set, Map<Construction, ParserActionSet> actions) { set.addActions(actions.get(new Terminal(construction.getName(), null))); }
java
private void addNonExcactActions(Construction construction, ParserActionSet set, Map<Construction, ParserActionSet> actions) { set.addActions(actions.get(new Terminal(construction.getName(), null))); }
[ "private", "void", "addNonExcactActions", "(", "Construction", "construction", ",", "ParserActionSet", "set", ",", "Map", "<", "Construction", ",", "ParserActionSet", ">", "actions", ")", "{", "set", ".", "addActions", "(", "actions", ".", "get", "(", "new", "Terminal", "(", "construction", ".", "getName", "(", ")", ",", "null", ")", ")", ")", ";", "}" ]
The method is needed for grammars where no keywords are available like Fortran. E.G.: If 'IF' is a keyword for the IF-construct and 'IF' also allowed to be a variable name, we need to add the actions for terminal NAME_LITERAL/'IF" and for NAME_LITERAL/*.
[ "The", "method", "is", "needed", "for", "grammars", "where", "no", "keywords", "are", "available", "like", "Fortran", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/parsetable/AbstractParserTable.java#L226-L229
154,633
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/validate/ValidationException.java
ValidationException.composeMessage
public static String composeMessage(List<ValidationResult> results) { StringBuilder builder = new StringBuilder(); builder.append("Validation failed"); if (results != null && results.size() > 0) { boolean first = true; for (ValidationResult result : results) { if (result.getType() != ValidationResultType.Information) { if (!first) builder.append(": "); else builder.append(", "); builder.append(result.getMessage()); first = false; } } } return builder.toString(); }
java
public static String composeMessage(List<ValidationResult> results) { StringBuilder builder = new StringBuilder(); builder.append("Validation failed"); if (results != null && results.size() > 0) { boolean first = true; for (ValidationResult result : results) { if (result.getType() != ValidationResultType.Information) { if (!first) builder.append(": "); else builder.append(", "); builder.append(result.getMessage()); first = false; } } } return builder.toString(); }
[ "public", "static", "String", "composeMessage", "(", "List", "<", "ValidationResult", ">", "results", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "\"Validation failed\"", ")", ";", "if", "(", "results", "!=", "null", "&&", "results", ".", "size", "(", ")", ">", "0", ")", "{", "boolean", "first", "=", "true", ";", "for", "(", "ValidationResult", "result", ":", "results", ")", "{", "if", "(", "result", ".", "getType", "(", ")", "!=", "ValidationResultType", ".", "Information", ")", "{", "if", "(", "!", "first", ")", "builder", ".", "append", "(", "\": \"", ")", ";", "else", "builder", ".", "append", "(", "\", \"", ")", ";", "builder", ".", "append", "(", "result", ".", "getMessage", "(", ")", ")", ";", "first", "=", "false", ";", "}", "}", "}", "return", "builder", ".", "toString", "(", ")", ";", "}" ]
Composes human readable error message based on validation results. @param results a list of validation results. @return a composed error message. @see ValidationResult
[ "Composes", "human", "readable", "error", "message", "based", "on", "validation", "results", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/validate/ValidationException.java#L54-L73
154,634
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/validate/ValidationException.java
ValidationException.fromResults
public static ValidationException fromResults(String correlationId, List<ValidationResult> results, boolean strict) throws ValidationException { boolean hasErrors = false; for (ValidationResult result : results) { if (result.getType() == ValidationResultType.Error) hasErrors = true; if (strict && result.getType() == ValidationResultType.Warning) hasErrors = true; } return hasErrors ? new ValidationException(correlationId, results) : null; }
java
public static ValidationException fromResults(String correlationId, List<ValidationResult> results, boolean strict) throws ValidationException { boolean hasErrors = false; for (ValidationResult result : results) { if (result.getType() == ValidationResultType.Error) hasErrors = true; if (strict && result.getType() == ValidationResultType.Warning) hasErrors = true; } return hasErrors ? new ValidationException(correlationId, results) : null; }
[ "public", "static", "ValidationException", "fromResults", "(", "String", "correlationId", ",", "List", "<", "ValidationResult", ">", "results", ",", "boolean", "strict", ")", "throws", "ValidationException", "{", "boolean", "hasErrors", "=", "false", ";", "for", "(", "ValidationResult", "result", ":", "results", ")", "{", "if", "(", "result", ".", "getType", "(", ")", "==", "ValidationResultType", ".", "Error", ")", "hasErrors", "=", "true", ";", "if", "(", "strict", "&&", "result", ".", "getType", "(", ")", "==", "ValidationResultType", ".", "Warning", ")", "hasErrors", "=", "true", ";", "}", "return", "hasErrors", "?", "new", "ValidationException", "(", "correlationId", ",", "results", ")", ":", "null", ";", "}" ]
Creates a new ValidationException based on errors in validation results. If validation results have no errors, than null is returned. @param correlationId (optional) transaction id to trace execution through call chain. @param results list of validation results that may contain errors @param strict true to treat warnings as errors. @return a newly created ValidationException or null if no errors in found. @throws ValidationException when errors occured in validation. @see ValidationResult
[ "Creates", "a", "new", "ValidationException", "based", "on", "errors", "in", "validation", "results", ".", "If", "validation", "results", "have", "no", "errors", "than", "null", "is", "returned", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/validate/ValidationException.java#L88-L99
154,635
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/validate/ValidationException.java
ValidationException.throwExceptionIfNeeded
public static void throwExceptionIfNeeded(String correlationId, List<ValidationResult> results, boolean strict) throws ValidationException { ValidationException ex = fromResults(correlationId, results, strict); if (ex != null) throw ex; }
java
public static void throwExceptionIfNeeded(String correlationId, List<ValidationResult> results, boolean strict) throws ValidationException { ValidationException ex = fromResults(correlationId, results, strict); if (ex != null) throw ex; }
[ "public", "static", "void", "throwExceptionIfNeeded", "(", "String", "correlationId", ",", "List", "<", "ValidationResult", ">", "results", ",", "boolean", "strict", ")", "throws", "ValidationException", "{", "ValidationException", "ex", "=", "fromResults", "(", "correlationId", ",", "results", ",", "strict", ")", ";", "if", "(", "ex", "!=", "null", ")", "throw", "ex", ";", "}" ]
Throws ValidationException based on errors in validation results. If validation results have no errors, than no exception is thrown. @param correlationId (optional) transaction id to trace execution through call chain. @param results list of validation results that may contain errors @param strict true to treat warnings as errors. @throws ValidationException when errors occured in validation. @see ValidationResult @see ValidationException
[ "Throws", "ValidationException", "based", "on", "errors", "in", "validation", "results", ".", "If", "validation", "results", "have", "no", "errors", "than", "no", "exception", "is", "thrown", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/validate/ValidationException.java#L114-L119
154,636
PureSolTechnologies/commons
misc/src/main/java/com/puresoltechnologies/commons/misc/hash/HashUtilities.java
HashUtilities.convertByteArrayToString
private static String convertByteArrayToString(byte[] byteArray) { if (byteArray == null) { throw new IllegalArgumentException("Byte array must not be null!"); } StringBuffer hexString = new StringBuffer(); for (int i = 0; i < byteArray.length; i++) { int digit = 0xFF & byteArray[i]; String hexDigits = Integer.toHexString(digit); if (hexDigits.length() < 2) { hexString.append("0"); } hexString.append(hexDigits); } return hexString.toString(); }
java
private static String convertByteArrayToString(byte[] byteArray) { if (byteArray == null) { throw new IllegalArgumentException("Byte array must not be null!"); } StringBuffer hexString = new StringBuffer(); for (int i = 0; i < byteArray.length; i++) { int digit = 0xFF & byteArray[i]; String hexDigits = Integer.toHexString(digit); if (hexDigits.length() < 2) { hexString.append("0"); } hexString.append(hexDigits); } return hexString.toString(); }
[ "private", "static", "String", "convertByteArrayToString", "(", "byte", "[", "]", "byteArray", ")", "{", "if", "(", "byteArray", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Byte array must not be null!\"", ")", ";", "}", "StringBuffer", "hexString", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "byteArray", ".", "length", ";", "i", "++", ")", "{", "int", "digit", "=", "0xFF", "&", "byteArray", "[", "i", "]", ";", "String", "hexDigits", "=", "Integer", ".", "toHexString", "(", "digit", ")", ";", "if", "(", "hexDigits", ".", "length", "(", ")", "<", "2", ")", "{", "hexString", ".", "append", "(", "\"0\"", ")", ";", "}", "hexString", ".", "append", "(", "hexDigits", ")", ";", "}", "return", "hexString", ".", "toString", "(", ")", ";", "}" ]
This method converts a byte array into a string converting each byte into a 2-digit hex representation and appending them all together. @param byteArray is the array of bytes to be converted. @return A {@link String} is returned representing the byte array.
[ "This", "method", "converts", "a", "byte", "array", "into", "a", "string", "converting", "each", "byte", "into", "a", "2", "-", "digit", "hex", "representation", "and", "appending", "them", "all", "together", "." ]
f98c23d8841a1ff61632ff17fe7d24f99dbc1d44
https://github.com/PureSolTechnologies/commons/blob/f98c23d8841a1ff61632ff17fe7d24f99dbc1d44/misc/src/main/java/com/puresoltechnologies/commons/misc/hash/HashUtilities.java#L90-L104
154,637
hudson3-plugins/warnings-plugin
src/main/java/hudson/plugins/warnings/parser/ViolationsRegistry.java
ViolationsRegistry.addParsers
public static void addParsers(final List<AbstractWarningsParser> parsers) { parsers.add(new ViolationsAdapter(new CodenarcParser(), Messages._Warnings_Codenarc_ParserName(), Messages._Warnings_Codenarc_LinkName(), Messages._Warnings_Codenarc_TrendName())); parsers.add(new ViolationsAdapter(new CssLintParser(), Messages._Warnings_CssLint_ParserName(), Messages._Warnings_CssLint_LinkName(), Messages._Warnings_CssLint_TrendName())); parsers.add(new ViolationsAdapter(new GendarmeParser(), Messages._Warnings_Gendarme_ParserName(), Messages._Warnings_Gendarme_LinkName(), Messages._Warnings_Gendarme_TrendName())); parsers.add(new ViolationsAdapter(new JcReportParser(), Messages._Warnings_JCReport_ParserName(), Messages._Warnings_JCReport_LinkName(), Messages._Warnings_JCReport_TrendName())); parsers.add(new ViolationsAdapter(new Pep8Parser(), Messages._Warnings_Pep8_ParserName(), Messages._Warnings_Pep8_LinkName(), Messages._Warnings_Pep8_TrendName())); }
java
public static void addParsers(final List<AbstractWarningsParser> parsers) { parsers.add(new ViolationsAdapter(new CodenarcParser(), Messages._Warnings_Codenarc_ParserName(), Messages._Warnings_Codenarc_LinkName(), Messages._Warnings_Codenarc_TrendName())); parsers.add(new ViolationsAdapter(new CssLintParser(), Messages._Warnings_CssLint_ParserName(), Messages._Warnings_CssLint_LinkName(), Messages._Warnings_CssLint_TrendName())); parsers.add(new ViolationsAdapter(new GendarmeParser(), Messages._Warnings_Gendarme_ParserName(), Messages._Warnings_Gendarme_LinkName(), Messages._Warnings_Gendarme_TrendName())); parsers.add(new ViolationsAdapter(new JcReportParser(), Messages._Warnings_JCReport_ParserName(), Messages._Warnings_JCReport_LinkName(), Messages._Warnings_JCReport_TrendName())); parsers.add(new ViolationsAdapter(new Pep8Parser(), Messages._Warnings_Pep8_ParserName(), Messages._Warnings_Pep8_LinkName(), Messages._Warnings_Pep8_TrendName())); }
[ "public", "static", "void", "addParsers", "(", "final", "List", "<", "AbstractWarningsParser", ">", "parsers", ")", "{", "parsers", ".", "add", "(", "new", "ViolationsAdapter", "(", "new", "CodenarcParser", "(", ")", ",", "Messages", ".", "_Warnings_Codenarc_ParserName", "(", ")", ",", "Messages", ".", "_Warnings_Codenarc_LinkName", "(", ")", ",", "Messages", ".", "_Warnings_Codenarc_TrendName", "(", ")", ")", ")", ";", "parsers", ".", "add", "(", "new", "ViolationsAdapter", "(", "new", "CssLintParser", "(", ")", ",", "Messages", ".", "_Warnings_CssLint_ParserName", "(", ")", ",", "Messages", ".", "_Warnings_CssLint_LinkName", "(", ")", ",", "Messages", ".", "_Warnings_CssLint_TrendName", "(", ")", ")", ")", ";", "parsers", ".", "add", "(", "new", "ViolationsAdapter", "(", "new", "GendarmeParser", "(", ")", ",", "Messages", ".", "_Warnings_Gendarme_ParserName", "(", ")", ",", "Messages", ".", "_Warnings_Gendarme_LinkName", "(", ")", ",", "Messages", ".", "_Warnings_Gendarme_TrendName", "(", ")", ")", ")", ";", "parsers", ".", "add", "(", "new", "ViolationsAdapter", "(", "new", "JcReportParser", "(", ")", ",", "Messages", ".", "_Warnings_JCReport_ParserName", "(", ")", ",", "Messages", ".", "_Warnings_JCReport_LinkName", "(", ")", ",", "Messages", ".", "_Warnings_JCReport_TrendName", "(", ")", ")", ")", ";", "parsers", ".", "add", "(", "new", "ViolationsAdapter", "(", "new", "Pep8Parser", "(", ")", ",", "Messages", ".", "_Warnings_Pep8_ParserName", "(", ")", ",", "Messages", ".", "_Warnings_Pep8_LinkName", "(", ")", ",", "Messages", ".", "_Warnings_Pep8_TrendName", "(", ")", ")", ")", ";", "}" ]
Appends the parsers of the violations plug-in to the specified list of parsers. @param parsers the list of parsers that will be modified
[ "Appends", "the", "parsers", "of", "the", "violations", "plug", "-", "in", "to", "the", "specified", "list", "of", "parsers", "." ]
462c9f3dffede9120173935567392b22520b0966
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/ViolationsRegistry.java#L24-L45
154,638
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/DoubleConverter.java
DoubleConverter.toNullableDouble
public static Double toNullableDouble(Object value) { if (value == null) return null; if (value instanceof Date) return (double) ((Date) value).getTime(); if (value instanceof Calendar) return (double) ((Calendar) value).getTimeInMillis(); if (value instanceof Duration) return (double) ((Duration) value).toMillis(); if (value instanceof Boolean) return (boolean) value ? 1.0 : 0.0; if (value instanceof Integer) return (double) ((int) value); if (value instanceof Short) return (double) ((short) value); if (value instanceof Long) return (double) ((long) value); if (value instanceof Float) return (double) ((float) value); if (value instanceof Double) return (double) value; if (value instanceof String) try { return Double.parseDouble((String) value); } catch (NumberFormatException ex) { return null; } return null; }
java
public static Double toNullableDouble(Object value) { if (value == null) return null; if (value instanceof Date) return (double) ((Date) value).getTime(); if (value instanceof Calendar) return (double) ((Calendar) value).getTimeInMillis(); if (value instanceof Duration) return (double) ((Duration) value).toMillis(); if (value instanceof Boolean) return (boolean) value ? 1.0 : 0.0; if (value instanceof Integer) return (double) ((int) value); if (value instanceof Short) return (double) ((short) value); if (value instanceof Long) return (double) ((long) value); if (value instanceof Float) return (double) ((float) value); if (value instanceof Double) return (double) value; if (value instanceof String) try { return Double.parseDouble((String) value); } catch (NumberFormatException ex) { return null; } return null; }
[ "public", "static", "Double", "toNullableDouble", "(", "Object", "value", ")", "{", "if", "(", "value", "==", "null", ")", "return", "null", ";", "if", "(", "value", "instanceof", "Date", ")", "return", "(", "double", ")", "(", "(", "Date", ")", "value", ")", ".", "getTime", "(", ")", ";", "if", "(", "value", "instanceof", "Calendar", ")", "return", "(", "double", ")", "(", "(", "Calendar", ")", "value", ")", ".", "getTimeInMillis", "(", ")", ";", "if", "(", "value", "instanceof", "Duration", ")", "return", "(", "double", ")", "(", "(", "Duration", ")", "value", ")", ".", "toMillis", "(", ")", ";", "if", "(", "value", "instanceof", "Boolean", ")", "return", "(", "boolean", ")", "value", "?", "1.0", ":", "0.0", ";", "if", "(", "value", "instanceof", "Integer", ")", "return", "(", "double", ")", "(", "(", "int", ")", "value", ")", ";", "if", "(", "value", "instanceof", "Short", ")", "return", "(", "double", ")", "(", "(", "short", ")", "value", ")", ";", "if", "(", "value", "instanceof", "Long", ")", "return", "(", "double", ")", "(", "(", "long", ")", "value", ")", ";", "if", "(", "value", "instanceof", "Float", ")", "return", "(", "double", ")", "(", "(", "float", ")", "value", ")", ";", "if", "(", "value", "instanceof", "Double", ")", "return", "(", "double", ")", "value", ";", "if", "(", "value", "instanceof", "String", ")", "try", "{", "return", "Double", ".", "parseDouble", "(", "(", "String", ")", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "return", "null", ";", "}", "return", "null", ";", "}" ]
Converts value into doubles or returns null when conversion is not possible. @param value the value to convert. @return double value or null when conversion is not supported.
[ "Converts", "value", "into", "doubles", "or", "returns", "null", "when", "conversion", "is", "not", "possible", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/DoubleConverter.java#L32-L65
154,639
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/DoubleConverter.java
DoubleConverter.toDoubleWithDefault
public static double toDoubleWithDefault(Object value, double defaultValue) { Double result = toNullableDouble(value); return result != null ? (double) result : defaultValue; }
java
public static double toDoubleWithDefault(Object value, double defaultValue) { Double result = toNullableDouble(value); return result != null ? (double) result : defaultValue; }
[ "public", "static", "double", "toDoubleWithDefault", "(", "Object", "value", ",", "double", "defaultValue", ")", "{", "Double", "result", "=", "toNullableDouble", "(", "value", ")", ";", "return", "result", "!=", "null", "?", "(", "double", ")", "result", ":", "defaultValue", ";", "}" ]
Converts value into doubles or returns default value when conversion is not possible. @param value the value to convert. @param defaultValue the default value. @return double value or default when conversion is not supported. @see DoubleConverter#toNullableDouble(Object)
[ "Converts", "value", "into", "doubles", "or", "returns", "default", "value", "when", "conversion", "is", "not", "possible", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/DoubleConverter.java#L89-L92
154,640
JM-Lab/utils-java8
src/main/java/kr/jm/utils/collections/JMNestedMap.java
JMNestedMap.put
public V put(K1 key1, K2 key2, V value) { return getOrPutGetNew(key1).put(key2, value); }
java
public V put(K1 key1, K2 key2, V value) { return getOrPutGetNew(key1).put(key2, value); }
[ "public", "V", "put", "(", "K1", "key1", ",", "K2", "key2", ",", "V", "value", ")", "{", "return", "getOrPutGetNew", "(", "key1", ")", ".", "put", "(", "key2", ",", "value", ")", ";", "}" ]
Put v. @param key1 the key 1 @param key2 the key 2 @param value the value @return the v
[ "Put", "v", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/JMNestedMap.java#L150-L152
154,641
JM-Lab/utils-java8
src/main/java/kr/jm/utils/collections/JMNestedMap.java
JMNestedMap.get
public V get(K1 key1, K2 key2) { return JMOptional.getOptional(nestedMap, key1).map(map -> map.get(key2)) .orElse(null); }
java
public V get(K1 key1, K2 key2) { return JMOptional.getOptional(nestedMap, key1).map(map -> map.get(key2)) .orElse(null); }
[ "public", "V", "get", "(", "K1", "key1", ",", "K2", "key2", ")", "{", "return", "JMOptional", ".", "getOptional", "(", "nestedMap", ",", "key1", ")", ".", "map", "(", "map", "->", "map", ".", "get", "(", "key2", ")", ")", ".", "orElse", "(", "null", ")", ";", "}" ]
Get v. @param key1 the key 1 @param key2 the key 2 @return the v
[ "Get", "v", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/JMNestedMap.java#L161-L164
154,642
finsterwalder/fileutils
src/main/java/name/finsterwalder/utils/Ensure.java
Ensure.notEmpty
public static void notEmpty(final Collection<?> collection, final String parameterName) { if (collection.isEmpty()) { throw new IllegalArgumentException("\"" + parameterName + "\" must not be null or empty, but was: " + collection); } }
java
public static void notEmpty(final Collection<?> collection, final String parameterName) { if (collection.isEmpty()) { throw new IllegalArgumentException("\"" + parameterName + "\" must not be null or empty, but was: " + collection); } }
[ "public", "static", "void", "notEmpty", "(", "final", "Collection", "<", "?", ">", "collection", ",", "final", "String", "parameterName", ")", "{", "if", "(", "collection", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\\\"\"", "+", "parameterName", "+", "\"\\\" must not be null or empty, but was: \"", "+", "collection", ")", ";", "}", "}" ]
Check that the provided Collection is not empty). @param collection collection to check @param parameterName name of the parameter to display in the error message
[ "Check", "that", "the", "provided", "Collection", "is", "not", "empty", ")", "." ]
db5e00f37a2c8bbdfd9bc070d187620c2ed1ad29
https://github.com/finsterwalder/fileutils/blob/db5e00f37a2c8bbdfd9bc070d187620c2ed1ad29/src/main/java/name/finsterwalder/utils/Ensure.java#L76-L80
154,643
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/InputPassword.java
InputPassword.readPassword
public String readPassword() { this.before = ""; this.after = ""; terminal.formatln("%s: ", message); try { for (; ; ) { Char c = terminal.read(); if (c == null) { throw new IOException("End of input."); } int ch = c.asInteger(); if (ch == Char.CR) { return before + after; } if (ch == Char.DEL || ch == Char.BS) { // backspace... if (before.length() > 0) { before = before.substring(0, before.length() - 1); printInputLine(); } continue; } if (c instanceof Control) { if (c.equals(Control.DELETE)) { if (after.length() > 0) { after = after.substring(1); } } else if (c.equals(Control.LEFT)) { if (before.length() > 0) { after = "" + before.charAt(before.length() - 1) + after; before = before.substring(0, before.length() - 1); } } else if (c.equals(Control.HOME)) { after = before + after; before = ""; } else if (c.equals(Control.RIGHT)) { if (after.length() > 0) { before = before + after.charAt(0); after = after.substring(1); } } else if (c.equals(Control.END)) { before = before + after; after = ""; } else { // Silently ignore unknown control chars. continue; } printInputLine(); continue; } if (ch == Char.ESC || ch == Char.ABR || ch == Char.EOF) { throw new IOException("User interrupted: " + c.asString()); } if (ch < 0x20) { // Silently ignore unknown ASCII control characters. continue; } before = before + c.toString(); printInputLine(); } } catch (IOException e) { throw new UncheckedIOException(e); } }
java
public String readPassword() { this.before = ""; this.after = ""; terminal.formatln("%s: ", message); try { for (; ; ) { Char c = terminal.read(); if (c == null) { throw new IOException("End of input."); } int ch = c.asInteger(); if (ch == Char.CR) { return before + after; } if (ch == Char.DEL || ch == Char.BS) { // backspace... if (before.length() > 0) { before = before.substring(0, before.length() - 1); printInputLine(); } continue; } if (c instanceof Control) { if (c.equals(Control.DELETE)) { if (after.length() > 0) { after = after.substring(1); } } else if (c.equals(Control.LEFT)) { if (before.length() > 0) { after = "" + before.charAt(before.length() - 1) + after; before = before.substring(0, before.length() - 1); } } else if (c.equals(Control.HOME)) { after = before + after; before = ""; } else if (c.equals(Control.RIGHT)) { if (after.length() > 0) { before = before + after.charAt(0); after = after.substring(1); } } else if (c.equals(Control.END)) { before = before + after; after = ""; } else { // Silently ignore unknown control chars. continue; } printInputLine(); continue; } if (ch == Char.ESC || ch == Char.ABR || ch == Char.EOF) { throw new IOException("User interrupted: " + c.asString()); } if (ch < 0x20) { // Silently ignore unknown ASCII control characters. continue; } before = before + c.toString(); printInputLine(); } } catch (IOException e) { throw new UncheckedIOException(e); } }
[ "public", "String", "readPassword", "(", ")", "{", "this", ".", "before", "=", "\"\"", ";", "this", ".", "after", "=", "\"\"", ";", "terminal", ".", "formatln", "(", "\"%s: \"", ",", "message", ")", ";", "try", "{", "for", "(", ";", ";", ")", "{", "Char", "c", "=", "terminal", ".", "read", "(", ")", ";", "if", "(", "c", "==", "null", ")", "{", "throw", "new", "IOException", "(", "\"End of input.\"", ")", ";", "}", "int", "ch", "=", "c", ".", "asInteger", "(", ")", ";", "if", "(", "ch", "==", "Char", ".", "CR", ")", "{", "return", "before", "+", "after", ";", "}", "if", "(", "ch", "==", "Char", ".", "DEL", "||", "ch", "==", "Char", ".", "BS", ")", "{", "// backspace...", "if", "(", "before", ".", "length", "(", ")", ">", "0", ")", "{", "before", "=", "before", ".", "substring", "(", "0", ",", "before", ".", "length", "(", ")", "-", "1", ")", ";", "printInputLine", "(", ")", ";", "}", "continue", ";", "}", "if", "(", "c", "instanceof", "Control", ")", "{", "if", "(", "c", ".", "equals", "(", "Control", ".", "DELETE", ")", ")", "{", "if", "(", "after", ".", "length", "(", ")", ">", "0", ")", "{", "after", "=", "after", ".", "substring", "(", "1", ")", ";", "}", "}", "else", "if", "(", "c", ".", "equals", "(", "Control", ".", "LEFT", ")", ")", "{", "if", "(", "before", ".", "length", "(", ")", ">", "0", ")", "{", "after", "=", "\"\"", "+", "before", ".", "charAt", "(", "before", ".", "length", "(", ")", "-", "1", ")", "+", "after", ";", "before", "=", "before", ".", "substring", "(", "0", ",", "before", ".", "length", "(", ")", "-", "1", ")", ";", "}", "}", "else", "if", "(", "c", ".", "equals", "(", "Control", ".", "HOME", ")", ")", "{", "after", "=", "before", "+", "after", ";", "before", "=", "\"\"", ";", "}", "else", "if", "(", "c", ".", "equals", "(", "Control", ".", "RIGHT", ")", ")", "{", "if", "(", "after", ".", "length", "(", ")", ">", "0", ")", "{", "before", "=", "before", "+", "after", ".", "charAt", "(", "0", ")", ";", "after", "=", "after", ".", "substring", "(", "1", ")", ";", "}", "}", "else", "if", "(", "c", ".", "equals", "(", "Control", ".", "END", ")", ")", "{", "before", "=", "before", "+", "after", ";", "after", "=", "\"\"", ";", "}", "else", "{", "// Silently ignore unknown control chars.", "continue", ";", "}", "printInputLine", "(", ")", ";", "continue", ";", "}", "if", "(", "ch", "==", "Char", ".", "ESC", "||", "ch", "==", "Char", ".", "ABR", "||", "ch", "==", "Char", ".", "EOF", ")", "{", "throw", "new", "IOException", "(", "\"User interrupted: \"", "+", "c", ".", "asString", "(", ")", ")", ";", "}", "if", "(", "ch", "<", "0x20", ")", "{", "// Silently ignore unknown ASCII control characters.", "continue", ";", "}", "before", "=", "before", "+", "c", ".", "toString", "(", ")", ";", "printInputLine", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "UncheckedIOException", "(", "e", ")", ";", "}", "}" ]
Read password from terminal. @return The resulting line.
[ "Read", "password", "from", "terminal", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/InputPassword.java#L72-L144
154,644
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/LineBuffer.java
LineBuffer.add
public void add(Collection<String> lines) { for (String line : lines) { buffer.add(line); terminal.println(line); } }
java
public void add(Collection<String> lines) { for (String line : lines) { buffer.add(line); terminal.println(line); } }
[ "public", "void", "add", "(", "Collection", "<", "String", ">", "lines", ")", "{", "for", "(", "String", "line", ":", "lines", ")", "{", "buffer", ".", "add", "(", "line", ")", ";", "terminal", ".", "println", "(", "line", ")", ";", "}", "}" ]
Add new lines to the end of the buffer, and print them out. @param lines The lines to add.
[ "Add", "new", "lines", "to", "the", "end", "of", "the", "buffer", "and", "print", "them", "out", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/LineBuffer.java#L83-L88
154,645
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/LineBuffer.java
LineBuffer.update
public void update(int offset, List<String> lines) { if (lines.isEmpty()) { throw new IllegalArgumentException("Empty line set"); } if (offset >= count() || offset < 0) { throw new IndexOutOfBoundsException("Index: " + offset + ", Size: " + count()); } int up = count() - offset - 1; for (int i = 0; i < lines.size(); ++i) { String line = lines.get(i); if (i == 0) { terminal.print("\r"); if (up > 0) { terminal.print(cursorUp(up)); } } else { terminal.println(); --up; } String old = offset + i < buffer.size() ? buffer.get(offset + i) : null; buffer.set(offset + i, line); if (line.equals(old) && !line.isEmpty()) { // No change. continue; } terminal.print(CURSOR_ERASE); terminal.print(line); } // Move the cursor back to the end of the last line. if (up > 0) { terminal.format("\r%s%s", cursorDown(up), cursorRight(printableWidth(lastLine()))); } }
java
public void update(int offset, List<String> lines) { if (lines.isEmpty()) { throw new IllegalArgumentException("Empty line set"); } if (offset >= count() || offset < 0) { throw new IndexOutOfBoundsException("Index: " + offset + ", Size: " + count()); } int up = count() - offset - 1; for (int i = 0; i < lines.size(); ++i) { String line = lines.get(i); if (i == 0) { terminal.print("\r"); if (up > 0) { terminal.print(cursorUp(up)); } } else { terminal.println(); --up; } String old = offset + i < buffer.size() ? buffer.get(offset + i) : null; buffer.set(offset + i, line); if (line.equals(old) && !line.isEmpty()) { // No change. continue; } terminal.print(CURSOR_ERASE); terminal.print(line); } // Move the cursor back to the end of the last line. if (up > 0) { terminal.format("\r%s%s", cursorDown(up), cursorRight(printableWidth(lastLine()))); } }
[ "public", "void", "update", "(", "int", "offset", ",", "List", "<", "String", ">", "lines", ")", "{", "if", "(", "lines", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Empty line set\"", ")", ";", "}", "if", "(", "offset", ">=", "count", "(", ")", "||", "offset", "<", "0", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", "\"Index: \"", "+", "offset", "+", "\", Size: \"", "+", "count", "(", ")", ")", ";", "}", "int", "up", "=", "count", "(", ")", "-", "offset", "-", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "lines", ".", "size", "(", ")", ";", "++", "i", ")", "{", "String", "line", "=", "lines", ".", "get", "(", "i", ")", ";", "if", "(", "i", "==", "0", ")", "{", "terminal", ".", "print", "(", "\"\\r\"", ")", ";", "if", "(", "up", ">", "0", ")", "{", "terminal", ".", "print", "(", "cursorUp", "(", "up", ")", ")", ";", "}", "}", "else", "{", "terminal", ".", "println", "(", ")", ";", "--", "up", ";", "}", "String", "old", "=", "offset", "+", "i", "<", "buffer", ".", "size", "(", ")", "?", "buffer", ".", "get", "(", "offset", "+", "i", ")", ":", "null", ";", "buffer", ".", "set", "(", "offset", "+", "i", ",", "line", ")", ";", "if", "(", "line", ".", "equals", "(", "old", ")", "&&", "!", "line", ".", "isEmpty", "(", ")", ")", "{", "// No change.", "continue", ";", "}", "terminal", ".", "print", "(", "CURSOR_ERASE", ")", ";", "terminal", ".", "print", "(", "line", ")", ";", "}", "// Move the cursor back to the end of the last line.", "if", "(", "up", ">", "0", ")", "{", "terminal", ".", "format", "(", "\"\\r%s%s\"", ",", "cursorDown", "(", "up", ")", ",", "cursorRight", "(", "printableWidth", "(", "lastLine", "(", ")", ")", ")", ")", ";", "}", "}" ]
Update a number of lines starting at a specific offset. @param offset The line offset (0-indexed to count). @param lines The new line content.
[ "Update", "a", "number", "of", "lines", "starting", "at", "a", "specific", "offset", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/LineBuffer.java#L106-L146
154,646
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/LineBuffer.java
LineBuffer.clear
public void clear() { if (buffer.size() > 0) { terminal.format("\r%s", CURSOR_ERASE); for (int i = 1; i < buffer.size(); ++i) { terminal.format("%s%s", UP, CURSOR_ERASE); } buffer.clear(); } }
java
public void clear() { if (buffer.size() > 0) { terminal.format("\r%s", CURSOR_ERASE); for (int i = 1; i < buffer.size(); ++i) { terminal.format("%s%s", UP, CURSOR_ERASE); } buffer.clear(); } }
[ "public", "void", "clear", "(", ")", "{", "if", "(", "buffer", ".", "size", "(", ")", ">", "0", ")", "{", "terminal", ".", "format", "(", "\"\\r%s\"", ",", "CURSOR_ERASE", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "buffer", ".", "size", "(", ")", ";", "++", "i", ")", "{", "terminal", ".", "format", "(", "\"%s%s\"", ",", "UP", ",", "CURSOR_ERASE", ")", ";", "}", "buffer", ".", "clear", "(", ")", ";", "}", "}" ]
Clear the entire buffer, and the terminal area it represents.
[ "Clear", "the", "entire", "buffer", "and", "the", "terminal", "area", "it", "represents", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/LineBuffer.java#L151-L159
154,647
morimekta/utils
console-util/src/main/java/net/morimekta/console/terminal/LineBuffer.java
LineBuffer.clearLast
public void clearLast(int N) { if (N < 1) { throw new IllegalArgumentException("Unable to clear " + N + " lines"); } if (N > count()) { throw new IllegalArgumentException("Count: " + N + ", Size: " + count()); } if (N == count()) { clear(); return; } terminal.format("\r%s", CURSOR_ERASE); buffer.remove(buffer.size() - 1); for (int i = 1; i < N; ++i) { terminal.format("%s%s", UP, CURSOR_ERASE); buffer.remove(buffer.size() - 1); } terminal.format("%s\r%s", UP, cursorRight(printableWidth(lastLine()))); }
java
public void clearLast(int N) { if (N < 1) { throw new IllegalArgumentException("Unable to clear " + N + " lines"); } if (N > count()) { throw new IllegalArgumentException("Count: " + N + ", Size: " + count()); } if (N == count()) { clear(); return; } terminal.format("\r%s", CURSOR_ERASE); buffer.remove(buffer.size() - 1); for (int i = 1; i < N; ++i) { terminal.format("%s%s", UP, CURSOR_ERASE); buffer.remove(buffer.size() - 1); } terminal.format("%s\r%s", UP, cursorRight(printableWidth(lastLine()))); }
[ "public", "void", "clearLast", "(", "int", "N", ")", "{", "if", "(", "N", "<", "1", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unable to clear \"", "+", "N", "+", "\" lines\"", ")", ";", "}", "if", "(", "N", ">", "count", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Count: \"", "+", "N", "+", "\", Size: \"", "+", "count", "(", ")", ")", ";", "}", "if", "(", "N", "==", "count", "(", ")", ")", "{", "clear", "(", ")", ";", "return", ";", "}", "terminal", ".", "format", "(", "\"\\r%s\"", ",", "CURSOR_ERASE", ")", ";", "buffer", ".", "remove", "(", "buffer", ".", "size", "(", ")", "-", "1", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "N", ";", "++", "i", ")", "{", "terminal", ".", "format", "(", "\"%s%s\"", ",", "UP", ",", "CURSOR_ERASE", ")", ";", "buffer", ".", "remove", "(", "buffer", ".", "size", "(", ")", "-", "1", ")", ";", "}", "terminal", ".", "format", "(", "\"%s\\r%s\"", ",", "UP", ",", "cursorRight", "(", "printableWidth", "(", "lastLine", "(", ")", ")", ")", ")", ";", "}" ]
Clear the last N lines, and move the cursor to the end of the last remaining line. @param N Number of lines to clear.
[ "Clear", "the", "last", "N", "lines", "and", "move", "the", "cursor", "to", "the", "end", "of", "the", "last", "remaining", "line", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/LineBuffer.java#L167-L189
154,648
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.copy
public static Path copy(Path sourcePath, Path destinationPath, CopyOption... options) { return operate(sourcePath, destinationPath, "copy", finalPath -> { try { return Files.copy(sourcePath, finalPath, options); } catch (Exception e) { return JMExceptionManager.handleExceptionAndReturnNull(log, e, "copy", sourcePath, destinationPath, options); } }); }
java
public static Path copy(Path sourcePath, Path destinationPath, CopyOption... options) { return operate(sourcePath, destinationPath, "copy", finalPath -> { try { return Files.copy(sourcePath, finalPath, options); } catch (Exception e) { return JMExceptionManager.handleExceptionAndReturnNull(log, e, "copy", sourcePath, destinationPath, options); } }); }
[ "public", "static", "Path", "copy", "(", "Path", "sourcePath", ",", "Path", "destinationPath", ",", "CopyOption", "...", "options", ")", "{", "return", "operate", "(", "sourcePath", ",", "destinationPath", ",", "\"copy\"", ",", "finalPath", "->", "{", "try", "{", "return", "Files", ".", "copy", "(", "sourcePath", ",", "finalPath", ",", "options", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "JMExceptionManager", ".", "handleExceptionAndReturnNull", "(", "log", ",", "e", ",", "\"copy\"", ",", "sourcePath", ",", "destinationPath", ",", "options", ")", ";", "}", "}", ")", ";", "}" ]
Copy path. @param sourcePath the source path @param destinationPath the destination path @param options the options @return the path
[ "Copy", "path", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L39-L49
154,649
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.copyDirRecursivelyAsync
public static Optional<JMProgressiveManager<Path, Path>> copyDirRecursivelyAsync(Path targetDirPath, Path destinationDirPath, CopyOption... options) { Map<Boolean, List<Path>> directoryOrFilePathMap = JMLambda.groupBy( JMPath.getSubPathList(targetDirPath), JMPath::isDirectory); JMOptional.getOptional(directoryOrFilePathMap, true) .ifPresent(list -> list.stream() .map(dirPath -> JMPath.buildRelativeDestinationPath( destinationDirPath, targetDirPath, dirPath)) .forEach(JMPathOperation::createDirectories)); return operateDir(targetDirPath, destinationDirPath, directoryOrFilePathMap.get(false), bulkPathList -> new JMProgressiveManager<>(bulkPathList, path -> Optional.ofNullable(copy(path, JMPath.buildRelativeDestinationPath( destinationDirPath, targetDirPath, path), options)))); }
java
public static Optional<JMProgressiveManager<Path, Path>> copyDirRecursivelyAsync(Path targetDirPath, Path destinationDirPath, CopyOption... options) { Map<Boolean, List<Path>> directoryOrFilePathMap = JMLambda.groupBy( JMPath.getSubPathList(targetDirPath), JMPath::isDirectory); JMOptional.getOptional(directoryOrFilePathMap, true) .ifPresent(list -> list.stream() .map(dirPath -> JMPath.buildRelativeDestinationPath( destinationDirPath, targetDirPath, dirPath)) .forEach(JMPathOperation::createDirectories)); return operateDir(targetDirPath, destinationDirPath, directoryOrFilePathMap.get(false), bulkPathList -> new JMProgressiveManager<>(bulkPathList, path -> Optional.ofNullable(copy(path, JMPath.buildRelativeDestinationPath( destinationDirPath, targetDirPath, path), options)))); }
[ "public", "static", "Optional", "<", "JMProgressiveManager", "<", "Path", ",", "Path", ">", ">", "copyDirRecursivelyAsync", "(", "Path", "targetDirPath", ",", "Path", "destinationDirPath", ",", "CopyOption", "...", "options", ")", "{", "Map", "<", "Boolean", ",", "List", "<", "Path", ">", ">", "directoryOrFilePathMap", "=", "JMLambda", ".", "groupBy", "(", "JMPath", ".", "getSubPathList", "(", "targetDirPath", ")", ",", "JMPath", "::", "isDirectory", ")", ";", "JMOptional", ".", "getOptional", "(", "directoryOrFilePathMap", ",", "true", ")", ".", "ifPresent", "(", "list", "->", "list", ".", "stream", "(", ")", ".", "map", "(", "dirPath", "->", "JMPath", ".", "buildRelativeDestinationPath", "(", "destinationDirPath", ",", "targetDirPath", ",", "dirPath", ")", ")", ".", "forEach", "(", "JMPathOperation", "::", "createDirectories", ")", ")", ";", "return", "operateDir", "(", "targetDirPath", ",", "destinationDirPath", ",", "directoryOrFilePathMap", ".", "get", "(", "false", ")", ",", "bulkPathList", "->", "new", "JMProgressiveManager", "<>", "(", "bulkPathList", ",", "path", "->", "Optional", ".", "ofNullable", "(", "copy", "(", "path", ",", "JMPath", ".", "buildRelativeDestinationPath", "(", "destinationDirPath", ",", "targetDirPath", ",", "path", ")", ",", "options", ")", ")", ")", ")", ";", "}" ]
Copy dir recursively async optional. @param targetDirPath the target dir path @param destinationDirPath the destination dir path @param options the options @return the optional
[ "Copy", "dir", "recursively", "async", "optional", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L59-L77
154,650
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.copyFilePathListAsync
public static Optional<JMProgressiveManager<Path, Path>> copyFilePathListAsync(List<Path> filePathList, Path destinationDirPath, CopyOption... options) { return operateBulk(filePathList, destinationDirPath, sourcePath -> Optional.ofNullable( copy(sourcePath, destinationDirPath, options))); }
java
public static Optional<JMProgressiveManager<Path, Path>> copyFilePathListAsync(List<Path> filePathList, Path destinationDirPath, CopyOption... options) { return operateBulk(filePathList, destinationDirPath, sourcePath -> Optional.ofNullable( copy(sourcePath, destinationDirPath, options))); }
[ "public", "static", "Optional", "<", "JMProgressiveManager", "<", "Path", ",", "Path", ">", ">", "copyFilePathListAsync", "(", "List", "<", "Path", ">", "filePathList", ",", "Path", "destinationDirPath", ",", "CopyOption", "...", "options", ")", "{", "return", "operateBulk", "(", "filePathList", ",", "destinationDirPath", ",", "sourcePath", "->", "Optional", ".", "ofNullable", "(", "copy", "(", "sourcePath", ",", "destinationDirPath", ",", "options", ")", ")", ")", ";", "}" ]
Copy file path list async optional. @param filePathList the file path list @param destinationDirPath the destination dir path @param options the options @return the optional
[ "Copy", "file", "path", "list", "async", "optional", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L87-L93
154,651
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.moveDir
public static Optional<Path> moveDir(Path sourceDirPath, Path destinationDirPath, CopyOption... options) { return operateDir(sourceDirPath, destinationDirPath, sourceDirPath, path -> move(path, destinationDirPath, options)); }
java
public static Optional<Path> moveDir(Path sourceDirPath, Path destinationDirPath, CopyOption... options) { return operateDir(sourceDirPath, destinationDirPath, sourceDirPath, path -> move(path, destinationDirPath, options)); }
[ "public", "static", "Optional", "<", "Path", ">", "moveDir", "(", "Path", "sourceDirPath", ",", "Path", "destinationDirPath", ",", "CopyOption", "...", "options", ")", "{", "return", "operateDir", "(", "sourceDirPath", ",", "destinationDirPath", ",", "sourceDirPath", ",", "path", "->", "move", "(", "path", ",", "destinationDirPath", ",", "options", ")", ")", ";", "}" ]
Move dir optional. @param sourceDirPath the source dir path @param destinationDirPath the destination dir path @param options the options @return the optional
[ "Move", "dir", "optional", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L123-L127
154,652
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.movePathListAsync
public static Optional<JMProgressiveManager<Path, Path>> movePathListAsync( List<Path> pathList, Path destinationDirPath, CopyOption... options) { return operateBulk(pathList, destinationDirPath, sourcePath -> JMPath.isDirectory(sourcePath) ? moveDir(sourcePath, destinationDirPath, options) : Optional.ofNullable( move(sourcePath, destinationDirPath, options))); }
java
public static Optional<JMProgressiveManager<Path, Path>> movePathListAsync( List<Path> pathList, Path destinationDirPath, CopyOption... options) { return operateBulk(pathList, destinationDirPath, sourcePath -> JMPath.isDirectory(sourcePath) ? moveDir(sourcePath, destinationDirPath, options) : Optional.ofNullable( move(sourcePath, destinationDirPath, options))); }
[ "public", "static", "Optional", "<", "JMProgressiveManager", "<", "Path", ",", "Path", ">", ">", "movePathListAsync", "(", "List", "<", "Path", ">", "pathList", ",", "Path", "destinationDirPath", ",", "CopyOption", "...", "options", ")", "{", "return", "operateBulk", "(", "pathList", ",", "destinationDirPath", ",", "sourcePath", "->", "JMPath", ".", "isDirectory", "(", "sourcePath", ")", "?", "moveDir", "(", "sourcePath", ",", "destinationDirPath", ",", "options", ")", ":", "Optional", ".", "ofNullable", "(", "move", "(", "sourcePath", ",", "destinationDirPath", ",", "options", ")", ")", ")", ";", "}" ]
Move path list async optional. @param pathList the path list @param destinationDirPath the destination dir path @param options the options @return the optional
[ "Move", "path", "list", "async", "optional", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L137-L145
154,653
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.deleteAll
public static boolean deleteAll(Path targetPath) { debug(log, "deleteAll", targetPath); return JMPath.isDirectory(targetPath) ? deleteDir(targetPath) : delete(targetPath); }
java
public static boolean deleteAll(Path targetPath) { debug(log, "deleteAll", targetPath); return JMPath.isDirectory(targetPath) ? deleteDir(targetPath) : delete(targetPath); }
[ "public", "static", "boolean", "deleteAll", "(", "Path", "targetPath", ")", "{", "debug", "(", "log", ",", "\"deleteAll\"", ",", "targetPath", ")", ";", "return", "JMPath", ".", "isDirectory", "(", "targetPath", ")", "?", "deleteDir", "(", "targetPath", ")", ":", "delete", "(", "targetPath", ")", ";", "}" ]
Delete all boolean. @param targetPath the target path @return the boolean
[ "Delete", "all", "boolean", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L208-L212
154,654
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.deleteDir
public static boolean deleteDir(Path targetDirPath) { debug(log, "deleteDir", targetDirPath); return deleteBulkThenFalseList( JMCollections.getReversed(JMPath.getSubPathList(targetDirPath))) .size() == 0 && delete(targetDirPath); }
java
public static boolean deleteDir(Path targetDirPath) { debug(log, "deleteDir", targetDirPath); return deleteBulkThenFalseList( JMCollections.getReversed(JMPath.getSubPathList(targetDirPath))) .size() == 0 && delete(targetDirPath); }
[ "public", "static", "boolean", "deleteDir", "(", "Path", "targetDirPath", ")", "{", "debug", "(", "log", ",", "\"deleteDir\"", ",", "targetDirPath", ")", ";", "return", "deleteBulkThenFalseList", "(", "JMCollections", ".", "getReversed", "(", "JMPath", ".", "getSubPathList", "(", "targetDirPath", ")", ")", ")", ".", "size", "(", ")", "==", "0", "&&", "delete", "(", "targetDirPath", ")", ";", "}" ]
Delete dir boolean. @param targetDirPath the target dir path @return the boolean
[ "Delete", "dir", "boolean", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L220-L225
154,655
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.deleteBulkThenFalseList
public static List<Path> deleteBulkThenFalseList(List<Path> bulkPathList) { debug(log, "deleteBulkThenFalseList", bulkPathList); return bulkPathList.stream().filter(negate(JMPathOperation::deleteAll)) .collect(toList()); }
java
public static List<Path> deleteBulkThenFalseList(List<Path> bulkPathList) { debug(log, "deleteBulkThenFalseList", bulkPathList); return bulkPathList.stream().filter(negate(JMPathOperation::deleteAll)) .collect(toList()); }
[ "public", "static", "List", "<", "Path", ">", "deleteBulkThenFalseList", "(", "List", "<", "Path", ">", "bulkPathList", ")", "{", "debug", "(", "log", ",", "\"deleteBulkThenFalseList\"", ",", "bulkPathList", ")", ";", "return", "bulkPathList", ".", "stream", "(", ")", ".", "filter", "(", "negate", "(", "JMPathOperation", "::", "deleteAll", ")", ")", ".", "collect", "(", "toList", "(", ")", ")", ";", "}" ]
Delete bulk then false list list. @param bulkPathList the bulk path list @return the list
[ "Delete", "bulk", "then", "false", "list", "list", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L233-L237
154,656
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.deleteAllAsync
public static JMProgressiveManager<Path, Boolean> deleteAllAsync(List<Path> pathList) { debug(log, "deleteAllAsync", pathList); return new JMProgressiveManager<>(pathList, targetPath -> Optional.of(deleteAll(targetPath))); }
java
public static JMProgressiveManager<Path, Boolean> deleteAllAsync(List<Path> pathList) { debug(log, "deleteAllAsync", pathList); return new JMProgressiveManager<>(pathList, targetPath -> Optional.of(deleteAll(targetPath))); }
[ "public", "static", "JMProgressiveManager", "<", "Path", ",", "Boolean", ">", "deleteAllAsync", "(", "List", "<", "Path", ">", "pathList", ")", "{", "debug", "(", "log", ",", "\"deleteAllAsync\"", ",", "pathList", ")", ";", "return", "new", "JMProgressiveManager", "<>", "(", "pathList", ",", "targetPath", "->", "Optional", ".", "of", "(", "deleteAll", "(", "targetPath", ")", ")", ")", ";", "}" ]
Delete all async jm progressive manager. @param pathList the path list @return the jm progressive manager
[ "Delete", "all", "async", "jm", "progressive", "manager", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L245-L250
154,657
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.deleteOnExit
public static Path deleteOnExit(Path path) { debug(log, "deleteOnExit", path); path.toFile().deleteOnExit(); return path; }
java
public static Path deleteOnExit(Path path) { debug(log, "deleteOnExit", path); path.toFile().deleteOnExit(); return path; }
[ "public", "static", "Path", "deleteOnExit", "(", "Path", "path", ")", "{", "debug", "(", "log", ",", "\"deleteOnExit\"", ",", "path", ")", ";", "path", ".", "toFile", "(", ")", ".", "deleteOnExit", "(", ")", ";", "return", "path", ";", "}" ]
Delete on exit path. @param path the path @return the path
[ "Delete", "on", "exit", "path", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L258-L262
154,658
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.createTempFilePathAsOpt
public static Optional<Path> createTempFilePathAsOpt(Path path) { debug(log, "createTempFilePathAsOpt", path); String[] prefixSuffix = JMFiles.getPrefixSuffix(path.toFile()); try { return Optional .of(Files.createTempFile(prefixSuffix[0], prefixSuffix[1])) .filter(JMPath.ExistFilter) .map(JMPathOperation::deleteOnExit); } catch (Exception e) { return JMExceptionManager.handleExceptionAndReturnEmptyOptional(log, e, "createTempFilePathAsOpt", path); } }
java
public static Optional<Path> createTempFilePathAsOpt(Path path) { debug(log, "createTempFilePathAsOpt", path); String[] prefixSuffix = JMFiles.getPrefixSuffix(path.toFile()); try { return Optional .of(Files.createTempFile(prefixSuffix[0], prefixSuffix[1])) .filter(JMPath.ExistFilter) .map(JMPathOperation::deleteOnExit); } catch (Exception e) { return JMExceptionManager.handleExceptionAndReturnEmptyOptional(log, e, "createTempFilePathAsOpt", path); } }
[ "public", "static", "Optional", "<", "Path", ">", "createTempFilePathAsOpt", "(", "Path", "path", ")", "{", "debug", "(", "log", ",", "\"createTempFilePathAsOpt\"", ",", "path", ")", ";", "String", "[", "]", "prefixSuffix", "=", "JMFiles", ".", "getPrefixSuffix", "(", "path", ".", "toFile", "(", ")", ")", ";", "try", "{", "return", "Optional", ".", "of", "(", "Files", ".", "createTempFile", "(", "prefixSuffix", "[", "0", "]", ",", "prefixSuffix", "[", "1", "]", ")", ")", ".", "filter", "(", "JMPath", ".", "ExistFilter", ")", ".", "map", "(", "JMPathOperation", "::", "deleteOnExit", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "JMExceptionManager", ".", "handleExceptionAndReturnEmptyOptional", "(", "log", ",", "e", ",", "\"createTempFilePathAsOpt\"", ",", "path", ")", ";", "}", "}" ]
Create temp file path as opt optional. @param path the path @return the optional
[ "Create", "temp", "file", "path", "as", "opt", "optional", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L270-L282
154,659
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.createTempDirPathAsOpt
public static Optional<Path> createTempDirPathAsOpt(Path path) { debug(log, "createTempDirPathAsOpt", path); try { return Optional.of(Files.createTempDirectory(path.toString())) .filter(JMPath.ExistFilter) .map(JMPathOperation::deleteOnExit); } catch (Exception e) { return JMExceptionManager.handleExceptionAndReturnEmptyOptional(log, e, "createTempDirPathAsOpt", path); } }
java
public static Optional<Path> createTempDirPathAsOpt(Path path) { debug(log, "createTempDirPathAsOpt", path); try { return Optional.of(Files.createTempDirectory(path.toString())) .filter(JMPath.ExistFilter) .map(JMPathOperation::deleteOnExit); } catch (Exception e) { return JMExceptionManager.handleExceptionAndReturnEmptyOptional(log, e, "createTempDirPathAsOpt", path); } }
[ "public", "static", "Optional", "<", "Path", ">", "createTempDirPathAsOpt", "(", "Path", "path", ")", "{", "debug", "(", "log", ",", "\"createTempDirPathAsOpt\"", ",", "path", ")", ";", "try", "{", "return", "Optional", ".", "of", "(", "Files", ".", "createTempDirectory", "(", "path", ".", "toString", "(", ")", ")", ")", ".", "filter", "(", "JMPath", ".", "ExistFilter", ")", ".", "map", "(", "JMPathOperation", "::", "deleteOnExit", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "JMExceptionManager", ".", "handleExceptionAndReturnEmptyOptional", "(", "log", ",", "e", ",", "\"createTempDirPathAsOpt\"", ",", "path", ")", ";", "}", "}" ]
Create temp dir path as opt optional. @param path the path @return the optional
[ "Create", "temp", "dir", "path", "as", "opt", "optional", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L290-L300
154,660
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.createFile
public static Optional<Path> createFile(Path path, FileAttribute<?>... attrs) { debug(log, "createFile", path, attrs); try { return Optional.of(Files.createFile(path, attrs)); } catch (Exception e) { return JMExceptionManager.handleExceptionAndReturnEmptyOptional(log, e, "createFile", path); } }
java
public static Optional<Path> createFile(Path path, FileAttribute<?>... attrs) { debug(log, "createFile", path, attrs); try { return Optional.of(Files.createFile(path, attrs)); } catch (Exception e) { return JMExceptionManager.handleExceptionAndReturnEmptyOptional(log, e, "createFile", path); } }
[ "public", "static", "Optional", "<", "Path", ">", "createFile", "(", "Path", "path", ",", "FileAttribute", "<", "?", ">", "...", "attrs", ")", "{", "debug", "(", "log", ",", "\"createFile\"", ",", "path", ",", "attrs", ")", ";", "try", "{", "return", "Optional", ".", "of", "(", "Files", ".", "createFile", "(", "path", ",", "attrs", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "JMExceptionManager", ".", "handleExceptionAndReturnEmptyOptional", "(", "log", ",", "e", ",", "\"createFile\"", ",", "path", ")", ";", "}", "}" ]
Create file optional. @param path the path @param attrs the attrs @return the optional
[ "Create", "file", "optional", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L309-L318
154,661
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.createDirectories
public static Optional<Path> createDirectories(Path dirPath, FileAttribute<?>... attrs) { debug(log, "createDirectories", dirPath, attrs); try { return Optional.of(Files.createDirectories(dirPath, attrs)); } catch (Exception e) { return JMExceptionManager.handleExceptionAndReturnEmptyOptional(log, e, "createDirectories", dirPath); } }
java
public static Optional<Path> createDirectories(Path dirPath, FileAttribute<?>... attrs) { debug(log, "createDirectories", dirPath, attrs); try { return Optional.of(Files.createDirectories(dirPath, attrs)); } catch (Exception e) { return JMExceptionManager.handleExceptionAndReturnEmptyOptional(log, e, "createDirectories", dirPath); } }
[ "public", "static", "Optional", "<", "Path", ">", "createDirectories", "(", "Path", "dirPath", ",", "FileAttribute", "<", "?", ">", "...", "attrs", ")", "{", "debug", "(", "log", ",", "\"createDirectories\"", ",", "dirPath", ",", "attrs", ")", ";", "try", "{", "return", "Optional", ".", "of", "(", "Files", ".", "createDirectories", "(", "dirPath", ",", "attrs", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "JMExceptionManager", ".", "handleExceptionAndReturnEmptyOptional", "(", "log", ",", "e", ",", "\"createDirectories\"", ",", "dirPath", ")", ";", "}", "}" ]
Create directories optional. @param dirPath the dir path @param attrs the attrs @return the optional
[ "Create", "directories", "optional", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L327-L336
154,662
JM-Lab/utils-java8
src/main/java/kr/jm/utils/helper/JMPathOperation.java
JMPathOperation.createFileWithParentDirectories
public static void createFileWithParentDirectories(Path path, FileAttribute<?>... attrs) { createDirectories(path.getParent(), attrs); createFile(path, attrs); }
java
public static void createFileWithParentDirectories(Path path, FileAttribute<?>... attrs) { createDirectories(path.getParent(), attrs); createFile(path, attrs); }
[ "public", "static", "void", "createFileWithParentDirectories", "(", "Path", "path", ",", "FileAttribute", "<", "?", ">", "...", "attrs", ")", "{", "createDirectories", "(", "path", ".", "getParent", "(", ")", ",", "attrs", ")", ";", "createFile", "(", "path", ",", "attrs", ")", ";", "}" ]
Create file with parent directories. @param path the path @param attrs the attrs
[ "Create", "file", "with", "parent", "directories", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPathOperation.java#L362-L366
154,663
morimekta/utils
io-util/src/main/java/net/morimekta/util/Base64.java
Base64.encodeToString
public static String encodeToString(final byte[] source, int off, int len) { byte[] encoded = encode(source, off, len); return new String(encoded, US_ASCII); }
java
public static String encodeToString(final byte[] source, int off, int len) { byte[] encoded = encode(source, off, len); return new String(encoded, US_ASCII); }
[ "public", "static", "String", "encodeToString", "(", "final", "byte", "[", "]", "source", ",", "int", "off", ",", "int", "len", ")", "{", "byte", "[", "]", "encoded", "=", "encode", "(", "source", ",", "off", ",", "len", ")", ";", "return", "new", "String", "(", "encoded", ",", "US_ASCII", ")", ";", "}" ]
Encodes a byte array into Base64 string. @param source The data to convert @param off The data offset of what to encode. @param len The number of bytes to encode. @return The Base64-encoded data as a String @throws NullPointerException if source array is null @since 2.0
[ "Encodes", "a", "byte", "array", "into", "Base64", "string", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Base64.java#L190-L193
154,664
morimekta/utils
io-util/src/main/java/net/morimekta/util/Base64.java
Base64.encode
public static byte[] encode(final byte[] source, final int off, final int len) { if (source == null) { throw new NullPointerException("Cannot serialize a null array."); } if (off < 0) { throw new IllegalArgumentException("Cannot have negative offset: " + off); } if (len < 0) { throw new IllegalArgumentException("Cannot have negative length: " + len); } if (off + len > source.length) { throw new IllegalArgumentException(String.format( "Cannot have offset of %d and length of %d with array of length %d", off, len, source.length)); } if (len == 0) { return new byte[0]; } //int len43 = len * 4 / 3; //byte[] outBuff = new byte[ ( len43 ) // Main 4:3 // + ( (len % 3) > 0 ? 4 : 0 ) // Account for padding // + (breakLines ? ( len43 / MAX_LINE_LENGTH ) : 0) ]; // New lines // Try to determine more precisely how big the array needs to be. // If we get it right, we don't have to do an array copy, and // we save a bunch of memory. int blocks = len / 3; int extra = len % 3; int bufLen = blocks * 4 + (extra > 0 ? extra + 1 : 0); // Bytes needed for actual encoding byte[] dest = new byte[bufLen]; int srcPos = 0; int destPos = 0; final int len2 = len - 2; for (; srcPos < len2; srcPos += 3) { destPos += encode3to4(source, srcPos + off, 3, dest, destPos); } if (srcPos < len) { encode3to4(source, srcPos + off, len - srcPos, dest, destPos); } return dest; }
java
public static byte[] encode(final byte[] source, final int off, final int len) { if (source == null) { throw new NullPointerException("Cannot serialize a null array."); } if (off < 0) { throw new IllegalArgumentException("Cannot have negative offset: " + off); } if (len < 0) { throw new IllegalArgumentException("Cannot have negative length: " + len); } if (off + len > source.length) { throw new IllegalArgumentException(String.format( "Cannot have offset of %d and length of %d with array of length %d", off, len, source.length)); } if (len == 0) { return new byte[0]; } //int len43 = len * 4 / 3; //byte[] outBuff = new byte[ ( len43 ) // Main 4:3 // + ( (len % 3) > 0 ? 4 : 0 ) // Account for padding // + (breakLines ? ( len43 / MAX_LINE_LENGTH ) : 0) ]; // New lines // Try to determine more precisely how big the array needs to be. // If we get it right, we don't have to do an array copy, and // we save a bunch of memory. int blocks = len / 3; int extra = len % 3; int bufLen = blocks * 4 + (extra > 0 ? extra + 1 : 0); // Bytes needed for actual encoding byte[] dest = new byte[bufLen]; int srcPos = 0; int destPos = 0; final int len2 = len - 2; for (; srcPos < len2; srcPos += 3) { destPos += encode3to4(source, srcPos + off, 3, dest, destPos); } if (srcPos < len) { encode3to4(source, srcPos + off, len - srcPos, dest, destPos); } return dest; }
[ "public", "static", "byte", "[", "]", "encode", "(", "final", "byte", "[", "]", "source", ",", "final", "int", "off", ",", "final", "int", "len", ")", "{", "if", "(", "source", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Cannot serialize a null array.\"", ")", ";", "}", "if", "(", "off", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot have negative offset: \"", "+", "off", ")", ";", "}", "if", "(", "len", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot have negative length: \"", "+", "len", ")", ";", "}", "if", "(", "off", "+", "len", ">", "source", ".", "length", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"Cannot have offset of %d and length of %d with array of length %d\"", ",", "off", ",", "len", ",", "source", ".", "length", ")", ")", ";", "}", "if", "(", "len", "==", "0", ")", "{", "return", "new", "byte", "[", "0", "]", ";", "}", "//int len43 = len * 4 / 3;", "//byte[] outBuff = new byte[ ( len43 ) // Main 4:3", "// + ( (len % 3) > 0 ? 4 : 0 ) // Account for padding", "// + (breakLines ? ( len43 / MAX_LINE_LENGTH ) : 0) ]; // New lines", "// Try to determine more precisely how big the array needs to be.", "// If we get it right, we don't have to do an array copy, and", "// we save a bunch of memory.", "int", "blocks", "=", "len", "/", "3", ";", "int", "extra", "=", "len", "%", "3", ";", "int", "bufLen", "=", "blocks", "*", "4", "+", "(", "extra", ">", "0", "?", "extra", "+", "1", ":", "0", ")", ";", "// Bytes needed for actual encoding", "byte", "[", "]", "dest", "=", "new", "byte", "[", "bufLen", "]", ";", "int", "srcPos", "=", "0", ";", "int", "destPos", "=", "0", ";", "final", "int", "len2", "=", "len", "-", "2", ";", "for", "(", ";", "srcPos", "<", "len2", ";", "srcPos", "+=", "3", ")", "{", "destPos", "+=", "encode3to4", "(", "source", ",", "srcPos", "+", "off", ",", "3", ",", "dest", ",", "destPos", ")", ";", "}", "if", "(", "srcPos", "<", "len", ")", "{", "encode3to4", "(", "source", ",", "srcPos", "+", "off", ",", "len", "-", "srcPos", ",", "dest", ",", "destPos", ")", ";", "}", "return", "dest", ";", "}" ]
Encodes a byte array into Base64 data. @param source The data to convert @param off The data offset of what to encode. @param len The number of bytes to encode. @return The Base64-encoded data as a String @throws NullPointerException if source array is null @since 2.0
[ "Encodes", "a", "byte", "array", "into", "Base64", "data", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Base64.java#L205-L254
154,665
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/errors/ApplicationExceptionFactory.java
ApplicationExceptionFactory.create
public ApplicationException create(ErrorDescription description) { if (description == null) throw new NullPointerException("Description cannot be null"); ApplicationException error = null; String category = description.getCategory(); String code = description.getCode(); String message = description.getMessage(); String correlationId = description.getCorrelationId(); // Create well-known exception type based on error category if (ErrorCategory.Unknown.equals(category)) error = new UnknownException(correlationId, code, message); else if (ErrorCategory.Internal.equals(category)) error = new InternalException(correlationId, code, message); else if (ErrorCategory.Misconfiguration.equals(category)) error = new ConfigException(correlationId, code, message); else if (ErrorCategory.NoResponse.equals(category)) error = new ConnectionException(correlationId, code, message); else if (ErrorCategory.FailedInvocation.equals(category)) error = new InvocationException(correlationId, code, message); else if (ErrorCategory.FileError.equals(category)) error = new FileException(correlationId, code, message); else if (ErrorCategory.BadRequest.equals(category)) error = new BadRequestException(correlationId, code, message); else if (ErrorCategory.Unauthorized.equals(category)) error = new UnauthorizedException(correlationId, code, message); else if (ErrorCategory.Conflict.equals(category)) error = new ConflictException(correlationId, code, message); else if (ErrorCategory.NotFound.equals(category)) error = new NotFoundException(correlationId, code, message); else if (ErrorCategory.InvalidState.equals(category)) error = new InvalidStateException(correlationId, code, message); else if (ErrorCategory.Unsupported.equals(category)) error = new UnsupportedException(correlationId, code, message); else { error = new UnknownException(); error.setCategory(category); error.setStatus(description.getStatus()); } // Fill error with details error.setDetails(description.getDetails()); error.setCauseString(description.getCause()); error.setStackTraceString(description.getStackTrace()); return error; }
java
public ApplicationException create(ErrorDescription description) { if (description == null) throw new NullPointerException("Description cannot be null"); ApplicationException error = null; String category = description.getCategory(); String code = description.getCode(); String message = description.getMessage(); String correlationId = description.getCorrelationId(); // Create well-known exception type based on error category if (ErrorCategory.Unknown.equals(category)) error = new UnknownException(correlationId, code, message); else if (ErrorCategory.Internal.equals(category)) error = new InternalException(correlationId, code, message); else if (ErrorCategory.Misconfiguration.equals(category)) error = new ConfigException(correlationId, code, message); else if (ErrorCategory.NoResponse.equals(category)) error = new ConnectionException(correlationId, code, message); else if (ErrorCategory.FailedInvocation.equals(category)) error = new InvocationException(correlationId, code, message); else if (ErrorCategory.FileError.equals(category)) error = new FileException(correlationId, code, message); else if (ErrorCategory.BadRequest.equals(category)) error = new BadRequestException(correlationId, code, message); else if (ErrorCategory.Unauthorized.equals(category)) error = new UnauthorizedException(correlationId, code, message); else if (ErrorCategory.Conflict.equals(category)) error = new ConflictException(correlationId, code, message); else if (ErrorCategory.NotFound.equals(category)) error = new NotFoundException(correlationId, code, message); else if (ErrorCategory.InvalidState.equals(category)) error = new InvalidStateException(correlationId, code, message); else if (ErrorCategory.Unsupported.equals(category)) error = new UnsupportedException(correlationId, code, message); else { error = new UnknownException(); error.setCategory(category); error.setStatus(description.getStatus()); } // Fill error with details error.setDetails(description.getDetails()); error.setCauseString(description.getCause()); error.setStackTraceString(description.getStackTrace()); return error; }
[ "public", "ApplicationException", "create", "(", "ErrorDescription", "description", ")", "{", "if", "(", "description", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"Description cannot be null\"", ")", ";", "ApplicationException", "error", "=", "null", ";", "String", "category", "=", "description", ".", "getCategory", "(", ")", ";", "String", "code", "=", "description", ".", "getCode", "(", ")", ";", "String", "message", "=", "description", ".", "getMessage", "(", ")", ";", "String", "correlationId", "=", "description", ".", "getCorrelationId", "(", ")", ";", "// Create well-known exception type based on error category", "if", "(", "ErrorCategory", ".", "Unknown", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "UnknownException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "Internal", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "InternalException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "Misconfiguration", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "ConfigException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "NoResponse", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "ConnectionException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "FailedInvocation", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "InvocationException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "FileError", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "FileException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "BadRequest", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "BadRequestException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "Unauthorized", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "UnauthorizedException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "Conflict", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "ConflictException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "NotFound", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "NotFoundException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "InvalidState", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "InvalidStateException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "if", "(", "ErrorCategory", ".", "Unsupported", ".", "equals", "(", "category", ")", ")", "error", "=", "new", "UnsupportedException", "(", "correlationId", ",", "code", ",", "message", ")", ";", "else", "{", "error", "=", "new", "UnknownException", "(", ")", ";", "error", ".", "setCategory", "(", "category", ")", ";", "error", ".", "setStatus", "(", "description", ".", "getStatus", "(", ")", ")", ";", "}", "// Fill error with details", "error", ".", "setDetails", "(", "description", ".", "getDetails", "(", ")", ")", ";", "error", ".", "setCauseString", "(", "description", ".", "getCause", "(", ")", ")", ";", "error", ".", "setStackTraceString", "(", "description", ".", "getStackTrace", "(", ")", ")", ";", "return", "error", ";", "}" ]
Recreates ApplicationException object from serialized ErrorDescription. It tries to restore original exception type using type or error category fields. @param description a serialized error description received as a result of remote call @return new ApplicationException object from serialized ErrorDescription.
[ "Recreates", "ApplicationException", "object", "from", "serialized", "ErrorDescription", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/errors/ApplicationExceptionFactory.java#L19-L66
154,666
javajazz/jazz
src/main/lombok/de/scravy/jazz/Jazz.java
Jazz.display
public static Window display(final String title, final int width, final int height, final Picture picture) { return play(title, width, height, new Animation() { @Override public Picture getPicture() { return picture; } @Override public void update(final double time, final double delta) { // do nothing, the picture is static. } }); }
java
public static Window display(final String title, final int width, final int height, final Picture picture) { return play(title, width, height, new Animation() { @Override public Picture getPicture() { return picture; } @Override public void update(final double time, final double delta) { // do nothing, the picture is static. } }); }
[ "public", "static", "Window", "display", "(", "final", "String", "title", ",", "final", "int", "width", ",", "final", "int", "height", ",", "final", "Picture", "picture", ")", "{", "return", "play", "(", "title", ",", "width", ",", "height", ",", "new", "Animation", "(", ")", "{", "@", "Override", "public", "Picture", "getPicture", "(", ")", "{", "return", "picture", ";", "}", "@", "Override", "public", "void", "update", "(", "final", "double", "time", ",", "final", "double", "delta", ")", "{", "// do nothing, the picture is static.", "}", "}", ")", ";", "}" ]
Displays a static picture in a single window. You can open multiple windows using this method. This method used an {@link Animation} and allows for zooming and panning. @since 1.0.0 @param title The title of the displayed window. @param width The width of the displayed window. @param height The height of the displayed window. @param picture The picture to be drawn in the displayed window. @return A reference to the newly created window.
[ "Displays", "a", "static", "picture", "in", "a", "single", "window", "." ]
f4a1a601700442b8ec6a947f5772a96dbf5dc44b
https://github.com/javajazz/jazz/blob/f4a1a601700442b8ec6a947f5772a96dbf5dc44b/src/main/lombok/de/scravy/jazz/Jazz.java#L204-L220
154,667
javajazz/jazz
src/main/lombok/de/scravy/jazz/Jazz.java
Jazz.animate
public static <M> Window animate(final String title, final int width, final int height, final M model, final Renderer<M> renderer, final UpdateHandler<M> updateHandler) { return animate(title, width, height, new Animation() { @Override public void update(final double time, final double delta) { updateHandler.update(model, time, delta); } @Override public Picture getPicture() { return renderer.render(model); } }); }
java
public static <M> Window animate(final String title, final int width, final int height, final M model, final Renderer<M> renderer, final UpdateHandler<M> updateHandler) { return animate(title, width, height, new Animation() { @Override public void update(final double time, final double delta) { updateHandler.update(model, time, delta); } @Override public Picture getPicture() { return renderer.render(model); } }); }
[ "public", "static", "<", "M", ">", "Window", "animate", "(", "final", "String", "title", ",", "final", "int", "width", ",", "final", "int", "height", ",", "final", "M", "model", ",", "final", "Renderer", "<", "M", ">", "renderer", ",", "final", "UpdateHandler", "<", "M", ">", "updateHandler", ")", "{", "return", "animate", "(", "title", ",", "width", ",", "height", ",", "new", "Animation", "(", ")", "{", "@", "Override", "public", "void", "update", "(", "final", "double", "time", ",", "final", "double", "delta", ")", "{", "updateHandler", ".", "update", "(", "model", ",", "time", ",", "delta", ")", ";", "}", "@", "Override", "public", "Picture", "getPicture", "(", ")", "{", "return", "renderer", ".", "render", "(", "model", ")", ";", "}", "}", ")", ";", "}" ]
Displays an animation in a single window. You can open multiple windows using this method. @see Renderer @since 1.0.0 @param title The title of the displayed window. @param width The width of the displayed window. @param height The height of the displayed window. @param model The model (a data object that describes your world). @param renderer The renderer that derives a picture from the model. @param updateHandler The update handler that updates the model. @return A reference to the newly created window.
[ "Displays", "an", "animation", "in", "a", "single", "window", "." ]
f4a1a601700442b8ec6a947f5772a96dbf5dc44b
https://github.com/javajazz/jazz/blob/f4a1a601700442b8ec6a947f5772a96dbf5dc44b/src/main/lombok/de/scravy/jazz/Jazz.java#L280-L296
154,668
JM-Lab/utils-java8
src/main/java/kr/jm/utils/CollectionPrinter.java
CollectionPrinter.listToJSONString
static public String listToJSONString(List<?> list) { if (list == null || list.size() == 0) { return "[]"; } StringBuilder sb = new StringBuilder("["); for (Object o : list) { buildAppendString(sb, o).append(',').append(' '); } return sb.delete(sb.length() - 2, sb.length()).append(']').toString(); }
java
static public String listToJSONString(List<?> list) { if (list == null || list.size() == 0) { return "[]"; } StringBuilder sb = new StringBuilder("["); for (Object o : list) { buildAppendString(sb, o).append(',').append(' '); } return sb.delete(sb.length() - 2, sb.length()).append(']').toString(); }
[ "static", "public", "String", "listToJSONString", "(", "List", "<", "?", ">", "list", ")", "{", "if", "(", "list", "==", "null", "||", "list", ".", "size", "(", ")", "==", "0", ")", "{", "return", "\"[]\"", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"[\"", ")", ";", "for", "(", "Object", "o", ":", "list", ")", "{", "buildAppendString", "(", "sb", ",", "o", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "'", "'", ")", ";", "}", "return", "sb", ".", "delete", "(", "sb", ".", "length", "(", ")", "-", "2", ",", "sb", ".", "length", "(", ")", ")", ".", "append", "(", "'", "'", ")", ".", "toString", "(", ")", ";", "}" ]
List to json string string. @param list the list @return the string
[ "List", "to", "json", "string", "string", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/CollectionPrinter.java#L19-L28
154,669
JM-Lab/utils-java8
src/main/java/kr/jm/utils/CollectionPrinter.java
CollectionPrinter.mapToJSONString
public static String mapToJSONString(Map<?, ?> map) { if (map == null || map.size() == 0) { return "{}"; } StringBuilder sb = new StringBuilder("{"); for (Object o : map.entrySet()) { Entry<?, ?> e = (Entry<?, ?>) o; buildAppendString(sb, e.getKey()).append('='); buildAppendString(sb, e.getValue()).append(',').append(' '); } return sb.delete(sb.length() - 2, sb.length()).append('}').toString(); }
java
public static String mapToJSONString(Map<?, ?> map) { if (map == null || map.size() == 0) { return "{}"; } StringBuilder sb = new StringBuilder("{"); for (Object o : map.entrySet()) { Entry<?, ?> e = (Entry<?, ?>) o; buildAppendString(sb, e.getKey()).append('='); buildAppendString(sb, e.getValue()).append(',').append(' '); } return sb.delete(sb.length() - 2, sb.length()).append('}').toString(); }
[ "public", "static", "String", "mapToJSONString", "(", "Map", "<", "?", ",", "?", ">", "map", ")", "{", "if", "(", "map", "==", "null", "||", "map", ".", "size", "(", ")", "==", "0", ")", "{", "return", "\"{}\"", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"{\"", ")", ";", "for", "(", "Object", "o", ":", "map", ".", "entrySet", "(", ")", ")", "{", "Entry", "<", "?", ",", "?", ">", "e", "=", "(", "Entry", "<", "?", ",", "?", ">", ")", "o", ";", "buildAppendString", "(", "sb", ",", "e", ".", "getKey", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "buildAppendString", "(", "sb", ",", "e", ".", "getValue", "(", ")", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "'", "'", ")", ";", "}", "return", "sb", ".", "delete", "(", "sb", ".", "length", "(", ")", "-", "2", ",", "sb", ".", "length", "(", ")", ")", ".", "append", "(", "'", "'", ")", ".", "toString", "(", ")", ";", "}" ]
Map to json string string. @param map the map @return the string
[ "Map", "to", "json", "string", "string", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/CollectionPrinter.java#L52-L63
154,670
konvergeio/cofoja
src/main/java/com/google/java/contract/ContractAssertionError.java
ContractAssertionError.cleanStackTrace
private void cleanStackTrace() { StackTraceElement[] realTrace = getStackTrace(); StackTraceElement[] trace = new StackTraceElement[realTrace.length - 1]; StackTraceElement top = realTrace[0]; trace[0] = new StackTraceElement(top.getClassName(), getMethodName(realTrace[2].getMethodName()), top.getFileName(), top.getLineNumber()); System.arraycopy(realTrace, 2, trace, 1, realTrace.length - 2); setStackTrace(trace); }
java
private void cleanStackTrace() { StackTraceElement[] realTrace = getStackTrace(); StackTraceElement[] trace = new StackTraceElement[realTrace.length - 1]; StackTraceElement top = realTrace[0]; trace[0] = new StackTraceElement(top.getClassName(), getMethodName(realTrace[2].getMethodName()), top.getFileName(), top.getLineNumber()); System.arraycopy(realTrace, 2, trace, 1, realTrace.length - 2); setStackTrace(trace); }
[ "private", "void", "cleanStackTrace", "(", ")", "{", "StackTraceElement", "[", "]", "realTrace", "=", "getStackTrace", "(", ")", ";", "StackTraceElement", "[", "]", "trace", "=", "new", "StackTraceElement", "[", "realTrace", ".", "length", "-", "1", "]", ";", "StackTraceElement", "top", "=", "realTrace", "[", "0", "]", ";", "trace", "[", "0", "]", "=", "new", "StackTraceElement", "(", "top", ".", "getClassName", "(", ")", ",", "getMethodName", "(", "realTrace", "[", "2", "]", ".", "getMethodName", "(", ")", ")", ",", "top", ".", "getFileName", "(", ")", ",", "top", ".", "getLineNumber", "(", ")", ")", ";", "System", ".", "arraycopy", "(", "realTrace", ",", "2", ",", "trace", ",", "1", ",", "realTrace", ".", "length", "-", "2", ")", ";", "setStackTrace", "(", "trace", ")", ";", "}" ]
Remove wrapper call, leaving only the contract helper.
[ "Remove", "wrapper", "call", "leaving", "only", "the", "contract", "helper", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/ContractAssertionError.java#L85-L94
154,671
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/refer/Reference.java
Reference.match
public boolean match(Object locator) { // Locate by direct reference matching if (_reference.equals(locator)) return true; // Locate by type else if (locator instanceof Class<?>) return ((Class<?>) locator).isInstance(_reference); // Locate by direct locator matching else if (_locator != null) return _locator.equals(locator); else return false; }
java
public boolean match(Object locator) { // Locate by direct reference matching if (_reference.equals(locator)) return true; // Locate by type else if (locator instanceof Class<?>) return ((Class<?>) locator).isInstance(_reference); // Locate by direct locator matching else if (_locator != null) return _locator.equals(locator); else return false; }
[ "public", "boolean", "match", "(", "Object", "locator", ")", "{", "// Locate by direct reference matching", "if", "(", "_reference", ".", "equals", "(", "locator", ")", ")", "return", "true", ";", "// Locate by type", "else", "if", "(", "locator", "instanceof", "Class", "<", "?", ">", ")", "return", "(", "(", "Class", "<", "?", ">", ")", "locator", ")", ".", "isInstance", "(", "_reference", ")", ";", "// Locate by direct locator matching", "else", "if", "(", "_locator", "!=", "null", ")", "return", "_locator", ".", "equals", "(", "locator", ")", ";", "else", "return", "false", ";", "}" ]
Matches locator to this reference locator. Descriptors are matched using equal method. All other locator types are matched using direct comparison. @param locator the locator to match. @return true if locators are matching and false it they don't. @see Descriptor
[ "Matches", "locator", "to", "this", "reference", "locator", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/Reference.java#L38-L50
154,672
morimekta/utils
console-util/src/main/java/net/morimekta/console/util/STTY.java
STTY.setSTTYMode
public STTYModeSwitcher setSTTYMode(STTYMode mode) { try { return new STTYModeSwitcher(mode, runtime); } catch (IOException e) { throw new UncheckedIOException(e); } }
java
public STTYModeSwitcher setSTTYMode(STTYMode mode) { try { return new STTYModeSwitcher(mode, runtime); } catch (IOException e) { throw new UncheckedIOException(e); } }
[ "public", "STTYModeSwitcher", "setSTTYMode", "(", "STTYMode", "mode", ")", "{", "try", "{", "return", "new", "STTYModeSwitcher", "(", "mode", ",", "runtime", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "UncheckedIOException", "(", "e", ")", ";", "}", "}" ]
Set the current STTY mode, and return the closable switcher to turn back. @param mode The STTY mode to set. @return The mode switcher.
[ "Set", "the", "current", "STTY", "mode", "and", "return", "the", "closable", "switcher", "to", "turn", "back", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/util/STTY.java#L76-L82
154,673
lotaris/jee-validation
src/main/java/com/lotaris/jee/validation/preprocessing/BeanValidationPreprocessor.java
BeanValidationPreprocessor.addError
private void addError(IValidationContext context, ConstraintViolation violation, JsonPointer pointer) { // extract the error code, if any final Class<? extends Annotation> annotationType = violation.getConstraintDescriptor().getAnnotation().annotationType(); final IErrorCode validationCode = constraintConverter.getErrorCode(annotationType); final IErrorLocationType validationType = constraintConverter.getErrorLocationType(annotationType); // add the error to the validation context context.addError(pointer.toString(), validationType, validationCode, violation.getMessage()); }
java
private void addError(IValidationContext context, ConstraintViolation violation, JsonPointer pointer) { // extract the error code, if any final Class<? extends Annotation> annotationType = violation.getConstraintDescriptor().getAnnotation().annotationType(); final IErrorCode validationCode = constraintConverter.getErrorCode(annotationType); final IErrorLocationType validationType = constraintConverter.getErrorLocationType(annotationType); // add the error to the validation context context.addError(pointer.toString(), validationType, validationCode, violation.getMessage()); }
[ "private", "void", "addError", "(", "IValidationContext", "context", ",", "ConstraintViolation", "violation", ",", "JsonPointer", "pointer", ")", "{", "// extract the error code, if any", "final", "Class", "<", "?", "extends", "Annotation", ">", "annotationType", "=", "violation", ".", "getConstraintDescriptor", "(", ")", ".", "getAnnotation", "(", ")", ".", "annotationType", "(", ")", ";", "final", "IErrorCode", "validationCode", "=", "constraintConverter", ".", "getErrorCode", "(", "annotationType", ")", ";", "final", "IErrorLocationType", "validationType", "=", "constraintConverter", ".", "getErrorLocationType", "(", "annotationType", ")", ";", "// add the error to the validation context", "context", ".", "addError", "(", "pointer", ".", "toString", "(", ")", ",", "validationType", ",", "validationCode", ",", "violation", ".", "getMessage", "(", ")", ")", ";", "}" ]
Adds an error message describing a constraint violation. @param context the validation context to add errors to @param violation the constraint violation @param pointer a JSON pointer to the invalid value in the JSON document @return an API error message
[ "Adds", "an", "error", "message", "describing", "a", "constraint", "violation", "." ]
feefff820b5a67c7471a13e08fdaf2d60bb3ad16
https://github.com/lotaris/jee-validation/blob/feefff820b5a67c7471a13e08fdaf2d60bb3ad16/src/main/java/com/lotaris/jee/validation/preprocessing/BeanValidationPreprocessor.java#L162-L171
154,674
grails/grails-gdoc-engine
src/main/java/org/radeox/macro/MacroRepository.java
MacroRepository.load
private void load() { Iterator iterator = loaders.iterator(); while (iterator.hasNext()) { MacroLoader loader = (MacroLoader) iterator.next(); loader.setRepository(this); log.debug("Loading from: " + loader.getClass()); loader.loadPlugins(this); } }
java
private void load() { Iterator iterator = loaders.iterator(); while (iterator.hasNext()) { MacroLoader loader = (MacroLoader) iterator.next(); loader.setRepository(this); log.debug("Loading from: " + loader.getClass()); loader.loadPlugins(this); } }
[ "private", "void", "load", "(", ")", "{", "Iterator", "iterator", "=", "loaders", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "MacroLoader", "loader", "=", "(", "MacroLoader", ")", "iterator", ".", "next", "(", ")", ";", "loader", ".", "setRepository", "(", "this", ")", ";", "log", ".", "debug", "(", "\"Loading from: \"", "+", "loader", ".", "getClass", "(", ")", ")", ";", "loader", ".", "loadPlugins", "(", "this", ")", ";", "}", "}" ]
Loads macros from all loaders into plugins.
[ "Loads", "macros", "from", "all", "loaders", "into", "plugins", "." ]
e52aa09eaa61510dc48b27603bd9ea116cd6531a
https://github.com/grails/grails-gdoc-engine/blob/e52aa09eaa61510dc48b27603bd9ea116cd6531a/src/main/java/org/radeox/macro/MacroRepository.java#L75-L83
154,675
BellaDati/belladati-sdk-java
src/main/java/com/belladati/sdk/view/impl/ViewImpl.java
ViewImpl.parseType
private static ViewType parseType(JsonNode node) throws UnknownViewTypeException { if (node.hasNonNull("type")) { try { return ViewType.valueOf(node.get("type").asText().toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new UnknownViewTypeException(node.get("type").asText()); } } else { throw new UnknownViewTypeException("missing type"); } }
java
private static ViewType parseType(JsonNode node) throws UnknownViewTypeException { if (node.hasNonNull("type")) { try { return ViewType.valueOf(node.get("type").asText().toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new UnknownViewTypeException(node.get("type").asText()); } } else { throw new UnknownViewTypeException("missing type"); } }
[ "private", "static", "ViewType", "parseType", "(", "JsonNode", "node", ")", "throws", "UnknownViewTypeException", "{", "if", "(", "node", ".", "hasNonNull", "(", "\"type\"", ")", ")", "{", "try", "{", "return", "ViewType", ".", "valueOf", "(", "node", ".", "get", "(", "\"type\"", ")", ".", "asText", "(", ")", ".", "toUpperCase", "(", "Locale", ".", "ENGLISH", ")", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "UnknownViewTypeException", "(", "node", ".", "get", "(", "\"type\"", ")", ".", "asText", "(", ")", ")", ";", "}", "}", "else", "{", "throw", "new", "UnknownViewTypeException", "(", "\"missing type\"", ")", ";", "}", "}" ]
Parses the view type from the given JSON node. @param node the node to examine @return the view type from the node @throws UnknownViewTypeException if no view type was found or it couldn't be parsed
[ "Parses", "the", "view", "type", "from", "the", "given", "JSON", "node", "." ]
1a732a57ebc825ddf47ce405723cc958adb1a43f
https://github.com/BellaDati/belladati-sdk-java/blob/1a732a57ebc825ddf47ce405723cc958adb1a43f/src/main/java/com/belladati/sdk/view/impl/ViewImpl.java#L63-L73
154,676
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/io/DataLoader.java
DataLoader.stream
public Stream<T> stream() { if (thread == null) { synchronized (this) { if (thread == null) { thread = new Thread(() -> read(queue)); thread.setDaemon(true); thread.start(); } } } @Nullable final Iterator<T> iterator = new AsyncListIterator<>(queue, thread); return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT), false).filter(x -> x != null); }
java
public Stream<T> stream() { if (thread == null) { synchronized (this) { if (thread == null) { thread = new Thread(() -> read(queue)); thread.setDaemon(true); thread.start(); } } } @Nullable final Iterator<T> iterator = new AsyncListIterator<>(queue, thread); return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT), false).filter(x -> x != null); }
[ "public", "Stream", "<", "T", ">", "stream", "(", ")", "{", "if", "(", "thread", "==", "null", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "thread", "==", "null", ")", "{", "thread", "=", "new", "Thread", "(", "(", ")", "->", "read", "(", "queue", ")", ")", ";", "thread", ".", "setDaemon", "(", "true", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "}", "}", "@", "Nullable", "final", "Iterator", "<", "T", ">", "iterator", "=", "new", "AsyncListIterator", "<>", "(", "queue", ",", "thread", ")", ";", "return", "StreamSupport", ".", "stream", "(", "Spliterators", ".", "spliteratorUnknownSize", "(", "iterator", ",", "Spliterator", ".", "DISTINCT", ")", ",", "false", ")", ".", "filter", "(", "x", "->", "x", "!=", "null", ")", ";", "}" ]
Stream stream. @return the stream
[ "Stream", "stream", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/io/DataLoader.java#L82-L94
154,677
james-hu/jabb-core
src/main/java/net/sf/jabb/util/stat/AtomicBigInteger.java
AtomicBigInteger.getAndSet
public BigInteger getAndSet(BigInteger newValue) { while (true) { BigInteger current = get(); if (valueHolder.compareAndSet(current, newValue)) return current; } }
java
public BigInteger getAndSet(BigInteger newValue) { while (true) { BigInteger current = get(); if (valueHolder.compareAndSet(current, newValue)) return current; } }
[ "public", "BigInteger", "getAndSet", "(", "BigInteger", "newValue", ")", "{", "while", "(", "true", ")", "{", "BigInteger", "current", "=", "get", "(", ")", ";", "if", "(", "valueHolder", ".", "compareAndSet", "(", "current", ",", "newValue", ")", ")", "return", "current", ";", "}", "}" ]
Atomically sets to the given value and returns the old value. @param newValue the new value @return the previous value
[ "Atomically", "sets", "to", "the", "given", "value", "and", "returns", "the", "old", "value", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/stat/AtomicBigInteger.java#L95-L101
154,678
james-hu/jabb-core
src/main/java/net/sf/jabb/util/stat/BasicFrequencyCounter.java
BasicFrequencyCounter.getTotalCounts
public BigInteger getTotalCounts(){ BigInteger result = BigInteger.ZERO; for (AtomicLong c: counters.getMap().values()){ result = result.add(BigInteger.valueOf(c.get())); } return result; }
java
public BigInteger getTotalCounts(){ BigInteger result = BigInteger.ZERO; for (AtomicLong c: counters.getMap().values()){ result = result.add(BigInteger.valueOf(c.get())); } return result; }
[ "public", "BigInteger", "getTotalCounts", "(", ")", "{", "BigInteger", "result", "=", "BigInteger", ".", "ZERO", ";", "for", "(", "AtomicLong", "c", ":", "counters", ".", "getMap", "(", ")", ".", "values", "(", ")", ")", "{", "result", "=", "result", ".", "add", "(", "BigInteger", ".", "valueOf", "(", "c", ".", "get", "(", ")", ")", ")", ";", "}", "return", "result", ";", "}" ]
Get the summary value of all the counts @return the summary value of all the counts
[ "Get", "the", "summary", "value", "of", "all", "the", "counts" ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/stat/BasicFrequencyCounter.java#L122-L128
154,679
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/IntegerConverter.java
IntegerConverter.toNullableInteger
public static Integer toNullableInteger(Object value) { Long result = LongConverter.toNullableLong(value); return result != null ? (int) ((long) result) : null; }
java
public static Integer toNullableInteger(Object value) { Long result = LongConverter.toNullableLong(value); return result != null ? (int) ((long) result) : null; }
[ "public", "static", "Integer", "toNullableInteger", "(", "Object", "value", ")", "{", "Long", "result", "=", "LongConverter", ".", "toNullableLong", "(", "value", ")", ";", "return", "result", "!=", "null", "?", "(", "int", ")", "(", "(", "long", ")", "result", ")", ":", "null", ";", "}" ]
Converts value into integer or returns null when conversion is not possible. @param value the value to convert. @return integer value or null when conversion is not supported. @see LongConverter#toNullableLong(Object)
[ "Converts", "value", "into", "integer", "or", "returns", "null", "when", "conversion", "is", "not", "possible", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/IntegerConverter.java#L32-L35
154,680
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/IntegerConverter.java
IntegerConverter.toIntegerWithDefault
public static int toIntegerWithDefault(Object value, int defaultValue) { Integer result = toNullableInteger(value); return result != null ? (int) result : defaultValue; }
java
public static int toIntegerWithDefault(Object value, int defaultValue) { Integer result = toNullableInteger(value); return result != null ? (int) result : defaultValue; }
[ "public", "static", "int", "toIntegerWithDefault", "(", "Object", "value", ",", "int", "defaultValue", ")", "{", "Integer", "result", "=", "toNullableInteger", "(", "value", ")", ";", "return", "result", "!=", "null", "?", "(", "int", ")", "result", ":", "defaultValue", ";", "}" ]
Converts value into integer or returns default value when conversion is not possible. @param value the value to convert. @param defaultValue the default value. @return integer value or default when conversion is not supported. @see IntegerConverter#toNullableInteger(Object)
[ "Converts", "value", "into", "integer", "or", "returns", "default", "value", "when", "conversion", "is", "not", "possible", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/IntegerConverter.java#L59-L62
154,681
james-hu/jabb-core
src/main/java/net/sf/jabb/stdr/jsp/SetTag.java
SetTag.findSpringBean
private Object findSpringBean(String beanName) { ServletContext servletContext = this.pageContext.getServletContext(); Enumeration<String> attrNames = servletContext.getAttributeNames(); while (attrNames.hasMoreElements()){ String attrName = attrNames.nextElement(); if (attrName.startsWith("org.springframework")){ try{ WebApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(servletContext, attrName); Object bean = springContext.getBean(beanName); return bean; }catch(Exception e){ // continue if the bean cannot be found. } } } return null; }
java
private Object findSpringBean(String beanName) { ServletContext servletContext = this.pageContext.getServletContext(); Enumeration<String> attrNames = servletContext.getAttributeNames(); while (attrNames.hasMoreElements()){ String attrName = attrNames.nextElement(); if (attrName.startsWith("org.springframework")){ try{ WebApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(servletContext, attrName); Object bean = springContext.getBean(beanName); return bean; }catch(Exception e){ // continue if the bean cannot be found. } } } return null; }
[ "private", "Object", "findSpringBean", "(", "String", "beanName", ")", "{", "ServletContext", "servletContext", "=", "this", ".", "pageContext", ".", "getServletContext", "(", ")", ";", "Enumeration", "<", "String", ">", "attrNames", "=", "servletContext", ".", "getAttributeNames", "(", ")", ";", "while", "(", "attrNames", ".", "hasMoreElements", "(", ")", ")", "{", "String", "attrName", "=", "attrNames", ".", "nextElement", "(", ")", ";", "if", "(", "attrName", ".", "startsWith", "(", "\"org.springframework\"", ")", ")", "{", "try", "{", "WebApplicationContext", "springContext", "=", "WebApplicationContextUtils", ".", "getWebApplicationContext", "(", "servletContext", ",", "attrName", ")", ";", "Object", "bean", "=", "springContext", ".", "getBean", "(", "beanName", ")", ";", "return", "bean", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// continue if the bean cannot be found.\r", "}", "}", "}", "return", "null", ";", "}" ]
Find the Spring bean from WebApplicationContext in servlet context. @param beanName @return the bean or null
[ "Find", "the", "Spring", "bean", "from", "WebApplicationContext", "in", "servlet", "context", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/stdr/jsp/SetTag.java#L73-L90
154,682
bushidowallet/bushido-java-service
bushido-service-lib/src/main/java/com/bccapi/bitlib/crypto/ec/EcTools.java
EcTools.integerToBytes
public static byte[] integerToBytes(BigInteger s, int length) { byte[] bytes = s.toByteArray(); if (length < bytes.length) { // The length is smaller than the byte representation. Truncate by // copying over the least significant bytes byte[] tmp = new byte[length]; System.arraycopy(bytes, bytes.length - tmp.length, tmp, 0, tmp.length); return tmp; } else if (length > bytes.length) { // The length is larger than the byte representation. Copy over all // bytes and leave it prefixed by zeros. byte[] tmp = new byte[length]; System.arraycopy(bytes, 0, tmp, tmp.length - bytes.length, bytes.length); return tmp; } return bytes; }
java
public static byte[] integerToBytes(BigInteger s, int length) { byte[] bytes = s.toByteArray(); if (length < bytes.length) { // The length is smaller than the byte representation. Truncate by // copying over the least significant bytes byte[] tmp = new byte[length]; System.arraycopy(bytes, bytes.length - tmp.length, tmp, 0, tmp.length); return tmp; } else if (length > bytes.length) { // The length is larger than the byte representation. Copy over all // bytes and leave it prefixed by zeros. byte[] tmp = new byte[length]; System.arraycopy(bytes, 0, tmp, tmp.length - bytes.length, bytes.length); return tmp; } return bytes; }
[ "public", "static", "byte", "[", "]", "integerToBytes", "(", "BigInteger", "s", ",", "int", "length", ")", "{", "byte", "[", "]", "bytes", "=", "s", ".", "toByteArray", "(", ")", ";", "if", "(", "length", "<", "bytes", ".", "length", ")", "{", "// The length is smaller than the byte representation. Truncate by", "// copying over the least significant bytes", "byte", "[", "]", "tmp", "=", "new", "byte", "[", "length", "]", ";", "System", ".", "arraycopy", "(", "bytes", ",", "bytes", ".", "length", "-", "tmp", ".", "length", ",", "tmp", ",", "0", ",", "tmp", ".", "length", ")", ";", "return", "tmp", ";", "}", "else", "if", "(", "length", ">", "bytes", ".", "length", ")", "{", "// The length is larger than the byte representation. Copy over all", "// bytes and leave it prefixed by zeros.", "byte", "[", "]", "tmp", "=", "new", "byte", "[", "length", "]", ";", "System", ".", "arraycopy", "(", "bytes", ",", "0", ",", "tmp", ",", "tmp", ".", "length", "-", "bytes", ".", "length", ",", "bytes", ".", "length", ")", ";", "return", "tmp", ";", "}", "return", "bytes", ";", "}" ]
Get a big integer as an array of bytes of a specified length @param s big number @param length output byte[] length @return output big int as byte[]
[ "Get", "a", "big", "integer", "as", "an", "array", "of", "bytes", "of", "a", "specified", "length" ]
e1a0157527e57459b509718044d2df44084876a2
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/crypto/ec/EcTools.java#L31-L47
154,683
bushidowallet/bushido-java-service
bushido-service-lib/src/main/java/com/bccapi/bitlib/crypto/ec/EcTools.java
EcTools.multiply
public static Point multiply(Point p, BigInteger k) { BigInteger e = k; BigInteger h = e.multiply(BigInteger.valueOf(3)); Point neg = p.negate(); Point R = p; for (int i = h.bitLength() - 2; i > 0; --i) { R = R.twice(); boolean hBit = h.testBit(i); boolean eBit = e.testBit(i); if (hBit != eBit) { R = R.add(hBit ? p : neg); } } return R; }
java
public static Point multiply(Point p, BigInteger k) { BigInteger e = k; BigInteger h = e.multiply(BigInteger.valueOf(3)); Point neg = p.negate(); Point R = p; for (int i = h.bitLength() - 2; i > 0; --i) { R = R.twice(); boolean hBit = h.testBit(i); boolean eBit = e.testBit(i); if (hBit != eBit) { R = R.add(hBit ? p : neg); } } return R; }
[ "public", "static", "Point", "multiply", "(", "Point", "p", ",", "BigInteger", "k", ")", "{", "BigInteger", "e", "=", "k", ";", "BigInteger", "h", "=", "e", ".", "multiply", "(", "BigInteger", ".", "valueOf", "(", "3", ")", ")", ";", "Point", "neg", "=", "p", ".", "negate", "(", ")", ";", "Point", "R", "=", "p", ";", "for", "(", "int", "i", "=", "h", ".", "bitLength", "(", ")", "-", "2", ";", "i", ">", "0", ";", "--", "i", ")", "{", "R", "=", "R", ".", "twice", "(", ")", ";", "boolean", "hBit", "=", "h", ".", "testBit", "(", "i", ")", ";", "boolean", "eBit", "=", "e", ".", "testBit", "(", "i", ")", ";", "if", "(", "hBit", "!=", "eBit", ")", "{", "R", "=", "R", ".", "add", "(", "hBit", "?", "p", ":", "neg", ")", ";", "}", "}", "return", "R", ";", "}" ]
Multiply a point with a big integer @param p point on curve @param k multiplier @return point multiplied by k
[ "Multiply", "a", "point", "with", "a", "big", "integer" ]
e1a0157527e57459b509718044d2df44084876a2
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/crypto/ec/EcTools.java#L56-L75
154,684
foundation-runtime/service-directory
1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/entity/ServiceInstanceHeartbeat.java
ServiceInstanceHeartbeat.getProviderAddress
public String getProviderAddress() { if (providerAddress!=null) { Matcher matcher = HOST_PORT_PATTERN.matcher(providerAddress); if (matcher.matches() && isValidPort(matcher.group(2))) { return matcher.group(1); } }else if(providerId!=null){ Matcher matcher = HOST_PORT_PATTERN.matcher(providerId); if (matcher.matches() && isValidPort(matcher.group(2))) { return matcher.group(1); } } return providerAddress; }
java
public String getProviderAddress() { if (providerAddress!=null) { Matcher matcher = HOST_PORT_PATTERN.matcher(providerAddress); if (matcher.matches() && isValidPort(matcher.group(2))) { return matcher.group(1); } }else if(providerId!=null){ Matcher matcher = HOST_PORT_PATTERN.matcher(providerId); if (matcher.matches() && isValidPort(matcher.group(2))) { return matcher.group(1); } } return providerAddress; }
[ "public", "String", "getProviderAddress", "(", ")", "{", "if", "(", "providerAddress", "!=", "null", ")", "{", "Matcher", "matcher", "=", "HOST_PORT_PATTERN", ".", "matcher", "(", "providerAddress", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", "&&", "isValidPort", "(", "matcher", ".", "group", "(", "2", ")", ")", ")", "{", "return", "matcher", ".", "group", "(", "1", ")", ";", "}", "}", "else", "if", "(", "providerId", "!=", "null", ")", "{", "Matcher", "matcher", "=", "HOST_PORT_PATTERN", ".", "matcher", "(", "providerId", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", "&&", "isValidPort", "(", "matcher", ".", "group", "(", "2", ")", ")", ")", "{", "return", "matcher", ".", "group", "(", "1", ")", ";", "}", "}", "return", "providerAddress", ";", "}" ]
Get the providerAddress. @return the providerAddress.
[ "Get", "the", "providerAddress", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/entity/ServiceInstanceHeartbeat.java#L90-L103
154,685
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/TypeConverter.java
TypeConverter.toTypeCode
public static TypeCode toTypeCode(Class<?> type) { if (type == null) return TypeCode.Unknown; else if (type.isArray()) return TypeCode.Array; else if (type.isEnum()) return TypeCode.Enum; else if (type.isPrimitive()) { if (_booleanType.isAssignableFrom(type)) return TypeCode.Boolean; if (_doubleType.isAssignableFrom(type)) return TypeCode.Double; if (_floatType.isAssignableFrom(type)) return TypeCode.Float; if (_longType.isAssignableFrom(type)) return TypeCode.Long; if (_integerType.isAssignableFrom(type)) return TypeCode.Integer; } else { if (_booleanType.isAssignableFrom(type)) return TypeCode.Boolean; if (_doubleType.isAssignableFrom(type)) return TypeCode.Double; if (_floatType.isAssignableFrom(type)) return TypeCode.Float; if (_longType.isAssignableFrom(type)) return TypeCode.Long; if (_integerType.isAssignableFrom(type)) return TypeCode.Integer; if (_stringType.isAssignableFrom(type)) return TypeCode.String; if (_dateTimeType.isAssignableFrom(type)) return TypeCode.DateTime; if (_durationType.isAssignableFrom(type)) return TypeCode.Duration; if (_mapType.isAssignableFrom(type)) return TypeCode.Map; if (_listType.isAssignableFrom(type)) return TypeCode.Array; if (_enumType.isAssignableFrom(type)) return TypeCode.Enum; } return TypeCode.Object; }
java
public static TypeCode toTypeCode(Class<?> type) { if (type == null) return TypeCode.Unknown; else if (type.isArray()) return TypeCode.Array; else if (type.isEnum()) return TypeCode.Enum; else if (type.isPrimitive()) { if (_booleanType.isAssignableFrom(type)) return TypeCode.Boolean; if (_doubleType.isAssignableFrom(type)) return TypeCode.Double; if (_floatType.isAssignableFrom(type)) return TypeCode.Float; if (_longType.isAssignableFrom(type)) return TypeCode.Long; if (_integerType.isAssignableFrom(type)) return TypeCode.Integer; } else { if (_booleanType.isAssignableFrom(type)) return TypeCode.Boolean; if (_doubleType.isAssignableFrom(type)) return TypeCode.Double; if (_floatType.isAssignableFrom(type)) return TypeCode.Float; if (_longType.isAssignableFrom(type)) return TypeCode.Long; if (_integerType.isAssignableFrom(type)) return TypeCode.Integer; if (_stringType.isAssignableFrom(type)) return TypeCode.String; if (_dateTimeType.isAssignableFrom(type)) return TypeCode.DateTime; if (_durationType.isAssignableFrom(type)) return TypeCode.Duration; if (_mapType.isAssignableFrom(type)) return TypeCode.Map; if (_listType.isAssignableFrom(type)) return TypeCode.Array; if (_enumType.isAssignableFrom(type)) return TypeCode.Enum; } return TypeCode.Object; }
[ "public", "static", "TypeCode", "toTypeCode", "(", "Class", "<", "?", ">", "type", ")", "{", "if", "(", "type", "==", "null", ")", "return", "TypeCode", ".", "Unknown", ";", "else", "if", "(", "type", ".", "isArray", "(", ")", ")", "return", "TypeCode", ".", "Array", ";", "else", "if", "(", "type", ".", "isEnum", "(", ")", ")", "return", "TypeCode", ".", "Enum", ";", "else", "if", "(", "type", ".", "isPrimitive", "(", ")", ")", "{", "if", "(", "_booleanType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Boolean", ";", "if", "(", "_doubleType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Double", ";", "if", "(", "_floatType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Float", ";", "if", "(", "_longType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Long", ";", "if", "(", "_integerType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Integer", ";", "}", "else", "{", "if", "(", "_booleanType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Boolean", ";", "if", "(", "_doubleType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Double", ";", "if", "(", "_floatType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Float", ";", "if", "(", "_longType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Long", ";", "if", "(", "_integerType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Integer", ";", "if", "(", "_stringType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "String", ";", "if", "(", "_dateTimeType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "DateTime", ";", "if", "(", "_durationType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Duration", ";", "if", "(", "_mapType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Map", ";", "if", "(", "_listType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Array", ";", "if", "(", "_enumType", ".", "isAssignableFrom", "(", "type", ")", ")", "return", "TypeCode", ".", "Enum", ";", "}", "return", "TypeCode", ".", "Object", ";", "}" ]
Gets TypeCode for specific type. @param type the Class type for the data type. @return the TypeCode that corresponds to the passed object's type.
[ "Gets", "TypeCode", "for", "specific", "type", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/TypeConverter.java#L40-L84
154,686
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/TypeConverter.java
TypeConverter.toTypeCode
public static TypeCode toTypeCode(Object value) { if (value == null) return TypeCode.Unknown; return toTypeCode(value.getClass()); }
java
public static TypeCode toTypeCode(Object value) { if (value == null) return TypeCode.Unknown; return toTypeCode(value.getClass()); }
[ "public", "static", "TypeCode", "toTypeCode", "(", "Object", "value", ")", "{", "if", "(", "value", "==", "null", ")", "return", "TypeCode", ".", "Unknown", ";", "return", "toTypeCode", "(", "value", ".", "getClass", "(", ")", ")", ";", "}" ]
Gets TypeCode for specific value. @param value value whose TypeCode is to be resolved. @return the TypeCode that corresponds to the passed object's type.
[ "Gets", "TypeCode", "for", "specific", "value", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/TypeConverter.java#L92-L97
154,687
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/TypeConverter.java
TypeConverter.toNullableType
@SuppressWarnings("unchecked") public static <T> T toNullableType(Class<T> type, Object value) { TypeCode resultType = toTypeCode(type); if (value == null) return null; if (type.isInstance(value)) return (T) value; // Convert to known types if (resultType == TypeCode.String) return type.cast(StringConverter.toNullableString(value)); else if (resultType == TypeCode.Integer) return type.cast(IntegerConverter.toNullableInteger(value)); else if (resultType == TypeCode.Long) return type.cast(LongConverter.toNullableLong(value)); else if (resultType == TypeCode.Float) return type.cast(FloatConverter.toNullableFloat(value)); else if (resultType == TypeCode.Double) return type.cast(DoubleConverter.toNullableDouble(value)); else if (resultType == TypeCode.Duration) return type.cast(DurationConverter.toNullableDuration(value)); else if (resultType == TypeCode.DateTime) return type.cast(DateTimeConverter.toNullableDateTime(value)); else if (resultType == TypeCode.Array) return type.cast(ArrayConverter.toNullableArray(value)); else if (resultType == TypeCode.Map) return type.cast(MapConverter.toNullableMap(value)); // Convert to unknown type try { return type.cast(value); } catch (Throwable t) { return null; } }
java
@SuppressWarnings("unchecked") public static <T> T toNullableType(Class<T> type, Object value) { TypeCode resultType = toTypeCode(type); if (value == null) return null; if (type.isInstance(value)) return (T) value; // Convert to known types if (resultType == TypeCode.String) return type.cast(StringConverter.toNullableString(value)); else if (resultType == TypeCode.Integer) return type.cast(IntegerConverter.toNullableInteger(value)); else if (resultType == TypeCode.Long) return type.cast(LongConverter.toNullableLong(value)); else if (resultType == TypeCode.Float) return type.cast(FloatConverter.toNullableFloat(value)); else if (resultType == TypeCode.Double) return type.cast(DoubleConverter.toNullableDouble(value)); else if (resultType == TypeCode.Duration) return type.cast(DurationConverter.toNullableDuration(value)); else if (resultType == TypeCode.DateTime) return type.cast(DateTimeConverter.toNullableDateTime(value)); else if (resultType == TypeCode.Array) return type.cast(ArrayConverter.toNullableArray(value)); else if (resultType == TypeCode.Map) return type.cast(MapConverter.toNullableMap(value)); // Convert to unknown type try { return type.cast(value); } catch (Throwable t) { return null; } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "toNullableType", "(", "Class", "<", "T", ">", "type", ",", "Object", "value", ")", "{", "TypeCode", "resultType", "=", "toTypeCode", "(", "type", ")", ";", "if", "(", "value", "==", "null", ")", "return", "null", ";", "if", "(", "type", ".", "isInstance", "(", "value", ")", ")", "return", "(", "T", ")", "value", ";", "// Convert to known types", "if", "(", "resultType", "==", "TypeCode", ".", "String", ")", "return", "type", ".", "cast", "(", "StringConverter", ".", "toNullableString", "(", "value", ")", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Integer", ")", "return", "type", ".", "cast", "(", "IntegerConverter", ".", "toNullableInteger", "(", "value", ")", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Long", ")", "return", "type", ".", "cast", "(", "LongConverter", ".", "toNullableLong", "(", "value", ")", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Float", ")", "return", "type", ".", "cast", "(", "FloatConverter", ".", "toNullableFloat", "(", "value", ")", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Double", ")", "return", "type", ".", "cast", "(", "DoubleConverter", ".", "toNullableDouble", "(", "value", ")", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Duration", ")", "return", "type", ".", "cast", "(", "DurationConverter", ".", "toNullableDuration", "(", "value", ")", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "DateTime", ")", "return", "type", ".", "cast", "(", "DateTimeConverter", ".", "toNullableDateTime", "(", "value", ")", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Array", ")", "return", "type", ".", "cast", "(", "ArrayConverter", ".", "toNullableArray", "(", "value", ")", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Map", ")", "return", "type", ".", "cast", "(", "MapConverter", ".", "toNullableMap", "(", "value", ")", ")", ";", "// Convert to unknown type", "try", "{", "return", "type", ".", "cast", "(", "value", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "return", "null", ";", "}", "}" ]
Converts value into an object type specified by Type Code or returns null when conversion is not possible. @param type the Class type for the data type. @param value the value to convert. @return object value of type corresponding to TypeCode, or null when conversion is not supported. @see TypeConverter#toTypeCode(Class)
[ "Converts", "value", "into", "an", "object", "type", "specified", "by", "Type", "Code", "or", "returns", "null", "when", "conversion", "is", "not", "possible", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/TypeConverter.java#L110-L145
154,688
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/TypeConverter.java
TypeConverter.toType
public static <T> T toType(Class<T> type, Object value) { T result = toNullableType(type, value); if (result != null) return result; TypeCode resultType = toTypeCode(type); if (resultType == TypeCode.String) return null; else if (resultType == TypeCode.Integer) return type.cast((int) 0); else if (resultType == TypeCode.Long) return type.cast((long) 0); else if (resultType == TypeCode.Float) return type.cast((float) 0); else if (resultType == TypeCode.Double) return type.cast((double) 0); else return null; }
java
public static <T> T toType(Class<T> type, Object value) { T result = toNullableType(type, value); if (result != null) return result; TypeCode resultType = toTypeCode(type); if (resultType == TypeCode.String) return null; else if (resultType == TypeCode.Integer) return type.cast((int) 0); else if (resultType == TypeCode.Long) return type.cast((long) 0); else if (resultType == TypeCode.Float) return type.cast((float) 0); else if (resultType == TypeCode.Double) return type.cast((double) 0); else return null; }
[ "public", "static", "<", "T", ">", "T", "toType", "(", "Class", "<", "T", ">", "type", ",", "Object", "value", ")", "{", "T", "result", "=", "toNullableType", "(", "type", ",", "value", ")", ";", "if", "(", "result", "!=", "null", ")", "return", "result", ";", "TypeCode", "resultType", "=", "toTypeCode", "(", "type", ")", ";", "if", "(", "resultType", "==", "TypeCode", ".", "String", ")", "return", "null", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Integer", ")", "return", "type", ".", "cast", "(", "(", "int", ")", "0", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Long", ")", "return", "type", ".", "cast", "(", "(", "long", ")", "0", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Float", ")", "return", "type", ".", "cast", "(", "(", "float", ")", "0", ")", ";", "else", "if", "(", "resultType", "==", "TypeCode", ".", "Double", ")", "return", "type", ".", "cast", "(", "(", "double", ")", "0", ")", ";", "else", "return", "null", ";", "}" ]
Converts value into an object type specified by Type Code or returns type default when conversion is not possible. @param type the Class type for the data type into which 'value' is to be converted. @param value the value to convert. @return object value of type corresponding to TypeCode, or type default when conversion is not supported. @see TypeConverter#toNullableType(Class, Object) @see TypeConverter#toTypeCode(Class)
[ "Converts", "value", "into", "an", "object", "type", "specified", "by", "Type", "Code", "or", "returns", "type", "default", "when", "conversion", "is", "not", "possible", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/TypeConverter.java#L159-L177
154,689
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/TypeConverter.java
TypeConverter.toTypeWithDefault
public static <T> T toTypeWithDefault(Class<T> type, Object value, T defaultValue) { T result = toNullableType(type, value); return result != null ? result : defaultValue; }
java
public static <T> T toTypeWithDefault(Class<T> type, Object value, T defaultValue) { T result = toNullableType(type, value); return result != null ? result : defaultValue; }
[ "public", "static", "<", "T", ">", "T", "toTypeWithDefault", "(", "Class", "<", "T", ">", "type", ",", "Object", "value", ",", "T", "defaultValue", ")", "{", "T", "result", "=", "toNullableType", "(", "type", ",", "value", ")", ";", "return", "result", "!=", "null", "?", "result", ":", "defaultValue", ";", "}" ]
Converts value into an object type specified by Type Code or returns default value when conversion is not possible. @param type the Class type for the data type into which 'value' is to be converted. @param value the value to convert. @param defaultValue the default value to return if conversion is not possible (returns null). @return object value of type corresponding to TypeCode, or default value when conversion is not supported. @see TypeConverter#toNullableType(Class, Object) @see TypeConverter#toTypeCode(Class)
[ "Converts", "value", "into", "an", "object", "type", "specified", "by", "Type", "Code", "or", "returns", "default", "value", "when", "conversion", "is", "not", "possible", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/TypeConverter.java#L193-L196
154,690
luyanfei/umeditor-fragment
src/main/java/cn/jhc/um/servlet/UploadServlet.java
UploadServlet.extractFileName
private String extractFileName(Part part) { String disposition = part.getHeader("Content-Disposition"); if (disposition == null) return null; Matcher matcher = FILENAME_PATTERN.matcher(disposition); if (!matcher.find()) return null; return matcher.group(1); }
java
private String extractFileName(Part part) { String disposition = part.getHeader("Content-Disposition"); if (disposition == null) return null; Matcher matcher = FILENAME_PATTERN.matcher(disposition); if (!matcher.find()) return null; return matcher.group(1); }
[ "private", "String", "extractFileName", "(", "Part", "part", ")", "{", "String", "disposition", "=", "part", ".", "getHeader", "(", "\"Content-Disposition\"", ")", ";", "if", "(", "disposition", "==", "null", ")", "return", "null", ";", "Matcher", "matcher", "=", "FILENAME_PATTERN", ".", "matcher", "(", "disposition", ")", ";", "if", "(", "!", "matcher", ".", "find", "(", ")", ")", "return", "null", ";", "return", "matcher", ".", "group", "(", "1", ")", ";", "}" ]
Extract filename property from Part's Content-Disposition header. @param part @return the extracted filename value.
[ "Extract", "filename", "property", "from", "Part", "s", "Content", "-", "Disposition", "header", "." ]
acf5a0f1f2c959e053f066bfb8917652c48cdc4e
https://github.com/luyanfei/umeditor-fragment/blob/acf5a0f1f2c959e053f066bfb8917652c48cdc4e/src/main/java/cn/jhc/um/servlet/UploadServlet.java#L109-L117
154,691
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/PercentileStatistics.java
PercentileStatistics.getPercentile
public synchronized Double getPercentile(final double percentile) { if (null == values) return Double.NaN; return values.parallelStream().flatMapToDouble(x -> Arrays.stream(x)).sorted().skip((int) (percentile * values.size())).findFirst().orElse(Double.NaN); }
java
public synchronized Double getPercentile(final double percentile) { if (null == values) return Double.NaN; return values.parallelStream().flatMapToDouble(x -> Arrays.stream(x)).sorted().skip((int) (percentile * values.size())).findFirst().orElse(Double.NaN); }
[ "public", "synchronized", "Double", "getPercentile", "(", "final", "double", "percentile", ")", "{", "if", "(", "null", "==", "values", ")", "return", "Double", ".", "NaN", ";", "return", "values", ".", "parallelStream", "(", ")", ".", "flatMapToDouble", "(", "x", "->", "Arrays", ".", "stream", "(", "x", ")", ")", ".", "sorted", "(", ")", ".", "skip", "(", "(", "int", ")", "(", "percentile", "*", "values", ".", "size", "(", ")", ")", ")", ".", "findFirst", "(", ")", ".", "orElse", "(", "Double", ".", "NaN", ")", ";", "}" ]
Gets percentile. @param percentile the percentile @return the percentile
[ "Gets", "percentile", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/PercentileStatistics.java#L67-L70
154,692
Sonoport/freesound-java
src/main/java/com/sonoport/freesound/query/SoundPagingQuery.java
SoundPagingQuery.includeFields
@SuppressWarnings("unchecked") public Q includeFields(final Set<String> fields) { if (this.fields == null) { this.fields = new HashSet<>(); } if (fields != null) { this.fields.addAll(fields); } return (Q) this; }
java
@SuppressWarnings("unchecked") public Q includeFields(final Set<String> fields) { if (this.fields == null) { this.fields = new HashSet<>(); } if (fields != null) { this.fields.addAll(fields); } return (Q) this; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Q", "includeFields", "(", "final", "Set", "<", "String", ">", "fields", ")", "{", "if", "(", "this", ".", "fields", "==", "null", ")", "{", "this", ".", "fields", "=", "new", "HashSet", "<>", "(", ")", ";", "}", "if", "(", "fields", "!=", "null", ")", "{", "this", ".", "fields", ".", "addAll", "(", "fields", ")", ";", "}", "return", "(", "Q", ")", "this", ";", "}" ]
Specify the set of fields to return in the results. Defined using the Fluent API approach. @param fields The fields to return @return The current query
[ "Specify", "the", "set", "of", "fields", "to", "return", "in", "the", "results", ".", "Defined", "using", "the", "Fluent", "API", "approach", "." ]
ab029e25de068c6f8cc028bc7f916938fd97c036
https://github.com/Sonoport/freesound-java/blob/ab029e25de068c6f8cc028bc7f916938fd97c036/src/main/java/com/sonoport/freesound/query/SoundPagingQuery.java#L95-L106
154,693
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/LookupManagerImpl.java
LookupManagerImpl.validateServiceInstanceMetadataQuery
private void validateServiceInstanceMetadataQuery(ServiceInstanceQuery query) throws ServiceException{ if (query == null) { throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR, ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(), "service instance query"); } for(QueryCriterion criterion : query.getCriteria()){ if(criterion instanceof ContainQueryCriterion || criterion instanceof NotContainQueryCriterion){ throw new ServiceException(ErrorCode.QUERY_CRITERION_ILLEGAL_IN_QUERY); } } }
java
private void validateServiceInstanceMetadataQuery(ServiceInstanceQuery query) throws ServiceException{ if (query == null) { throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR, ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(), "service instance query"); } for(QueryCriterion criterion : query.getCriteria()){ if(criterion instanceof ContainQueryCriterion || criterion instanceof NotContainQueryCriterion){ throw new ServiceException(ErrorCode.QUERY_CRITERION_ILLEGAL_IN_QUERY); } } }
[ "private", "void", "validateServiceInstanceMetadataQuery", "(", "ServiceInstanceQuery", "query", ")", "throws", "ServiceException", "{", "if", "(", "query", "==", "null", ")", "{", "throw", "new", "ServiceException", "(", "ErrorCode", ".", "SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR", ",", "ErrorCode", ".", "SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR", ".", "getMessageTemplate", "(", ")", ",", "\"service instance query\"", ")", ";", "}", "for", "(", "QueryCriterion", "criterion", ":", "query", ".", "getCriteria", "(", ")", ")", "{", "if", "(", "criterion", "instanceof", "ContainQueryCriterion", "||", "criterion", "instanceof", "NotContainQueryCriterion", ")", "{", "throw", "new", "ServiceException", "(", "ErrorCode", ".", "QUERY_CRITERION_ILLEGAL_IN_QUERY", ")", ";", "}", "}", "}" ]
Validate the metadata query for the queryInstanceByMetadataKey, queryInstancesByMetadataKey and getAllInstancesByMetadataKey methods. For those methods, the ContainQueryCriterion and NotContainQueryCriterion are not supported. @param query the ServiceInstanceQuery to be validated. @throws ServiceException when the ServiceInstanceQuery has ContainQueryCriterion or NotContainQueryCriterion.
[ "Validate", "the", "metadata", "query", "for", "the", "queryInstanceByMetadataKey", "queryInstancesByMetadataKey", "and", "getAllInstancesByMetadataKey", "methods", ".", "For", "those", "methods", "the", "ContainQueryCriterion", "and", "NotContainQueryCriterion", "are", "not", "supported", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/LookupManagerImpl.java#L399-L412
154,694
JM-Lab/utils-java8
src/main/java/kr/jm/utils/stats/generator/NumberStatsGenerator.java
NumberStatsGenerator.buildStatsMap
public static Map<String, Number> buildStatsMap( Collection<Number> numberCollection) { return JMMap.newChangedKeyMap( getOptional(numberCollection).map(NumberSummaryStatistics::of) .map(NumberSummaryStatistics::getStatsFieldMap) .orElseGet(Collections::emptyMap), StatsField::name); }
java
public static Map<String, Number> buildStatsMap( Collection<Number> numberCollection) { return JMMap.newChangedKeyMap( getOptional(numberCollection).map(NumberSummaryStatistics::of) .map(NumberSummaryStatistics::getStatsFieldMap) .orElseGet(Collections::emptyMap), StatsField::name); }
[ "public", "static", "Map", "<", "String", ",", "Number", ">", "buildStatsMap", "(", "Collection", "<", "Number", ">", "numberCollection", ")", "{", "return", "JMMap", ".", "newChangedKeyMap", "(", "getOptional", "(", "numberCollection", ")", ".", "map", "(", "NumberSummaryStatistics", "::", "of", ")", ".", "map", "(", "NumberSummaryStatistics", "::", "getStatsFieldMap", ")", ".", "orElseGet", "(", "Collections", "::", "emptyMap", ")", ",", "StatsField", "::", "name", ")", ";", "}" ]
Build stats map map. @param numberCollection the number collection @return the map
[ "Build", "stats", "map", "map", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/generator/NumberStatsGenerator.java#L24-L30
154,695
james-hu/jabb-core
src/main/java/net/sf/jabb/util/jms/JmsUtility.java
JmsUtility.exceptionSummary
static public String exceptionSummary(JMSException e){ Throwable cause = e.getCause(); Exception linked = e.getLinkedException(); return "JMSException: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", linked exception: " + (linked == null ? null : (linked.getClass().getName() + " - " + linked.getMessage())) + ", cause: " + (cause == null ? null : (cause.getClass().getName() + " - " + cause.getMessage())); }
java
static public String exceptionSummary(JMSException e){ Throwable cause = e.getCause(); Exception linked = e.getLinkedException(); return "JMSException: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", linked exception: " + (linked == null ? null : (linked.getClass().getName() + " - " + linked.getMessage())) + ", cause: " + (cause == null ? null : (cause.getClass().getName() + " - " + cause.getMessage())); }
[ "static", "public", "String", "exceptionSummary", "(", "JMSException", "e", ")", "{", "Throwable", "cause", "=", "e", ".", "getCause", "(", ")", ";", "Exception", "linked", "=", "e", ".", "getLinkedException", "(", ")", ";", "return", "\"JMSException: \"", "+", "e", ".", "getMessage", "(", ")", "+", "\", error code: \"", "+", "e", ".", "getErrorCode", "(", ")", "+", "\", linked exception: \"", "+", "(", "linked", "==", "null", "?", "null", ":", "(", "linked", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\" - \"", "+", "linked", ".", "getMessage", "(", ")", ")", ")", "+", "\", cause: \"", "+", "(", "cause", "==", "null", "?", "null", ":", "(", "cause", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\" - \"", "+", "cause", ".", "getMessage", "(", ")", ")", ")", ";", "}" ]
Generate a single line String consisted of the summary of a JMSException @param e the exception @return summary of the exception in one line
[ "Generate", "a", "single", "line", "String", "consisted", "of", "the", "summary", "of", "a", "JMSException" ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/jms/JmsUtility.java#L25-L34
154,696
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/FloatConverter.java
FloatConverter.toNullableFloat
public static Float toNullableFloat(Object value) { Double result = DoubleConverter.toNullableDouble(value); return result != null ? (float) ((double) result) : null; }
java
public static Float toNullableFloat(Object value) { Double result = DoubleConverter.toNullableDouble(value); return result != null ? (float) ((double) result) : null; }
[ "public", "static", "Float", "toNullableFloat", "(", "Object", "value", ")", "{", "Double", "result", "=", "DoubleConverter", ".", "toNullableDouble", "(", "value", ")", ";", "return", "result", "!=", "null", "?", "(", "float", ")", "(", "(", "double", ")", "result", ")", ":", "null", ";", "}" ]
Converts value into float or returns null when conversion is not possible. @param value the value to convert. @return float value or null when conversion is not supported. @see DoubleConverter#toNullableDouble(Object)
[ "Converts", "value", "into", "float", "or", "returns", "null", "when", "conversion", "is", "not", "possible", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/FloatConverter.java#L32-L35
154,697
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/convert/FloatConverter.java
FloatConverter.toFloatWithDefault
public static float toFloatWithDefault(Object value, float defaultValue) { Float result = toNullableFloat(value); return result != null ? (float) result : defaultValue; }
java
public static float toFloatWithDefault(Object value, float defaultValue) { Float result = toNullableFloat(value); return result != null ? (float) result : defaultValue; }
[ "public", "static", "float", "toFloatWithDefault", "(", "Object", "value", ",", "float", "defaultValue", ")", "{", "Float", "result", "=", "toNullableFloat", "(", "value", ")", ";", "return", "result", "!=", "null", "?", "(", "float", ")", "result", ":", "defaultValue", ";", "}" ]
Converts value into float or returns default when conversion is not possible. @param value the value to convert. @param defaultValue the default value. @return float value or default value when conversion is not supported. @see DoubleConverter#toDoubleWithDefault(Object, double) @see FloatConverter#toNullableFloat(Object)
[ "Converts", "value", "into", "float", "or", "returns", "default", "when", "conversion", "is", "not", "possible", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/FloatConverter.java#L60-L63
154,698
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/items/AbstractItemSet.java
AbstractItemSet.getNextConstructions
public List<Construction> getNextConstructions() { List<Construction> constructions = new ArrayList<Construction>(); for (T item : kernelItems) { Construction element = item.getNext(); if (element != null) { constructions.add(element); } } for (T item : nonKernelItems) { Construction element = item.getNext(); if (element != null) { constructions.add(element); } } return constructions; }
java
public List<Construction> getNextConstructions() { List<Construction> constructions = new ArrayList<Construction>(); for (T item : kernelItems) { Construction element = item.getNext(); if (element != null) { constructions.add(element); } } for (T item : nonKernelItems) { Construction element = item.getNext(); if (element != null) { constructions.add(element); } } return constructions; }
[ "public", "List", "<", "Construction", ">", "getNextConstructions", "(", ")", "{", "List", "<", "Construction", ">", "constructions", "=", "new", "ArrayList", "<", "Construction", ">", "(", ")", ";", "for", "(", "T", "item", ":", "kernelItems", ")", "{", "Construction", "element", "=", "item", ".", "getNext", "(", ")", ";", "if", "(", "element", "!=", "null", ")", "{", "constructions", ".", "add", "(", "element", ")", ";", "}", "}", "for", "(", "T", "item", ":", "nonKernelItems", ")", "{", "Construction", "element", "=", "item", ".", "getNext", "(", ")", ";", "if", "(", "element", "!=", "null", ")", "{", "constructions", ".", "add", "(", "element", ")", ";", "}", "}", "return", "constructions", ";", "}" ]
This method returns all constructions which are next to be expected to be found. @return {@link List} of {@link Construction} is returned.
[ "This", "method", "returns", "all", "constructions", "which", "are", "next", "to", "be", "expected", "to", "be", "found", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/items/AbstractItemSet.java#L161-L176
154,699
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/items/AbstractItemSet.java
AbstractItemSet.getNextItems
public List<T> getNextItems(Construction construction) { List<T> items = new ArrayList<T>(); for (T item : allItems) { if (construction.equals(item.getNext())) { items.add(item); } } return items; }
java
public List<T> getNextItems(Construction construction) { List<T> items = new ArrayList<T>(); for (T item : allItems) { if (construction.equals(item.getNext())) { items.add(item); } } return items; }
[ "public", "List", "<", "T", ">", "getNextItems", "(", "Construction", "construction", ")", "{", "List", "<", "T", ">", "items", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "for", "(", "T", "item", ":", "allItems", ")", "{", "if", "(", "construction", ".", "equals", "(", "item", ".", "getNext", "(", ")", ")", ")", "{", "items", ".", "add", "(", "item", ")", ";", "}", "}", "return", "items", ";", "}" ]
This method returns all items which have the given construction as next construction. @param construction is the {@link Construction} to be used to look up next items. @return A {@link List} of items is returned.
[ "This", "method", "returns", "all", "items", "which", "have", "the", "given", "construction", "as", "next", "construction", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/items/AbstractItemSet.java#L186-L194