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
22,600
jamesagnew/hapi-fhir
hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/IniFile.java
IniFile.delRemChars
private String delRemChars(String pstrSrc) { int intPos = 0; if (pstrSrc == null) return null; while ((intPos = pstrSrc.indexOf(";")) >= 0) { if (intPos == 0) pstrSrc = pstrSrc.substring(intPos + 1); else if (intPos > 0) pstrSrc = pstrSrc.substring(0, intPos) + pstrSrc.substring(intPos + 1); } return pstrSrc; }
java
private String delRemChars(String pstrSrc) { int intPos = 0; if (pstrSrc == null) return null; while ((intPos = pstrSrc.indexOf(";")) >= 0) { if (intPos == 0) pstrSrc = pstrSrc.substring(intPos + 1); else if (intPos > 0) pstrSrc = pstrSrc.substring(0, intPos) + pstrSrc.substring(intPos + 1); } return pstrSrc; }
[ "private", "String", "delRemChars", "(", "String", "pstrSrc", ")", "{", "int", "intPos", "=", "0", ";", "if", "(", "pstrSrc", "==", "null", ")", "return", "null", ";", "while", "(", "(", "intPos", "=", "pstrSrc", ".", "indexOf", "(", "\";\"", ")", ")", ">=", "0", ")", "{", "if", "(", "intPos", "==", "0", ")", "pstrSrc", "=", "pstrSrc", ".", "substring", "(", "intPos", "+", "1", ")", ";", "else", "if", "(", "intPos", ">", "0", ")", "pstrSrc", "=", "pstrSrc", ".", "substring", "(", "0", ",", "intPos", ")", "+", "pstrSrc", ".", "substring", "(", "intPos", "+", "1", ")", ";", "}", "return", "pstrSrc", ";", "}" ]
This function deletes the remark characters ';' from source string @param pstrSrc the source string @return the converted string
[ "This", "function", "deletes", "the", "remark", "characters", ";", "from", "source", "string" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/IniFile.java#L1159-L1172
22,601
jamesagnew/hapi-fhir
hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/IniFile.java
IniFile.addRemChars
private String addRemChars(String pstrSrc) { int intLen = 2; int intPos = 0; int intPrev = 0; String strLeft = null; String strRight = null; if (pstrSrc == null) return null; while (intPos >= 0) { intLen = 2; intPos = pstrSrc.indexOf("\r\n", intPrev); if (intPos < 0) { intLen = 1; intPos = pstrSrc.indexOf("\n", intPrev); if (intPos < 0) intPos = pstrSrc.indexOf("\r", intPrev); } if (intPos == 0) { pstrSrc = ";\r\n" + pstrSrc.substring(intPos + intLen); intPrev = intPos + intLen + 1; } else if (intPos > 0) { strLeft = pstrSrc.substring(0, intPos); strRight = pstrSrc.substring(intPos + intLen); if (strRight == null) pstrSrc = strLeft; else if (strRight.length() == 0) pstrSrc = strLeft; else pstrSrc = strLeft + "\r\n;" + strRight; intPrev = intPos + intLen + 1; } } if (!pstrSrc.substring(0, 1).equals(";")) pstrSrc = ";" + pstrSrc; pstrSrc = pstrSrc + "\r\n"; return pstrSrc; }
java
private String addRemChars(String pstrSrc) { int intLen = 2; int intPos = 0; int intPrev = 0; String strLeft = null; String strRight = null; if (pstrSrc == null) return null; while (intPos >= 0) { intLen = 2; intPos = pstrSrc.indexOf("\r\n", intPrev); if (intPos < 0) { intLen = 1; intPos = pstrSrc.indexOf("\n", intPrev); if (intPos < 0) intPos = pstrSrc.indexOf("\r", intPrev); } if (intPos == 0) { pstrSrc = ";\r\n" + pstrSrc.substring(intPos + intLen); intPrev = intPos + intLen + 1; } else if (intPos > 0) { strLeft = pstrSrc.substring(0, intPos); strRight = pstrSrc.substring(intPos + intLen); if (strRight == null) pstrSrc = strLeft; else if (strRight.length() == 0) pstrSrc = strLeft; else pstrSrc = strLeft + "\r\n;" + strRight; intPrev = intPos + intLen + 1; } } if (!pstrSrc.substring(0, 1).equals(";")) pstrSrc = ";" + pstrSrc; pstrSrc = pstrSrc + "\r\n"; return pstrSrc; }
[ "private", "String", "addRemChars", "(", "String", "pstrSrc", ")", "{", "int", "intLen", "=", "2", ";", "int", "intPos", "=", "0", ";", "int", "intPrev", "=", "0", ";", "String", "strLeft", "=", "null", ";", "String", "strRight", "=", "null", ";", "if", "(", "pstrSrc", "==", "null", ")", "return", "null", ";", "while", "(", "intPos", ">=", "0", ")", "{", "intLen", "=", "2", ";", "intPos", "=", "pstrSrc", ".", "indexOf", "(", "\"\\r\\n\"", ",", "intPrev", ")", ";", "if", "(", "intPos", "<", "0", ")", "{", "intLen", "=", "1", ";", "intPos", "=", "pstrSrc", ".", "indexOf", "(", "\"\\n\"", ",", "intPrev", ")", ";", "if", "(", "intPos", "<", "0", ")", "intPos", "=", "pstrSrc", ".", "indexOf", "(", "\"\\r\"", ",", "intPrev", ")", ";", "}", "if", "(", "intPos", "==", "0", ")", "{", "pstrSrc", "=", "\";\\r\\n\"", "+", "pstrSrc", ".", "substring", "(", "intPos", "+", "intLen", ")", ";", "intPrev", "=", "intPos", "+", "intLen", "+", "1", ";", "}", "else", "if", "(", "intPos", ">", "0", ")", "{", "strLeft", "=", "pstrSrc", ".", "substring", "(", "0", ",", "intPos", ")", ";", "strRight", "=", "pstrSrc", ".", "substring", "(", "intPos", "+", "intLen", ")", ";", "if", "(", "strRight", "==", "null", ")", "pstrSrc", "=", "strLeft", ";", "else", "if", "(", "strRight", ".", "length", "(", ")", "==", "0", ")", "pstrSrc", "=", "strLeft", ";", "else", "pstrSrc", "=", "strLeft", "+", "\"\\r\\n;\"", "+", "strRight", ";", "intPrev", "=", "intPos", "+", "intLen", "+", "1", ";", "}", "}", "if", "(", "!", "pstrSrc", ".", "substring", "(", "0", ",", "1", ")", ".", "equals", "(", "\";\"", ")", ")", "pstrSrc", "=", "\";\"", "+", "pstrSrc", ";", "pstrSrc", "=", "pstrSrc", "+", "\"\\r\\n\"", ";", "return", "pstrSrc", ";", "}" ]
This function adds a remark character ';' in source string. @param pstrSrc source string @return converted string.
[ "This", "function", "adds", "a", "remark", "character", ";", "in", "source", "string", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/IniFile.java#L1179-L1221
22,602
jamesagnew/hapi-fhir
hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/IniFile.java
IniFile.main
public static void main(String[] pstrArgs) { IniFile objINI = null; String strFile = null; if (pstrArgs.length == 0) return; strFile = pstrArgs[0]; // Following call will load the strFile if one exists. objINI = new IniFile(strFile); // objINI.addSection("QADatabase", "QA database connection details\nUsed for QA Testing"); // objINI.setStringProperty("QADatabase", "SID", "ORCL", null); // objINI.setStringProperty("QADatabase", "UserId", "System", null); // objINI.setStringProperty("QADatabase", "Password", "Manager", null); // objINI.setStringProperty("QADatabase", "HostName", "DBServer", null); // objINI.setIntegerProperty("QADatabase", "Port", 1521, null); // objINI.setStringProperty("QADatabase", "OracleHome", "%ORACLE_HOME%", null); // // objINI.setSectionComments("Folders", "Directories where generated files are stored"); objINI.setStringProperty("Folders", "folder1", "G:\\Temp", null); objINI.setStringProperty("Folders", "folder2", "G:\\Temp\\Backup", null); // Save changes back to strFile. objINI.save(); objINI = null; }
java
public static void main(String[] pstrArgs) { IniFile objINI = null; String strFile = null; if (pstrArgs.length == 0) return; strFile = pstrArgs[0]; // Following call will load the strFile if one exists. objINI = new IniFile(strFile); // objINI.addSection("QADatabase", "QA database connection details\nUsed for QA Testing"); // objINI.setStringProperty("QADatabase", "SID", "ORCL", null); // objINI.setStringProperty("QADatabase", "UserId", "System", null); // objINI.setStringProperty("QADatabase", "Password", "Manager", null); // objINI.setStringProperty("QADatabase", "HostName", "DBServer", null); // objINI.setIntegerProperty("QADatabase", "Port", 1521, null); // objINI.setStringProperty("QADatabase", "OracleHome", "%ORACLE_HOME%", null); // // objINI.setSectionComments("Folders", "Directories where generated files are stored"); objINI.setStringProperty("Folders", "folder1", "G:\\Temp", null); objINI.setStringProperty("Folders", "folder2", "G:\\Temp\\Backup", null); // Save changes back to strFile. objINI.save(); objINI = null; }
[ "public", "static", "void", "main", "(", "String", "[", "]", "pstrArgs", ")", "{", "IniFile", "objINI", "=", "null", ";", "String", "strFile", "=", "null", ";", "if", "(", "pstrArgs", ".", "length", "==", "0", ")", "return", ";", "strFile", "=", "pstrArgs", "[", "0", "]", ";", "// Following call will load the strFile if one exists.\r", "objINI", "=", "new", "IniFile", "(", "strFile", ")", ";", "// objINI.addSection(\"QADatabase\", \"QA database connection details\\nUsed for QA Testing\");\r", "// objINI.setStringProperty(\"QADatabase\", \"SID\", \"ORCL\", null);\r", "// objINI.setStringProperty(\"QADatabase\", \"UserId\", \"System\", null);\r", "// objINI.setStringProperty(\"QADatabase\", \"Password\", \"Manager\", null);\r", "// objINI.setStringProperty(\"QADatabase\", \"HostName\", \"DBServer\", null);\r", "// objINI.setIntegerProperty(\"QADatabase\", \"Port\", 1521, null);\r", "// objINI.setStringProperty(\"QADatabase\", \"OracleHome\", \"%ORACLE_HOME%\", null);\r", "// \r", "// objINI.setSectionComments(\"Folders\", \"Directories where generated files are stored\");\r", "objINI", ".", "setStringProperty", "(", "\"Folders\"", ",", "\"folder1\"", ",", "\"G:\\\\Temp\"", ",", "null", ")", ";", "objINI", ".", "setStringProperty", "(", "\"Folders\"", ",", "\"folder2\"", ",", "\"G:\\\\Temp\\\\Backup\"", ",", "null", ")", ";", "// Save changes back to strFile.\r", "objINI", ".", "save", "(", ")", ";", "objINI", "=", "null", ";", "}" ]
The main entry point for testing. @param pstrArgs the command line arguments array if any. @
[ "The", "main", "entry", "point", "for", "testing", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/IniFile.java#L1230-L1256
22,603
jamesagnew/hapi-fhir
hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/DefinitionNavigator.java
DefinitionNavigator.hasTypeChildren
public boolean hasTypeChildren(TypeRefComponent type) throws DefinitionException { if (typeChildren == null || typeOfChildren != type) { loadTypedChildren(type); } return !typeChildren.isEmpty(); }
java
public boolean hasTypeChildren(TypeRefComponent type) throws DefinitionException { if (typeChildren == null || typeOfChildren != type) { loadTypedChildren(type); } return !typeChildren.isEmpty(); }
[ "public", "boolean", "hasTypeChildren", "(", "TypeRefComponent", "type", ")", "throws", "DefinitionException", "{", "if", "(", "typeChildren", "==", "null", "||", "typeOfChildren", "!=", "type", ")", "{", "loadTypedChildren", "(", "type", ")", ";", "}", "return", "!", "typeChildren", ".", "isEmpty", "(", ")", ";", "}" ]
if you have a typed element, the tree might end at that point. And you may or may not want to walk into the tree of that type It depends what you are doing. So this is a choice. You can ask for the children, and then, if you get no children, you can see if there are children defined for the type, and then get them you have to provide a type if there's more than one type for current() since this library doesn't know how to choose @throws DefinitionException @
[ "if", "you", "have", "a", "typed", "element", "the", "tree", "might", "end", "at", "that", "point", ".", "And", "you", "may", "or", "may", "not", "want", "to", "walk", "into", "the", "tree", "of", "that", "type", "It", "depends", "what", "you", "are", "doing", ".", "So", "this", "is", "a", "choice", ".", "You", "can", "ask", "for", "the", "children", "and", "then", "if", "you", "get", "no", "children", "you", "can", "see", "if", "there", "are", "children", "defined", "for", "the", "type", "and", "then", "get", "them" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/DefinitionNavigator.java#L139-L144
22,604
jamesagnew/hapi-fhir
hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/TagList.java
TagList.addTag
public Tag addTag(String theScheme, String theTerm) { Tag retVal = new Tag(theScheme, theTerm); add(retVal); myOrderedTags = null; return retVal; }
java
public Tag addTag(String theScheme, String theTerm) { Tag retVal = new Tag(theScheme, theTerm); add(retVal); myOrderedTags = null; return retVal; }
[ "public", "Tag", "addTag", "(", "String", "theScheme", ",", "String", "theTerm", ")", "{", "Tag", "retVal", "=", "new", "Tag", "(", "theScheme", ",", "theTerm", ")", ";", "add", "(", "retVal", ")", ";", "myOrderedTags", "=", "null", ";", "return", "retVal", ";", "}" ]
Add a new tag instance @param theScheme The tag scheme (the system) @param theTerm The tag term (the code) @return Returns the newly created tag instance. Note that the tag is added to the list by this method, so you generally do not need to interact directly with the added tag.
[ "Add", "a", "new", "tag", "instance" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/TagList.java#L113-L118
22,605
jamesagnew/hapi-fhir
hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/RestfulClientFactory.java
RestfulClientFactory.newClient
@Override public synchronized <T extends IRestfulClient> T newClient(Class<T> theClientType, String theServerBase) { validateConfigured(); if (!theClientType.isInterface()) { throw new ConfigurationException(theClientType.getCanonicalName() + " is not an interface"); } ClientInvocationHandlerFactory invocationHandler = myInvocationHandlers.get(theClientType); if (invocationHandler == null) { IHttpClient httpClient = getHttpClient(theServerBase); invocationHandler = new ClientInvocationHandlerFactory(httpClient, myContext, theServerBase, theClientType); for (Method nextMethod : theClientType.getMethods()) { BaseMethodBinding<?> binding = BaseMethodBinding.bindMethod(nextMethod, myContext, null); invocationHandler.addBinding(nextMethod, binding); } myInvocationHandlers.put(theClientType, invocationHandler); } return instantiateProxy(theClientType, invocationHandler.newInvocationHandler(this)); }
java
@Override public synchronized <T extends IRestfulClient> T newClient(Class<T> theClientType, String theServerBase) { validateConfigured(); if (!theClientType.isInterface()) { throw new ConfigurationException(theClientType.getCanonicalName() + " is not an interface"); } ClientInvocationHandlerFactory invocationHandler = myInvocationHandlers.get(theClientType); if (invocationHandler == null) { IHttpClient httpClient = getHttpClient(theServerBase); invocationHandler = new ClientInvocationHandlerFactory(httpClient, myContext, theServerBase, theClientType); for (Method nextMethod : theClientType.getMethods()) { BaseMethodBinding<?> binding = BaseMethodBinding.bindMethod(nextMethod, myContext, null); invocationHandler.addBinding(nextMethod, binding); } myInvocationHandlers.put(theClientType, invocationHandler); } return instantiateProxy(theClientType, invocationHandler.newInvocationHandler(this)); }
[ "@", "Override", "public", "synchronized", "<", "T", "extends", "IRestfulClient", ">", "T", "newClient", "(", "Class", "<", "T", ">", "theClientType", ",", "String", "theServerBase", ")", "{", "validateConfigured", "(", ")", ";", "if", "(", "!", "theClientType", ".", "isInterface", "(", ")", ")", "{", "throw", "new", "ConfigurationException", "(", "theClientType", ".", "getCanonicalName", "(", ")", "+", "\" is not an interface\"", ")", ";", "}", "ClientInvocationHandlerFactory", "invocationHandler", "=", "myInvocationHandlers", ".", "get", "(", "theClientType", ")", ";", "if", "(", "invocationHandler", "==", "null", ")", "{", "IHttpClient", "httpClient", "=", "getHttpClient", "(", "theServerBase", ")", ";", "invocationHandler", "=", "new", "ClientInvocationHandlerFactory", "(", "httpClient", ",", "myContext", ",", "theServerBase", ",", "theClientType", ")", ";", "for", "(", "Method", "nextMethod", ":", "theClientType", ".", "getMethods", "(", ")", ")", "{", "BaseMethodBinding", "<", "?", ">", "binding", "=", "BaseMethodBinding", ".", "bindMethod", "(", "nextMethod", ",", "myContext", ",", "null", ")", ";", "invocationHandler", ".", "addBinding", "(", "nextMethod", ",", "binding", ")", ";", "}", "myInvocationHandlers", ".", "put", "(", "theClientType", ",", "invocationHandler", ")", ";", "}", "return", "instantiateProxy", "(", "theClientType", ",", "invocationHandler", ".", "newInvocationHandler", "(", "this", ")", ")", ";", "}" ]
Instantiates a new client instance @param theClientType The client type, which is an interface type to be instantiated @param theServerBase The URL of the base for the restful FHIR server to connect to @return A newly created client @throws ConfigurationException If the interface type is not an interface
[ "Instantiates", "a", "new", "client", "instance" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/RestfulClientFactory.java#L139-L159
22,606
jamesagnew/hapi-fhir
hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/RestfulClientFactory.java
RestfulClientFactory.setFhirContext
public void setFhirContext(FhirContext theContext) { if (myContext != null && myContext != theContext) { throw new IllegalStateException("RestfulClientFactory instance is already associated with one FhirContext. RestfulClientFactory instances can not be shared."); } myContext = theContext; }
java
public void setFhirContext(FhirContext theContext) { if (myContext != null && myContext != theContext) { throw new IllegalStateException("RestfulClientFactory instance is already associated with one FhirContext. RestfulClientFactory instances can not be shared."); } myContext = theContext; }
[ "public", "void", "setFhirContext", "(", "FhirContext", "theContext", ")", "{", "if", "(", "myContext", "!=", "null", "&&", "myContext", "!=", "theContext", ")", "{", "throw", "new", "IllegalStateException", "(", "\"RestfulClientFactory instance is already associated with one FhirContext. RestfulClientFactory instances can not be shared.\"", ")", ";", "}", "myContext", "=", "theContext", ";", "}" ]
Sets the context associated with this client factory. Must not be called more than once.
[ "Sets", "the", "context", "associated", "with", "this", "client", "factory", ".", "Must", "not", "be", "called", "more", "than", "once", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/RestfulClientFactory.java#L203-L208
22,607
jamesagnew/hapi-fhir
hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/model/dstu/resource/BaseResource.java
BaseResource.getAllPopulatedChildElementsOfType
@Override public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) { return Collections.emptyList(); }
java
@Override public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) { return Collections.emptyList(); }
[ "@", "Override", "public", "<", "T", "extends", "IElement", ">", "List", "<", "T", ">", "getAllPopulatedChildElementsOfType", "(", "Class", "<", "T", ">", "theType", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}" ]
NOP implementation of this method. @see ICompositeElement#getAllPopulatedChildElementsOfType(Class) for an explanation of why you don't need to override this method
[ "NOP", "implementation", "of", "this", "method", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/model/dstu/resource/BaseResource.java#L103-L106
22,608
jamesagnew/hapi-fhir
hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/model/Meta.java
Meta.addTag
public Meta addTag(String theSystem, String theCode, String theDisplay) { addTag().setSystem(theSystem).setCode(theCode).setDisplay(theDisplay); return this; }
java
public Meta addTag(String theSystem, String theCode, String theDisplay) { addTag().setSystem(theSystem).setCode(theCode).setDisplay(theDisplay); return this; }
[ "public", "Meta", "addTag", "(", "String", "theSystem", ",", "String", "theCode", ",", "String", "theDisplay", ")", "{", "addTag", "(", ")", ".", "setSystem", "(", "theSystem", ")", ".", "setCode", "(", "theCode", ")", ".", "setDisplay", "(", "theDisplay", ")", ";", "return", "this", ";", "}" ]
Convenience method which adds a tag @param theSystem The code system @param theCode The code @param theDisplay The display name @return Returns a reference to <code>this</code> for easy chaining
[ "Convenience", "method", "which", "adds", "a", "tag" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/model/Meta.java#L371-L374
22,609
jamesagnew/hapi-fhir
hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ElementUtil.java
ElementUtil.allPopulatedChildElements
public static <T extends IElement> List<T> allPopulatedChildElements(Class<T> theType, Object... theElements) { ArrayList<T> retVal = new ArrayList<T>(); for (Object next : theElements) { if (next == null) { continue; }else if (next instanceof IElement) { addElement(retVal, (IElement) next, theType); } else if (next instanceof List) { for (Object nextElement : ((List<?>)next)) { if (!(nextElement instanceof IBase)) { throw new IllegalArgumentException("Found element of "+nextElement.getClass()); } addElement(retVal, (IElement) nextElement, theType); } } else { throw new IllegalArgumentException("Found element of "+next.getClass()); } } return retVal; }
java
public static <T extends IElement> List<T> allPopulatedChildElements(Class<T> theType, Object... theElements) { ArrayList<T> retVal = new ArrayList<T>(); for (Object next : theElements) { if (next == null) { continue; }else if (next instanceof IElement) { addElement(retVal, (IElement) next, theType); } else if (next instanceof List) { for (Object nextElement : ((List<?>)next)) { if (!(nextElement instanceof IBase)) { throw new IllegalArgumentException("Found element of "+nextElement.getClass()); } addElement(retVal, (IElement) nextElement, theType); } } else { throw new IllegalArgumentException("Found element of "+next.getClass()); } } return retVal; }
[ "public", "static", "<", "T", "extends", "IElement", ">", "List", "<", "T", ">", "allPopulatedChildElements", "(", "Class", "<", "T", ">", "theType", ",", "Object", "...", "theElements", ")", "{", "ArrayList", "<", "T", ">", "retVal", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "for", "(", "Object", "next", ":", "theElements", ")", "{", "if", "(", "next", "==", "null", ")", "{", "continue", ";", "}", "else", "if", "(", "next", "instanceof", "IElement", ")", "{", "addElement", "(", "retVal", ",", "(", "IElement", ")", "next", ",", "theType", ")", ";", "}", "else", "if", "(", "next", "instanceof", "List", ")", "{", "for", "(", "Object", "nextElement", ":", "(", "(", "List", "<", "?", ">", ")", "next", ")", ")", "{", "if", "(", "!", "(", "nextElement", "instanceof", "IBase", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Found element of \"", "+", "nextElement", ".", "getClass", "(", ")", ")", ";", "}", "addElement", "(", "retVal", ",", "(", "IElement", ")", "nextElement", ",", "theType", ")", ";", "}", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Found element of \"", "+", "next", ".", "getClass", "(", ")", ")", ";", "}", "}", "return", "retVal", ";", "}" ]
Note that this method does not work on HL7.org structures
[ "Note", "that", "this", "method", "does", "not", "work", "on", "HL7", ".", "org", "structures" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ElementUtil.java#L120-L140
22,610
jamesagnew/hapi-fhir
hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/CSVReader.java
CSVReader.parseLine
public String[] parseLine() throws IOException, FHIRException { List<String> res = new ArrayList<String>(); StringBuilder b = new StringBuilder(); boolean inQuote = false; while (inQuote || (peek() != '\r' && peek() != '\n')) { char c = peek(); next(); if (c == '"') inQuote = !inQuote; else if (!inQuote && c == ',') { res.add(b.toString().trim()); b = new StringBuilder(); } else b.append(c); } res.add(b.toString().trim()); while (ready() && (peek() == '\r' || peek() == '\n')) { next(); } String[] r = new String[] {}; r = res.toArray(r); return r; }
java
public String[] parseLine() throws IOException, FHIRException { List<String> res = new ArrayList<String>(); StringBuilder b = new StringBuilder(); boolean inQuote = false; while (inQuote || (peek() != '\r' && peek() != '\n')) { char c = peek(); next(); if (c == '"') inQuote = !inQuote; else if (!inQuote && c == ',') { res.add(b.toString().trim()); b = new StringBuilder(); } else b.append(c); } res.add(b.toString().trim()); while (ready() && (peek() == '\r' || peek() == '\n')) { next(); } String[] r = new String[] {}; r = res.toArray(r); return r; }
[ "public", "String", "[", "]", "parseLine", "(", ")", "throws", "IOException", ",", "FHIRException", "{", "List", "<", "String", ">", "res", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "StringBuilder", "b", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "inQuote", "=", "false", ";", "while", "(", "inQuote", "||", "(", "peek", "(", ")", "!=", "'", "'", "&&", "peek", "(", ")", "!=", "'", "'", ")", ")", "{", "char", "c", "=", "peek", "(", ")", ";", "next", "(", ")", ";", "if", "(", "c", "==", "'", "'", ")", "inQuote", "=", "!", "inQuote", ";", "else", "if", "(", "!", "inQuote", "&&", "c", "==", "'", "'", ")", "{", "res", ".", "add", "(", "b", ".", "toString", "(", ")", ".", "trim", "(", ")", ")", ";", "b", "=", "new", "StringBuilder", "(", ")", ";", "}", "else", "b", ".", "append", "(", "c", ")", ";", "}", "res", ".", "add", "(", "b", ".", "toString", "(", ")", ".", "trim", "(", ")", ")", ";", "while", "(", "ready", "(", ")", "&&", "(", "peek", "(", ")", "==", "'", "'", "||", "peek", "(", ")", "==", "'", "'", ")", ")", "{", "next", "(", ")", ";", "}", "String", "[", "]", "r", "=", "new", "String", "[", "]", "{", "}", ";", "r", "=", "res", ".", "toArray", "(", "r", ")", ";", "return", "r", ";", "}" ]
Split one line in a CSV file into its rows. Comma's appearing in double quoted strings will not be seen as a separator. @return @throws IOException @throws FHIRException @
[ "Split", "one", "line", "in", "a", "CSV", "file", "into", "its", "rows", ".", "Comma", "s", "appearing", "in", "double", "quoted", "strings", "will", "not", "be", "seen", "as", "a", "separator", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/CSVReader.java#L119-L145
22,611
jamesagnew/hapi-fhir
hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/client/ClientUtils.java
ClientUtils.unmarshalReference
@SuppressWarnings("unchecked") protected <T extends Resource> T unmarshalReference(HttpResponse response, String format) { T resource = null; OperationOutcome error = null; byte[] cnt = log(response); if (cnt != null) { try { resource = (T)getParser(format).parse(cnt); if (resource instanceof OperationOutcome && hasError((OperationOutcome)resource)) { error = (OperationOutcome) resource; } } catch(IOException ioe) { throw new EFhirClientException("Error reading Http Response: "+ioe.getMessage(), ioe); } catch(Exception e) { throw new EFhirClientException("Error parsing response message: "+e.getMessage(), e); } } if(error != null) { throw new EFhirClientException("Error from server: "+ResourceUtilities.getErrorDescription(error), error); } return resource; }
java
@SuppressWarnings("unchecked") protected <T extends Resource> T unmarshalReference(HttpResponse response, String format) { T resource = null; OperationOutcome error = null; byte[] cnt = log(response); if (cnt != null) { try { resource = (T)getParser(format).parse(cnt); if (resource instanceof OperationOutcome && hasError((OperationOutcome)resource)) { error = (OperationOutcome) resource; } } catch(IOException ioe) { throw new EFhirClientException("Error reading Http Response: "+ioe.getMessage(), ioe); } catch(Exception e) { throw new EFhirClientException("Error parsing response message: "+e.getMessage(), e); } } if(error != null) { throw new EFhirClientException("Error from server: "+ResourceUtilities.getErrorDescription(error), error); } return resource; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "<", "T", "extends", "Resource", ">", "T", "unmarshalReference", "(", "HttpResponse", "response", ",", "String", "format", ")", "{", "T", "resource", "=", "null", ";", "OperationOutcome", "error", "=", "null", ";", "byte", "[", "]", "cnt", "=", "log", "(", "response", ")", ";", "if", "(", "cnt", "!=", "null", ")", "{", "try", "{", "resource", "=", "(", "T", ")", "getParser", "(", "format", ")", ".", "parse", "(", "cnt", ")", ";", "if", "(", "resource", "instanceof", "OperationOutcome", "&&", "hasError", "(", "(", "OperationOutcome", ")", "resource", ")", ")", "{", "error", "=", "(", "OperationOutcome", ")", "resource", ";", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "EFhirClientException", "(", "\"Error reading Http Response: \"", "+", "ioe", ".", "getMessage", "(", ")", ",", "ioe", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "EFhirClientException", "(", "\"Error parsing response message: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}", "if", "(", "error", "!=", "null", ")", "{", "throw", "new", "EFhirClientException", "(", "\"Error from server: \"", "+", "ResourceUtilities", ".", "getErrorDescription", "(", "error", ")", ",", "error", ")", ";", "}", "return", "resource", ";", "}" ]
Unmarshals a resource from the response stream. @param response @return
[ "Unmarshals", "a", "resource", "from", "the", "response", "stream", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/client/ClientUtils.java#L324-L345
22,612
jamesagnew/hapi-fhir
hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/client/ClientUtils.java
ClientUtils.unmarshalFeed
protected Bundle unmarshalFeed(HttpResponse response, String format) { Bundle feed = null; byte[] cnt = log(response); String contentType = response.getHeaders("Content-Type")[0].getValue(); OperationOutcome error = null; try { if (cnt != null) { if(contentType.contains(ResourceFormat.RESOURCE_XML.getHeader()) || contentType.contains("text/xml+fhir")) { Resource rf = getParser(format).parse(cnt); if (rf instanceof Bundle) feed = (Bundle) rf; else if (rf instanceof OperationOutcome && hasError((OperationOutcome) rf)) { error = (OperationOutcome) rf; } else { throw new EFhirClientException("Error reading server response: a resource was returned instead"); } } } } catch(IOException ioe) { throw new EFhirClientException("Error reading Http Response", ioe); } catch(Exception e) { throw new EFhirClientException("Error parsing response message", e); } if(error != null) { throw new EFhirClientException("Error from server: "+ResourceUtilities.getErrorDescription(error), error); } return feed; }
java
protected Bundle unmarshalFeed(HttpResponse response, String format) { Bundle feed = null; byte[] cnt = log(response); String contentType = response.getHeaders("Content-Type")[0].getValue(); OperationOutcome error = null; try { if (cnt != null) { if(contentType.contains(ResourceFormat.RESOURCE_XML.getHeader()) || contentType.contains("text/xml+fhir")) { Resource rf = getParser(format).parse(cnt); if (rf instanceof Bundle) feed = (Bundle) rf; else if (rf instanceof OperationOutcome && hasError((OperationOutcome) rf)) { error = (OperationOutcome) rf; } else { throw new EFhirClientException("Error reading server response: a resource was returned instead"); } } } } catch(IOException ioe) { throw new EFhirClientException("Error reading Http Response", ioe); } catch(Exception e) { throw new EFhirClientException("Error parsing response message", e); } if(error != null) { throw new EFhirClientException("Error from server: "+ResourceUtilities.getErrorDescription(error), error); } return feed; }
[ "protected", "Bundle", "unmarshalFeed", "(", "HttpResponse", "response", ",", "String", "format", ")", "{", "Bundle", "feed", "=", "null", ";", "byte", "[", "]", "cnt", "=", "log", "(", "response", ")", ";", "String", "contentType", "=", "response", ".", "getHeaders", "(", "\"Content-Type\"", ")", "[", "0", "]", ".", "getValue", "(", ")", ";", "OperationOutcome", "error", "=", "null", ";", "try", "{", "if", "(", "cnt", "!=", "null", ")", "{", "if", "(", "contentType", ".", "contains", "(", "ResourceFormat", ".", "RESOURCE_XML", ".", "getHeader", "(", ")", ")", "||", "contentType", ".", "contains", "(", "\"text/xml+fhir\"", ")", ")", "{", "Resource", "rf", "=", "getParser", "(", "format", ")", ".", "parse", "(", "cnt", ")", ";", "if", "(", "rf", "instanceof", "Bundle", ")", "feed", "=", "(", "Bundle", ")", "rf", ";", "else", "if", "(", "rf", "instanceof", "OperationOutcome", "&&", "hasError", "(", "(", "OperationOutcome", ")", "rf", ")", ")", "{", "error", "=", "(", "OperationOutcome", ")", "rf", ";", "}", "else", "{", "throw", "new", "EFhirClientException", "(", "\"Error reading server response: a resource was returned instead\"", ")", ";", "}", "}", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "EFhirClientException", "(", "\"Error reading Http Response\"", ",", "ioe", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "EFhirClientException", "(", "\"Error parsing response message\"", ",", "e", ")", ";", "}", "if", "(", "error", "!=", "null", ")", "{", "throw", "new", "EFhirClientException", "(", "\"Error from server: \"", "+", "ResourceUtilities", ".", "getErrorDescription", "(", "error", ")", ",", "error", ")", ";", "}", "return", "feed", ";", "}" ]
Unmarshals Bundle from response stream. @param response @return
[ "Unmarshals", "Bundle", "from", "response", "stream", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/client/ClientUtils.java#L353-L380
22,613
jamesagnew/hapi-fhir
hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/client/ClientUtils.java
ClientUtils.writeInputStreamAsString
protected String writeInputStreamAsString(InputStream instream) { String value = null; try { value = IOUtils.toString(instream, "UTF-8"); System.out.println(value); } catch(IOException ioe) { //Do nothing } return value; }
java
protected String writeInputStreamAsString(InputStream instream) { String value = null; try { value = IOUtils.toString(instream, "UTF-8"); System.out.println(value); } catch(IOException ioe) { //Do nothing } return value; }
[ "protected", "String", "writeInputStreamAsString", "(", "InputStream", "instream", ")", "{", "String", "value", "=", "null", ";", "try", "{", "value", "=", "IOUtils", ".", "toString", "(", "instream", ",", "\"UTF-8\"", ")", ";", "System", ".", "out", ".", "println", "(", "value", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "//Do nothing\r", "}", "return", "value", ";", "}" ]
Used for debugging @param instream @return
[ "Used", "for", "debugging" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/utils/client/ClientUtils.java#L621-L631
22,614
jamesagnew/hapi-fhir
hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java
RestfulServerUtils.determineResponseEncodingNoDefault
public static ResponseEncoding determineResponseEncodingNoDefault(RequestDetails theReq, EncodingEnum thePrefer) { return determineResponseEncodingNoDefault(theReq, thePrefer, null); }
java
public static ResponseEncoding determineResponseEncodingNoDefault(RequestDetails theReq, EncodingEnum thePrefer) { return determineResponseEncodingNoDefault(theReq, thePrefer, null); }
[ "public", "static", "ResponseEncoding", "determineResponseEncodingNoDefault", "(", "RequestDetails", "theReq", ",", "EncodingEnum", "thePrefer", ")", "{", "return", "determineResponseEncodingNoDefault", "(", "theReq", ",", "thePrefer", ",", "null", ")", ";", "}" ]
Returns null if the request doesn't express that it wants FHIR. If it expresses that it wants XML and JSON equally, returns thePrefer.
[ "Returns", "null", "if", "the", "request", "doesn", "t", "express", "that", "it", "wants", "FHIR", ".", "If", "it", "expresses", "that", "it", "wants", "XML", "and", "JSON", "equally", "returns", "thePrefer", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java#L365-L367
22,615
jamesagnew/hapi-fhir
hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java
NpmPackage.list
public List<String> list(String folder) throws IOException { List<String> res = new ArrayList<String>(); if (path != null) { File f = new File(Utilities.path(path, folder)); if (f.exists() && f.isDirectory()) for (String s : f.list()) res.add(s); } else { for (String s : content.keySet()) { if (s.startsWith(folder+"/") && !s.substring(folder.length()+2).contains("/")) res.add(s.substring(folder.length()+1)); } } return res; }
java
public List<String> list(String folder) throws IOException { List<String> res = new ArrayList<String>(); if (path != null) { File f = new File(Utilities.path(path, folder)); if (f.exists() && f.isDirectory()) for (String s : f.list()) res.add(s); } else { for (String s : content.keySet()) { if (s.startsWith(folder+"/") && !s.substring(folder.length()+2).contains("/")) res.add(s.substring(folder.length()+1)); } } return res; }
[ "public", "List", "<", "String", ">", "list", "(", "String", "folder", ")", "throws", "IOException", "{", "List", "<", "String", ">", "res", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "path", "!=", "null", ")", "{", "File", "f", "=", "new", "File", "(", "Utilities", ".", "path", "(", "path", ",", "folder", ")", ")", ";", "if", "(", "f", ".", "exists", "(", ")", "&&", "f", ".", "isDirectory", "(", ")", ")", "for", "(", "String", "s", ":", "f", ".", "list", "(", ")", ")", "res", ".", "(", "s", ")", ";", "}", "else", "{", "for", "(", "String", "s", ":", "content", ".", "keySet", "(", ")", ")", "{", "if", "(", "s", ".", "startsWith", "(", "folder", "+", "\"/\"", ")", "&&", "!", "s", ".", "substring", "(", "folder", ".", "length", "(", ")", "+", "2", ")", ".", "contains", "(", "\"/\"", ")", ")", "res", ".", "add", "(", "s", ".", "substring", "(", "folder", ".", "length", "(", ")", "+", "1", ")", ")", ";", "}", "}", "return", "res", ";", "}" ]
Accessing the contents of the package - get a list of files in a subfolder of the package @param folder @return @throws IOException
[ "Accessing", "the", "contents", "of", "the", "package", "-", "get", "a", "list", "of", "files", "in", "a", "subfolder", "of", "the", "package" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java#L110-L124
22,616
jamesagnew/hapi-fhir
hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java
NpmPackage.load
public InputStream load(String folder, String file) throws IOException { if (content.containsKey(folder+"/"+file)) return new ByteArrayInputStream(content.get(folder+"/"+file)); else { File f = new File(Utilities.path(path, folder, file)); if (f.exists()) return new FileInputStream(f); throw new IOException("Unable to find the file "+folder+"/"+file+" in the package "+name()); } }
java
public InputStream load(String folder, String file) throws IOException { if (content.containsKey(folder+"/"+file)) return new ByteArrayInputStream(content.get(folder+"/"+file)); else { File f = new File(Utilities.path(path, folder, file)); if (f.exists()) return new FileInputStream(f); throw new IOException("Unable to find the file "+folder+"/"+file+" in the package "+name()); } }
[ "public", "InputStream", "load", "(", "String", "folder", ",", "String", "file", ")", "throws", "IOException", "{", "if", "(", "content", ".", "containsKey", "(", "folder", "+", "\"/\"", "+", "file", ")", ")", "return", "new", "ByteArrayInputStream", "(", "content", ".", "get", "(", "folder", "+", "\"/\"", "+", "file", ")", ")", ";", "else", "{", "File", "f", "=", "new", "File", "(", "Utilities", ".", "path", "(", "path", ",", "folder", ",", "file", ")", ")", ";", "if", "(", "f", ".", "exists", "(", ")", ")", "return", "new", "FileInputStream", "(", "f", ")", ";", "throw", "new", "IOException", "(", "\"Unable to find the file \"", "+", "folder", "+", "\"/\"", "+", "file", "+", "\" in the package \"", "+", "name", "(", ")", ")", ";", "}", "}" ]
get a stream that contains the contents of one of the files in a folder @param folder @param file @return @throws IOException
[ "get", "a", "stream", "that", "contains", "the", "contents", "of", "one", "of", "the", "files", "in", "a", "folder" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java#L173-L182
22,617
jamesagnew/hapi-fhir
hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java
NpmPackage.fhirVersion
public String fhirVersion() { if ("hl7.fhir.core".equals(npm.get("name").getAsString())) return npm.get("version").getAsString(); else return npm.getAsJsonObject("dependencies").get("hl7.fhir.core").getAsString(); }
java
public String fhirVersion() { if ("hl7.fhir.core".equals(npm.get("name").getAsString())) return npm.get("version").getAsString(); else return npm.getAsJsonObject("dependencies").get("hl7.fhir.core").getAsString(); }
[ "public", "String", "fhirVersion", "(", ")", "{", "if", "(", "\"hl7.fhir.core\"", ".", "equals", "(", "npm", ".", "get", "(", "\"name\"", ")", ".", "getAsString", "(", ")", ")", ")", "return", "npm", ".", "get", "(", "\"version\"", ")", ".", "getAsString", "(", ")", ";", "else", "return", "npm", ".", "getAsJsonObject", "(", "\"dependencies\"", ")", ".", "get", "(", "\"hl7.fhir.core\"", ")", ".", "getAsString", "(", ")", ";", "}" ]
convenience method for getting the package fhir version @return
[ "convenience", "method", "for", "getting", "the", "package", "fhir", "version" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java#L217-L222
22,618
jamesagnew/hapi-fhir
hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/BaseResourceIndexedSearchParam.java
BaseResourceIndexedSearchParam.hash
static long hash(String... theValues) { Hasher hasher = HASH_FUNCTION.newHasher(); for (String next : theValues) { if (next == null) { hasher.putByte((byte) 0); } else { next = UrlUtil.escapeUrlParam(next); byte[] bytes = next.getBytes(Charsets.UTF_8); hasher.putBytes(bytes); } hasher.putBytes(DELIMITER_BYTES); } HashCode hashCode = hasher.hash(); return hashCode.asLong(); }
java
static long hash(String... theValues) { Hasher hasher = HASH_FUNCTION.newHasher(); for (String next : theValues) { if (next == null) { hasher.putByte((byte) 0); } else { next = UrlUtil.escapeUrlParam(next); byte[] bytes = next.getBytes(Charsets.UTF_8); hasher.putBytes(bytes); } hasher.putBytes(DELIMITER_BYTES); } HashCode hashCode = hasher.hash(); return hashCode.asLong(); }
[ "static", "long", "hash", "(", "String", "...", "theValues", ")", "{", "Hasher", "hasher", "=", "HASH_FUNCTION", ".", "newHasher", "(", ")", ";", "for", "(", "String", "next", ":", "theValues", ")", "{", "if", "(", "next", "==", "null", ")", "{", "hasher", ".", "putByte", "(", "(", "byte", ")", "0", ")", ";", "}", "else", "{", "next", "=", "UrlUtil", ".", "escapeUrlParam", "(", "next", ")", ";", "byte", "[", "]", "bytes", "=", "next", ".", "getBytes", "(", "Charsets", ".", "UTF_8", ")", ";", "hasher", ".", "putBytes", "(", "bytes", ")", ";", "}", "hasher", ".", "putBytes", "(", "DELIMITER_BYTES", ")", ";", "}", "HashCode", "hashCode", "=", "hasher", ".", "hash", "(", ")", ";", "return", "hashCode", ".", "asLong", "(", ")", ";", "}" ]
Applies a fast and consistent hashing algorithm to a set of strings
[ "Applies", "a", "fast", "and", "consistent", "hashing", "algorithm", "to", "a", "set", "of", "strings" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/BaseResourceIndexedSearchParam.java#L139-L155
22,619
jamesagnew/hapi-fhir
hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TranslationRequest.java
TranslationRequest.addCode
public TranslationRequest addCode(String theSystem, String theCode) { Validate.notBlank(theSystem, "theSystem must not be null"); Validate.notBlank(theCode, "theCode must not be null"); if (getCodeableConcept() == null) { setCodeableConcept(new CodeableConcept()); } getCodeableConcept().addCoding(new Coding().setSystem(theSystem).setCode(theCode)); return this; }
java
public TranslationRequest addCode(String theSystem, String theCode) { Validate.notBlank(theSystem, "theSystem must not be null"); Validate.notBlank(theCode, "theCode must not be null"); if (getCodeableConcept() == null) { setCodeableConcept(new CodeableConcept()); } getCodeableConcept().addCoding(new Coding().setSystem(theSystem).setCode(theCode)); return this; }
[ "public", "TranslationRequest", "addCode", "(", "String", "theSystem", ",", "String", "theCode", ")", "{", "Validate", ".", "notBlank", "(", "theSystem", ",", "\"theSystem must not be null\"", ")", ";", "Validate", ".", "notBlank", "(", "theCode", ",", "\"theCode must not be null\"", ")", ";", "if", "(", "getCodeableConcept", "(", ")", "==", "null", ")", "{", "setCodeableConcept", "(", "new", "CodeableConcept", "(", ")", ")", ";", "}", "getCodeableConcept", "(", ")", ".", "addCoding", "(", "new", "Coding", "(", ")", ".", "setSystem", "(", "theSystem", ")", ".", "setCode", "(", "theCode", ")", ")", ";", "return", "this", ";", "}" ]
This is just a convenience method that creates a codeableconcept if one doesn't already exist, and adds a coding to it
[ "This", "is", "just", "a", "convenience", "method", "that", "creates", "a", "codeableconcept", "if", "one", "doesn", "t", "already", "exist", "and", "adds", "a", "coding", "to", "it" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TranslationRequest.java#L50-L58
22,620
jamesagnew/hapi-fhir
hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
FhirContext.getResourceNames
public Set<String> getResourceNames() { Set<String> resourceNames = new HashSet<>(); if (myNameToResourceDefinition.isEmpty()) { Properties props = new Properties(); try { props.load(myVersion.getFhirVersionPropertiesFile()); } catch (IOException theE) { throw new ConfigurationException("Failed to load version properties file"); } Enumeration<?> propNames = props.propertyNames(); while (propNames.hasMoreElements()) { String next = (String) propNames.nextElement(); if (next.startsWith("resource.")) { resourceNames.add(next.substring("resource.".length()).trim()); } } } for (RuntimeResourceDefinition next : myNameToResourceDefinition.values()) { resourceNames.add(next.getName()); } return Collections.unmodifiableSet(resourceNames); }
java
public Set<String> getResourceNames() { Set<String> resourceNames = new HashSet<>(); if (myNameToResourceDefinition.isEmpty()) { Properties props = new Properties(); try { props.load(myVersion.getFhirVersionPropertiesFile()); } catch (IOException theE) { throw new ConfigurationException("Failed to load version properties file"); } Enumeration<?> propNames = props.propertyNames(); while (propNames.hasMoreElements()) { String next = (String) propNames.nextElement(); if (next.startsWith("resource.")) { resourceNames.add(next.substring("resource.".length()).trim()); } } } for (RuntimeResourceDefinition next : myNameToResourceDefinition.values()) { resourceNames.add(next.getName()); } return Collections.unmodifiableSet(resourceNames); }
[ "public", "Set", "<", "String", ">", "getResourceNames", "(", ")", "{", "Set", "<", "String", ">", "resourceNames", "=", "new", "HashSet", "<>", "(", ")", ";", "if", "(", "myNameToResourceDefinition", ".", "isEmpty", "(", ")", ")", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "try", "{", "props", ".", "load", "(", "myVersion", ".", "getFhirVersionPropertiesFile", "(", ")", ")", ";", "}", "catch", "(", "IOException", "theE", ")", "{", "throw", "new", "ConfigurationException", "(", "\"Failed to load version properties file\"", ")", ";", "}", "Enumeration", "<", "?", ">", "propNames", "=", "props", ".", "propertyNames", "(", ")", ";", "while", "(", "propNames", ".", "hasMoreElements", "(", ")", ")", "{", "String", "next", "=", "(", "String", ")", "propNames", ".", "nextElement", "(", ")", ";", "if", "(", "next", ".", "startsWith", "(", "\"resource.\"", ")", ")", "{", "resourceNames", ".", "add", "(", "next", ".", "substring", "(", "\"resource.\"", ".", "length", "(", ")", ")", ".", "trim", "(", ")", ")", ";", "}", "}", "}", "for", "(", "RuntimeResourceDefinition", "next", ":", "myNameToResourceDefinition", ".", "values", "(", ")", ")", "{", "resourceNames", ".", "add", "(", "next", ".", "getName", "(", ")", ")", ";", "}", "return", "Collections", ".", "unmodifiableSet", "(", "resourceNames", ")", ";", "}" ]
Returns an unmodifiable set containing all resource names known to this context
[ "Returns", "an", "unmodifiable", "set", "containing", "all", "resource", "names", "known", "to", "this", "context" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java#L491-L515
22,621
jamesagnew/hapi-fhir
hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
FhirContext.getRestfulClientFactory
public IRestfulClientFactory getRestfulClientFactory() { if (myRestfulClientFactory == null) { try { myRestfulClientFactory = (IRestfulClientFactory) ReflectionUtil.newInstance(Class.forName("ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory"), FhirContext.class, this); } catch (ClassNotFoundException e) { throw new ConfigurationException("hapi-fhir-client does not appear to be on the classpath"); } } return myRestfulClientFactory; }
java
public IRestfulClientFactory getRestfulClientFactory() { if (myRestfulClientFactory == null) { try { myRestfulClientFactory = (IRestfulClientFactory) ReflectionUtil.newInstance(Class.forName("ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory"), FhirContext.class, this); } catch (ClassNotFoundException e) { throw new ConfigurationException("hapi-fhir-client does not appear to be on the classpath"); } } return myRestfulClientFactory; }
[ "public", "IRestfulClientFactory", "getRestfulClientFactory", "(", ")", "{", "if", "(", "myRestfulClientFactory", "==", "null", ")", "{", "try", "{", "myRestfulClientFactory", "=", "(", "IRestfulClientFactory", ")", "ReflectionUtil", ".", "newInstance", "(", "Class", ".", "forName", "(", "\"ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory\"", ")", ",", "FhirContext", ".", "class", ",", "this", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "ConfigurationException", "(", "\"hapi-fhir-client does not appear to be on the classpath\"", ")", ";", "}", "}", "return", "myRestfulClientFactory", ";", "}" ]
Get the restful client factory. If no factory has been set, this will be initialized with a new ApacheRestfulClientFactory. @return the factory used to create the restful clients
[ "Get", "the", "restful", "client", "factory", ".", "If", "no", "factory", "has", "been", "set", "this", "will", "be", "initialized", "with", "a", "new", "ApacheRestfulClientFactory", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java#L523-L532
22,622
jamesagnew/hapi-fhir
hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/api/HookParams.java
HookParams.getParamsForType
public ListMultimap<Class<?>, Object> getParamsForType() { ArrayListMultimap<Class<?>, Object> retVal = ArrayListMultimap.create(); myParams.entries().forEach(entry -> retVal.put(entry.getKey(), unwrapValue(entry.getValue()))); return Multimaps.unmodifiableListMultimap(retVal); }
java
public ListMultimap<Class<?>, Object> getParamsForType() { ArrayListMultimap<Class<?>, Object> retVal = ArrayListMultimap.create(); myParams.entries().forEach(entry -> retVal.put(entry.getKey(), unwrapValue(entry.getValue()))); return Multimaps.unmodifiableListMultimap(retVal); }
[ "public", "ListMultimap", "<", "Class", "<", "?", ">", ",", "Object", ">", "getParamsForType", "(", ")", "{", "ArrayListMultimap", "<", "Class", "<", "?", ">", ",", "Object", ">", "retVal", "=", "ArrayListMultimap", ".", "create", "(", ")", ";", "myParams", ".", "entries", "(", ")", ".", "forEach", "(", "entry", "->", "retVal", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "unwrapValue", "(", "entry", ".", "getValue", "(", ")", ")", ")", ")", ";", "return", "Multimaps", ".", "unmodifiableListMultimap", "(", "retVal", ")", ";", "}" ]
Returns an unmodifiable multimap of the params, where the key is the param type and the value is the actual instance
[ "Returns", "an", "unmodifiable", "multimap", "of", "the", "params", "where", "the", "key", "is", "the", "param", "type", "and", "the", "value", "is", "the", "actual", "instance" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/interceptor/api/HookParams.java#L107-L111
22,623
jamesagnew/hapi-fhir
hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/HistoryMethodBinding.java
HistoryMethodBinding.incomingServerRequestMatchesMethod
@Override public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) { if (!Constants.PARAM_HISTORY.equals(theRequest.getOperation())) { return false; } if (theRequest.getResourceName() == null) { return myResourceOperationType == RestOperationTypeEnum.HISTORY_SYSTEM; } if (!StringUtils.equals(theRequest.getResourceName(), myResourceName)) { return false; } boolean haveIdParam = theRequest.getId() != null && !theRequest.getId().isEmpty(); boolean wantIdParam = myIdParamIndex != null; if (haveIdParam != wantIdParam) { return false; } if (theRequest.getId() == null) { return myResourceOperationType == RestOperationTypeEnum.HISTORY_TYPE; } else if (theRequest.getId().hasVersionIdPart()) { return false; } return true; }
java
@Override public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) { if (!Constants.PARAM_HISTORY.equals(theRequest.getOperation())) { return false; } if (theRequest.getResourceName() == null) { return myResourceOperationType == RestOperationTypeEnum.HISTORY_SYSTEM; } if (!StringUtils.equals(theRequest.getResourceName(), myResourceName)) { return false; } boolean haveIdParam = theRequest.getId() != null && !theRequest.getId().isEmpty(); boolean wantIdParam = myIdParamIndex != null; if (haveIdParam != wantIdParam) { return false; } if (theRequest.getId() == null) { return myResourceOperationType == RestOperationTypeEnum.HISTORY_TYPE; } else if (theRequest.getId().hasVersionIdPart()) { return false; } return true; }
[ "@", "Override", "public", "boolean", "incomingServerRequestMatchesMethod", "(", "RequestDetails", "theRequest", ")", "{", "if", "(", "!", "Constants", ".", "PARAM_HISTORY", ".", "equals", "(", "theRequest", ".", "getOperation", "(", ")", ")", ")", "{", "return", "false", ";", "}", "if", "(", "theRequest", ".", "getResourceName", "(", ")", "==", "null", ")", "{", "return", "myResourceOperationType", "==", "RestOperationTypeEnum", ".", "HISTORY_SYSTEM", ";", "}", "if", "(", "!", "StringUtils", ".", "equals", "(", "theRequest", ".", "getResourceName", "(", ")", ",", "myResourceName", ")", ")", "{", "return", "false", ";", "}", "boolean", "haveIdParam", "=", "theRequest", ".", "getId", "(", ")", "!=", "null", "&&", "!", "theRequest", ".", "getId", "(", ")", ".", "isEmpty", "(", ")", ";", "boolean", "wantIdParam", "=", "myIdParamIndex", "!=", "null", ";", "if", "(", "haveIdParam", "!=", "wantIdParam", ")", "{", "return", "false", ";", "}", "if", "(", "theRequest", ".", "getId", "(", ")", "==", "null", ")", "{", "return", "myResourceOperationType", "==", "RestOperationTypeEnum", ".", "HISTORY_TYPE", ";", "}", "else", "if", "(", "theRequest", ".", "getId", "(", ")", ".", "hasVersionIdPart", "(", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
ObjectUtils.equals is replaced by a JDK7 method..
[ "ObjectUtils", ".", "equals", "is", "replaced", "by", "a", "JDK7", "method", ".." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/HistoryMethodBinding.java#L107-L132
22,624
jamesagnew/hapi-fhir
hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/BaseServerResponseException.java
BaseServerResponseException.addResponseHeader
public BaseServerResponseException addResponseHeader(String theName, String theValue) { Validate.notBlank(theName, "theName must not be null or empty"); Validate.notBlank(theValue, "theValue must not be null or empty"); if (getResponseHeaders().containsKey(theName) == false) { getResponseHeaders().put(theName, new ArrayList<>()); } getResponseHeaders().get(theName).add(theValue); return this; }
java
public BaseServerResponseException addResponseHeader(String theName, String theValue) { Validate.notBlank(theName, "theName must not be null or empty"); Validate.notBlank(theValue, "theValue must not be null or empty"); if (getResponseHeaders().containsKey(theName) == false) { getResponseHeaders().put(theName, new ArrayList<>()); } getResponseHeaders().get(theName).add(theValue); return this; }
[ "public", "BaseServerResponseException", "addResponseHeader", "(", "String", "theName", ",", "String", "theValue", ")", "{", "Validate", ".", "notBlank", "(", "theName", ",", "\"theName must not be null or empty\"", ")", ";", "Validate", ".", "notBlank", "(", "theValue", ",", "\"theValue must not be null or empty\"", ")", ";", "if", "(", "getResponseHeaders", "(", ")", ".", "containsKey", "(", "theName", ")", "==", "false", ")", "{", "getResponseHeaders", "(", ")", ".", "put", "(", "theName", ",", "new", "ArrayList", "<>", "(", ")", ")", ";", "}", "getResponseHeaders", "(", ")", ".", "get", "(", "theName", ")", ".", "add", "(", "theValue", ")", ";", "return", "this", ";", "}" ]
Add a header which will be added to any responses @param theName The header name @param theValue The header value @return Returns a reference to <code>this</code> for easy method chaining @since 2.0
[ "Add", "a", "header", "which", "will", "be", "added", "to", "any", "responses" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/BaseServerResponseException.java#L193-L201
22,625
jamesagnew/hapi-fhir
hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsBundleProvider.java
AbstractJaxRsBundleProvider.create
@POST public Response create(final String resource) throws IOException { return execute(getRequest(RequestTypeEnum.POST, RestOperationTypeEnum.TRANSACTION).resource(resource)); }
java
@POST public Response create(final String resource) throws IOException { return execute(getRequest(RequestTypeEnum.POST, RestOperationTypeEnum.TRANSACTION).resource(resource)); }
[ "@", "POST", "public", "Response", "create", "(", "final", "String", "resource", ")", "throws", "IOException", "{", "return", "execute", "(", "getRequest", "(", "RequestTypeEnum", ".", "POST", ",", "RestOperationTypeEnum", ".", "TRANSACTION", ")", ".", "resource", "(", "resource", ")", ")", ";", "}" ]
Create all resources in one transaction @param resource the body of the post method containing the bundle of the resources being created in a xml/json form @return the response @see <a href="https://www.hl7.org/fhir/http.html#create">https://www.hl7. org/fhir/http.html#create</a>
[ "Create", "all", "resources", "in", "one", "transaction" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsBundleProvider.java#L97-L101
22,626
jamesagnew/hapi-fhir
hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionTriggeringSvcImpl.java
SubscriptionTriggeringSvcImpl.setMaxSubmitPerPass
public void setMaxSubmitPerPass(Integer theMaxSubmitPerPass) { Integer maxSubmitPerPass = theMaxSubmitPerPass; if (maxSubmitPerPass == null) { maxSubmitPerPass = DEFAULT_MAX_SUBMIT; } Validate.isTrue(maxSubmitPerPass > 0, "theMaxSubmitPerPass must be > 0"); myMaxSubmitPerPass = maxSubmitPerPass; }
java
public void setMaxSubmitPerPass(Integer theMaxSubmitPerPass) { Integer maxSubmitPerPass = theMaxSubmitPerPass; if (maxSubmitPerPass == null) { maxSubmitPerPass = DEFAULT_MAX_SUBMIT; } Validate.isTrue(maxSubmitPerPass > 0, "theMaxSubmitPerPass must be > 0"); myMaxSubmitPerPass = maxSubmitPerPass; }
[ "public", "void", "setMaxSubmitPerPass", "(", "Integer", "theMaxSubmitPerPass", ")", "{", "Integer", "maxSubmitPerPass", "=", "theMaxSubmitPerPass", ";", "if", "(", "maxSubmitPerPass", "==", "null", ")", "{", "maxSubmitPerPass", "=", "DEFAULT_MAX_SUBMIT", ";", "}", "Validate", ".", "isTrue", "(", "maxSubmitPerPass", ">", "0", ",", "\"theMaxSubmitPerPass must be > 0\"", ")", ";", "myMaxSubmitPerPass", "=", "maxSubmitPerPass", ";", "}" ]
Sets the maximum number of resources that will be submitted in a single pass
[ "Sets", "the", "maximum", "number", "of", "resources", "that", "will", "be", "submitted", "in", "a", "single", "pass" ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/subscription/SubscriptionTriggeringSvcImpl.java#L334-L341
22,627
jamesagnew/hapi-fhir
hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/filters/Filter.java
Filter.checkParams
public final void checkParams(Object[] params, int expected) { if(params == null || params.length != expected) { throw new RuntimeException("Liquid error: wrong number of arguments (" + (params == null ? 0 : params.length + 1) + " for " + (expected + 1) + ")"); } }
java
public final void checkParams(Object[] params, int expected) { if(params == null || params.length != expected) { throw new RuntimeException("Liquid error: wrong number of arguments (" + (params == null ? 0 : params.length + 1) + " for " + (expected + 1) + ")"); } }
[ "public", "final", "void", "checkParams", "(", "Object", "[", "]", "params", ",", "int", "expected", ")", "{", "if", "(", "params", "==", "null", "||", "params", ".", "length", "!=", "expected", ")", "{", "throw", "new", "RuntimeException", "(", "\"Liquid error: wrong number of arguments (\"", "+", "(", "params", "==", "null", "?", "0", ":", "params", ".", "length", "+", "1", ")", "+", "\" for \"", "+", "(", "expected", "+", "1", ")", "+", "\")\"", ")", ";", "}", "}" ]
Check the number of parameters and throws an exception if needed. @param params the parameters to check. @param expected the expected number of parameters.
[ "Check", "the", "number", "of", "parameters", "and", "throws", "an", "exception", "if", "needed", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/filters/Filter.java#L102-L107
22,628
jamesagnew/hapi-fhir
hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/filters/Filter.java
Filter.get
protected Object get(int index, Object... params) { if (index >= params.length) { throw new RuntimeException("error in filter '" + name + "': cannot get param index: " + index + " from: " + Arrays.toString(params)); } return params[index]; }
java
protected Object get(int index, Object... params) { if (index >= params.length) { throw new RuntimeException("error in filter '" + name + "': cannot get param index: " + index + " from: " + Arrays.toString(params)); } return params[index]; }
[ "protected", "Object", "get", "(", "int", "index", ",", "Object", "...", "params", ")", "{", "if", "(", "index", ">=", "params", ".", "length", ")", "{", "throw", "new", "RuntimeException", "(", "\"error in filter '\"", "+", "name", "+", "\"': cannot get param index: \"", "+", "index", "+", "\" from: \"", "+", "Arrays", ".", "toString", "(", "params", ")", ")", ";", "}", "return", "params", "[", "index", "]", ";", "}" ]
Returns a value at a specific index from an array of parameters. If no such index exists, a RuntimeException is thrown. @param index the index of the value to be retrieved. @param params the values. @return a value at a specific index from an array of parameters.
[ "Returns", "a", "value", "at", "a", "specific", "index", "from", "an", "array", "of", "parameters", ".", "If", "no", "such", "index", "exists", "a", "RuntimeException", "is", "thrown", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/filters/Filter.java#L121-L130
22,629
jamesagnew/hapi-fhir
hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/SearchParamWithInlineReferencesExtractor.java
SearchParamWithInlineReferencesExtractor.extractInlineReferences
public void extractInlineReferences(IBaseResource theResource) { if (!myDaoConfig.isAllowInlineMatchUrlReferences()) { return; } FhirTerser terser = myContext.newTerser(); List<IBaseReference> allRefs = terser.getAllPopulatedChildElementsOfType(theResource, IBaseReference.class); for (IBaseReference nextRef : allRefs) { IIdType nextId = nextRef.getReferenceElement(); String nextIdText = nextId.getValue(); if (nextIdText == null) { continue; } int qmIndex = nextIdText.indexOf('?'); if (qmIndex != -1) { for (int i = qmIndex - 1; i >= 0; i--) { if (nextIdText.charAt(i) == '/') { if (i < nextIdText.length() - 1 && nextIdText.charAt(i + 1) == '?') { // Just in case the URL is in the form Patient/?foo=bar continue; } nextIdText = nextIdText.substring(i + 1); break; } } String resourceTypeString = nextIdText.substring(0, nextIdText.indexOf('?')).replace("/", ""); RuntimeResourceDefinition matchResourceDef = myContext.getResourceDefinition(resourceTypeString); if (matchResourceDef == null) { String msg = myContext.getLocalizer().getMessage(BaseHapiFhirDao.class, "invalidMatchUrlInvalidResourceType", nextId.getValue(), resourceTypeString); throw new InvalidRequestException(msg); } Class<? extends IBaseResource> matchResourceType = matchResourceDef.getImplementingClass(); Set<Long> matches = myMatchResourceUrlService.processMatchUrl(nextIdText, matchResourceType); if (matches.isEmpty()) { String msg = myContext.getLocalizer().getMessage(BaseHapiFhirDao.class, "invalidMatchUrlNoMatches", nextId.getValue()); throw new ResourceNotFoundException(msg); } if (matches.size() > 1) { String msg = myContext.getLocalizer().getMessage(BaseHapiFhirDao.class, "invalidMatchUrlMultipleMatches", nextId.getValue()); throw new PreconditionFailedException(msg); } Long next = matches.iterator().next(); String newId = myIdHelperService.translatePidIdToForcedId(resourceTypeString, next); ourLog.debug("Replacing inline match URL[{}] with ID[{}}", nextId.getValue(), newId); nextRef.setReference(newId); } } }
java
public void extractInlineReferences(IBaseResource theResource) { if (!myDaoConfig.isAllowInlineMatchUrlReferences()) { return; } FhirTerser terser = myContext.newTerser(); List<IBaseReference> allRefs = terser.getAllPopulatedChildElementsOfType(theResource, IBaseReference.class); for (IBaseReference nextRef : allRefs) { IIdType nextId = nextRef.getReferenceElement(); String nextIdText = nextId.getValue(); if (nextIdText == null) { continue; } int qmIndex = nextIdText.indexOf('?'); if (qmIndex != -1) { for (int i = qmIndex - 1; i >= 0; i--) { if (nextIdText.charAt(i) == '/') { if (i < nextIdText.length() - 1 && nextIdText.charAt(i + 1) == '?') { // Just in case the URL is in the form Patient/?foo=bar continue; } nextIdText = nextIdText.substring(i + 1); break; } } String resourceTypeString = nextIdText.substring(0, nextIdText.indexOf('?')).replace("/", ""); RuntimeResourceDefinition matchResourceDef = myContext.getResourceDefinition(resourceTypeString); if (matchResourceDef == null) { String msg = myContext.getLocalizer().getMessage(BaseHapiFhirDao.class, "invalidMatchUrlInvalidResourceType", nextId.getValue(), resourceTypeString); throw new InvalidRequestException(msg); } Class<? extends IBaseResource> matchResourceType = matchResourceDef.getImplementingClass(); Set<Long> matches = myMatchResourceUrlService.processMatchUrl(nextIdText, matchResourceType); if (matches.isEmpty()) { String msg = myContext.getLocalizer().getMessage(BaseHapiFhirDao.class, "invalidMatchUrlNoMatches", nextId.getValue()); throw new ResourceNotFoundException(msg); } if (matches.size() > 1) { String msg = myContext.getLocalizer().getMessage(BaseHapiFhirDao.class, "invalidMatchUrlMultipleMatches", nextId.getValue()); throw new PreconditionFailedException(msg); } Long next = matches.iterator().next(); String newId = myIdHelperService.translatePidIdToForcedId(resourceTypeString, next); ourLog.debug("Replacing inline match URL[{}] with ID[{}}", nextId.getValue(), newId); nextRef.setReference(newId); } } }
[ "public", "void", "extractInlineReferences", "(", "IBaseResource", "theResource", ")", "{", "if", "(", "!", "myDaoConfig", ".", "isAllowInlineMatchUrlReferences", "(", ")", ")", "{", "return", ";", "}", "FhirTerser", "terser", "=", "myContext", ".", "newTerser", "(", ")", ";", "List", "<", "IBaseReference", ">", "allRefs", "=", "terser", ".", "getAllPopulatedChildElementsOfType", "(", "theResource", ",", "IBaseReference", ".", "class", ")", ";", "for", "(", "IBaseReference", "nextRef", ":", "allRefs", ")", "{", "IIdType", "nextId", "=", "nextRef", ".", "getReferenceElement", "(", ")", ";", "String", "nextIdText", "=", "nextId", ".", "getValue", "(", ")", ";", "if", "(", "nextIdText", "==", "null", ")", "{", "continue", ";", "}", "int", "qmIndex", "=", "nextIdText", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "qmIndex", "!=", "-", "1", ")", "{", "for", "(", "int", "i", "=", "qmIndex", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "nextIdText", ".", "charAt", "(", "i", ")", "==", "'", "'", ")", "{", "if", "(", "i", "<", "nextIdText", ".", "length", "(", ")", "-", "1", "&&", "nextIdText", ".", "charAt", "(", "i", "+", "1", ")", "==", "'", "'", ")", "{", "// Just in case the URL is in the form Patient/?foo=bar", "continue", ";", "}", "nextIdText", "=", "nextIdText", ".", "substring", "(", "i", "+", "1", ")", ";", "break", ";", "}", "}", "String", "resourceTypeString", "=", "nextIdText", ".", "substring", "(", "0", ",", "nextIdText", ".", "indexOf", "(", "'", "'", ")", ")", ".", "replace", "(", "\"/\"", ",", "\"\"", ")", ";", "RuntimeResourceDefinition", "matchResourceDef", "=", "myContext", ".", "getResourceDefinition", "(", "resourceTypeString", ")", ";", "if", "(", "matchResourceDef", "==", "null", ")", "{", "String", "msg", "=", "myContext", ".", "getLocalizer", "(", ")", ".", "getMessage", "(", "BaseHapiFhirDao", ".", "class", ",", "\"invalidMatchUrlInvalidResourceType\"", ",", "nextId", ".", "getValue", "(", ")", ",", "resourceTypeString", ")", ";", "throw", "new", "InvalidRequestException", "(", "msg", ")", ";", "}", "Class", "<", "?", "extends", "IBaseResource", ">", "matchResourceType", "=", "matchResourceDef", ".", "getImplementingClass", "(", ")", ";", "Set", "<", "Long", ">", "matches", "=", "myMatchResourceUrlService", ".", "processMatchUrl", "(", "nextIdText", ",", "matchResourceType", ")", ";", "if", "(", "matches", ".", "isEmpty", "(", ")", ")", "{", "String", "msg", "=", "myContext", ".", "getLocalizer", "(", ")", ".", "getMessage", "(", "BaseHapiFhirDao", ".", "class", ",", "\"invalidMatchUrlNoMatches\"", ",", "nextId", ".", "getValue", "(", ")", ")", ";", "throw", "new", "ResourceNotFoundException", "(", "msg", ")", ";", "}", "if", "(", "matches", ".", "size", "(", ")", ">", "1", ")", "{", "String", "msg", "=", "myContext", ".", "getLocalizer", "(", ")", ".", "getMessage", "(", "BaseHapiFhirDao", ".", "class", ",", "\"invalidMatchUrlMultipleMatches\"", ",", "nextId", ".", "getValue", "(", ")", ")", ";", "throw", "new", "PreconditionFailedException", "(", "msg", ")", ";", "}", "Long", "next", "=", "matches", ".", "iterator", "(", ")", ".", "next", "(", ")", ";", "String", "newId", "=", "myIdHelperService", ".", "translatePidIdToForcedId", "(", "resourceTypeString", ",", "next", ")", ";", "ourLog", ".", "debug", "(", "\"Replacing inline match URL[{}] with ID[{}}\"", ",", "nextId", ".", "getValue", "(", ")", ",", "newId", ")", ";", "nextRef", ".", "setReference", "(", "newId", ")", ";", "}", "}", "}" ]
Handle references within the resource that are match URLs, for example references like "Patient?identifier=foo". These match URLs are resolved and replaced with the ID of the matching resource.
[ "Handle", "references", "within", "the", "resource", "that", "are", "match", "URLs", "for", "example", "references", "like", "Patient?identifier", "=", "foo", ".", "These", "match", "URLs", "are", "resolved", "and", "replaced", "with", "the", "ID", "of", "the", "matching", "resource", "." ]
150a84d52fe691b7f48fcb28247c4bddb7aec352
https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/SearchParamWithInlineReferencesExtractor.java#L209-L255
22,630
scribejava/scribejava
scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth20Service.java
OAuth20Service.getAccessTokenClientCredentialsGrant
public Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrant( OAuthAsyncRequestCallback<OAuth2AccessToken> callback) { final OAuthRequest request = createAccessTokenClientCredentialsGrantRequest(null); return sendAccessTokenRequestAsync(request, callback); }
java
public Future<OAuth2AccessToken> getAccessTokenClientCredentialsGrant( OAuthAsyncRequestCallback<OAuth2AccessToken> callback) { final OAuthRequest request = createAccessTokenClientCredentialsGrantRequest(null); return sendAccessTokenRequestAsync(request, callback); }
[ "public", "Future", "<", "OAuth2AccessToken", ">", "getAccessTokenClientCredentialsGrant", "(", "OAuthAsyncRequestCallback", "<", "OAuth2AccessToken", ">", "callback", ")", "{", "final", "OAuthRequest", "request", "=", "createAccessTokenClientCredentialsGrantRequest", "(", "null", ")", ";", "return", "sendAccessTokenRequestAsync", "(", "request", ",", "callback", ")", ";", "}" ]
Start the request to retrieve the access token using client-credentials grant. The optionally provided callback will be called with the Token when it is available. @param callback optional callback @return Future
[ "Start", "the", "request", "to", "retrieve", "the", "access", "token", "using", "client", "-", "credentials", "grant", ".", "The", "optionally", "provided", "callback", "will", "be", "called", "with", "the", "Token", "when", "it", "is", "available", "." ]
030d76872fe371a84b5d05c6c3c33c34e8f611f1
https://github.com/scribejava/scribejava/blob/030d76872fe371a84b5d05c6c3c33c34e8f611f1/scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth20Service.java#L266-L271
22,631
scribejava/scribejava
scribejava-core/src/main/java/com/github/scribejava/core/model/OAuthRequest.java
OAuthRequest.addOAuthParameter
public void addOAuthParameter(String key, String value) { oauthParameters.put(checkKey(key), value); }
java
public void addOAuthParameter(String key, String value) { oauthParameters.put(checkKey(key), value); }
[ "public", "void", "addOAuthParameter", "(", "String", "key", ",", "String", "value", ")", "{", "oauthParameters", ".", "put", "(", "checkKey", "(", "key", ")", ",", "value", ")", ";", "}" ]
Adds an OAuth parameter. @param key name of the parameter @param value value of the parameter @throws IllegalArgumentException if the parameter is not an OAuth parameter
[ "Adds", "an", "OAuth", "parameter", "." ]
030d76872fe371a84b5d05c6c3c33c34e8f611f1
https://github.com/scribejava/scribejava/blob/030d76872fe371a84b5d05c6c3c33c34e8f611f1/scribejava-core/src/main/java/com/github/scribejava/core/model/OAuthRequest.java#L58-L60
22,632
scribejava/scribejava
scribejava-core/src/main/java/com/github/scribejava/core/model/OAuthRequest.java
OAuthRequest.getSanitizedUrl
public String getSanitizedUrl() { if (url.startsWith("http://") && (url.endsWith(":80") || url.contains(":80/"))) { return url.replaceAll("\\?.*", "").replaceAll(":80", ""); } else if (url.startsWith("https://") && (url.endsWith(":443") || url.contains(":443/"))) { return url.replaceAll("\\?.*", "").replaceAll(":443", ""); } else { return url.replaceAll("\\?.*", ""); } }
java
public String getSanitizedUrl() { if (url.startsWith("http://") && (url.endsWith(":80") || url.contains(":80/"))) { return url.replaceAll("\\?.*", "").replaceAll(":80", ""); } else if (url.startsWith("https://") && (url.endsWith(":443") || url.contains(":443/"))) { return url.replaceAll("\\?.*", "").replaceAll(":443", ""); } else { return url.replaceAll("\\?.*", ""); } }
[ "public", "String", "getSanitizedUrl", "(", ")", "{", "if", "(", "url", ".", "startsWith", "(", "\"http://\"", ")", "&&", "(", "url", ".", "endsWith", "(", "\":80\"", ")", "||", "url", ".", "contains", "(", "\":80/\"", ")", ")", ")", "{", "return", "url", ".", "replaceAll", "(", "\"\\\\?.*\"", ",", "\"\"", ")", ".", "replaceAll", "(", "\":80\"", ",", "\"\"", ")", ";", "}", "else", "if", "(", "url", ".", "startsWith", "(", "\"https://\"", ")", "&&", "(", "url", ".", "endsWith", "(", "\":443\"", ")", "||", "url", ".", "contains", "(", "\":443/\"", ")", ")", ")", "{", "return", "url", ".", "replaceAll", "(", "\"\\\\?.*\"", ",", "\"\"", ")", ".", "replaceAll", "(", "\":443\"", ",", "\"\"", ")", ";", "}", "else", "{", "return", "url", ".", "replaceAll", "(", "\"\\\\?.*\"", ",", "\"\"", ")", ";", "}", "}" ]
Returns the URL without the port and the query string part. @return the OAuth-sanitized URL
[ "Returns", "the", "URL", "without", "the", "port", "and", "the", "query", "string", "part", "." ]
030d76872fe371a84b5d05c6c3c33c34e8f611f1
https://github.com/scribejava/scribejava/blob/030d76872fe371a84b5d05c6c3c33c34e8f611f1/scribejava-core/src/main/java/com/github/scribejava/core/model/OAuthRequest.java#L336-L344
22,633
scribejava/scribejava
scribejava-core/src/main/java/com/github/scribejava/core/utils/StreamUtils.java
StreamUtils.getStreamContents
public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { read = in.read(buffer, 0, buffer.length); if (read > 0) { out.append(buffer, 0, read); } } while (read >= 0); } return out.toString(); }
java
public static String getStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final char[] buffer = new char[0x10000]; final StringBuilder out = new StringBuilder(); try (Reader in = new InputStreamReader(is, "UTF-8")) { int read; do { read = in.read(buffer, 0, buffer.length); if (read > 0) { out.append(buffer, 0, read); } } while (read >= 0); } return out.toString(); }
[ "public", "static", "String", "getStreamContents", "(", "InputStream", "is", ")", "throws", "IOException", "{", "Preconditions", ".", "checkNotNull", "(", "is", ",", "\"Cannot get String from a null object\"", ")", ";", "final", "char", "[", "]", "buffer", "=", "new", "char", "[", "0x10000", "]", ";", "final", "StringBuilder", "out", "=", "new", "StringBuilder", "(", ")", ";", "try", "(", "Reader", "in", "=", "new", "InputStreamReader", "(", "is", ",", "\"UTF-8\"", ")", ")", "{", "int", "read", ";", "do", "{", "read", "=", "in", ".", "read", "(", "buffer", ",", "0", ",", "buffer", ".", "length", ")", ";", "if", "(", "read", ">", "0", ")", "{", "out", ".", "append", "(", "buffer", ",", "0", ",", "read", ")", ";", "}", "}", "while", "(", "read", ">=", "0", ")", ";", "}", "return", "out", ".", "toString", "(", ")", ";", "}" ]
Returns the stream contents as an UTF-8 encoded string @param is input stream @return string contents @throws java.io.IOException in any. SocketTimeout in example
[ "Returns", "the", "stream", "contents", "as", "an", "UTF", "-", "8", "encoded", "string" ]
030d76872fe371a84b5d05c6c3c33c34e8f611f1
https://github.com/scribejava/scribejava/blob/030d76872fe371a84b5d05c6c3c33c34e8f611f1/scribejava-core/src/main/java/com/github/scribejava/core/utils/StreamUtils.java#L21-L35
22,634
scribejava/scribejava
scribejava-core/src/main/java/com/github/scribejava/core/utils/StreamUtils.java
StreamUtils.getGzipStreamContents
public static String getGzipStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final GZIPInputStream gis = new GZIPInputStream(is); return getStreamContents(gis); }
java
public static String getGzipStreamContents(InputStream is) throws IOException { Preconditions.checkNotNull(is, "Cannot get String from a null object"); final GZIPInputStream gis = new GZIPInputStream(is); return getStreamContents(gis); }
[ "public", "static", "String", "getGzipStreamContents", "(", "InputStream", "is", ")", "throws", "IOException", "{", "Preconditions", ".", "checkNotNull", "(", "is", ",", "\"Cannot get String from a null object\"", ")", ";", "final", "GZIPInputStream", "gis", "=", "new", "GZIPInputStream", "(", "is", ")", ";", "return", "getStreamContents", "(", "gis", ")", ";", "}" ]
Return String content from a gzip stream @param is input stream @return string contents @throws java.io.IOException in any. SocketTimeout in example
[ "Return", "String", "content", "from", "a", "gzip", "stream" ]
030d76872fe371a84b5d05c6c3c33c34e8f611f1
https://github.com/scribejava/scribejava/blob/030d76872fe371a84b5d05c6c3c33c34e8f611f1/scribejava-core/src/main/java/com/github/scribejava/core/utils/StreamUtils.java#L44-L48
22,635
spotify/docker-maven-plugin
src/main/java/com/spotify/docker/Utils.java
Utils.pushImageTag
public static void pushImageTag(DockerClient docker, String imageName, List<String> imageTags, Log log, boolean skipPush) throws MojoExecutionException, DockerException, IOException, InterruptedException { if (skipPush) { log.info("Skipping docker push"); return; } // tags should not be empty if you have specified the option to push tags if (imageTags.isEmpty()) { throw new MojoExecutionException("You have used option \"pushImageTag\" but have" + " not specified an \"imageTag\" in your" + " docker-maven-client's plugin configuration"); } final CompositeImageName compositeImageName = CompositeImageName.create(imageName, imageTags); for (final String imageTag : compositeImageName.getImageTags()) { final String imageNameWithTag = compositeImageName.getName() + ":" + imageTag; log.info("Pushing " + imageNameWithTag); docker.push(imageNameWithTag, new AnsiProgressHandler()); } }
java
public static void pushImageTag(DockerClient docker, String imageName, List<String> imageTags, Log log, boolean skipPush) throws MojoExecutionException, DockerException, IOException, InterruptedException { if (skipPush) { log.info("Skipping docker push"); return; } // tags should not be empty if you have specified the option to push tags if (imageTags.isEmpty()) { throw new MojoExecutionException("You have used option \"pushImageTag\" but have" + " not specified an \"imageTag\" in your" + " docker-maven-client's plugin configuration"); } final CompositeImageName compositeImageName = CompositeImageName.create(imageName, imageTags); for (final String imageTag : compositeImageName.getImageTags()) { final String imageNameWithTag = compositeImageName.getName() + ":" + imageTag; log.info("Pushing " + imageNameWithTag); docker.push(imageNameWithTag, new AnsiProgressHandler()); } }
[ "public", "static", "void", "pushImageTag", "(", "DockerClient", "docker", ",", "String", "imageName", ",", "List", "<", "String", ">", "imageTags", ",", "Log", "log", ",", "boolean", "skipPush", ")", "throws", "MojoExecutionException", ",", "DockerException", ",", "IOException", ",", "InterruptedException", "{", "if", "(", "skipPush", ")", "{", "log", ".", "info", "(", "\"Skipping docker push\"", ")", ";", "return", ";", "}", "// tags should not be empty if you have specified the option to push tags", "if", "(", "imageTags", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"You have used option \\\"pushImageTag\\\" but have\"", "+", "\" not specified an \\\"imageTag\\\" in your\"", "+", "\" docker-maven-client's plugin configuration\"", ")", ";", "}", "final", "CompositeImageName", "compositeImageName", "=", "CompositeImageName", ".", "create", "(", "imageName", ",", "imageTags", ")", ";", "for", "(", "final", "String", "imageTag", ":", "compositeImageName", ".", "getImageTags", "(", ")", ")", "{", "final", "String", "imageNameWithTag", "=", "compositeImageName", ".", "getName", "(", ")", "+", "\":\"", "+", "imageTag", ";", "log", ".", "info", "(", "\"Pushing \"", "+", "imageNameWithTag", ")", ";", "docker", ".", "push", "(", "imageNameWithTag", ",", "new", "AnsiProgressHandler", "(", ")", ")", ";", "}", "}" ]
push just the tags listed in the pom rather than all images using imageName
[ "push", "just", "the", "tags", "listed", "in", "the", "pom", "rather", "than", "all", "images", "using", "imageName" ]
c5bbc1c4993f5dc37c96457fa5de5af8308f7829
https://github.com/spotify/docker-maven-plugin/blob/c5bbc1c4993f5dc37c96457fa5de5af8308f7829/src/main/java/com/spotify/docker/Utils.java#L134-L154
22,636
spotify/docker-maven-plugin
src/main/java/com/spotify/docker/AbstractDockerMojo.java
AbstractDockerMojo.registryAuth
protected RegistryAuth registryAuth() throws MojoExecutionException { if (settings != null && serverId != null) { final Server server = settings.getServer(serverId); if (server != null) { final RegistryAuth.Builder registryAuthBuilder = RegistryAuth.builder(); final String username = server.getUsername(); String password = server.getPassword(); if (secDispatcher != null) { try { password = secDispatcher.decrypt(password); } catch (SecDispatcherException ex) { throw new MojoExecutionException("Cannot decrypt password from settings", ex); } } final String email = getEmail(server); if (!isNullOrEmpty(username)) { registryAuthBuilder.username(username); } if (!isNullOrEmpty(email)) { registryAuthBuilder.email(email); } if (!isNullOrEmpty(password)) { registryAuthBuilder.password(password); } if (!isNullOrEmpty(registryUrl)) { registryAuthBuilder.serverAddress(registryUrl); } return registryAuthBuilder.build(); } else { // settings.xml has no entry for the configured serverId, warn the user getLog().warn("No entry found in settings.xml for serverId=" + serverId + ", cannot configure authentication for that registry"); } } return null; }
java
protected RegistryAuth registryAuth() throws MojoExecutionException { if (settings != null && serverId != null) { final Server server = settings.getServer(serverId); if (server != null) { final RegistryAuth.Builder registryAuthBuilder = RegistryAuth.builder(); final String username = server.getUsername(); String password = server.getPassword(); if (secDispatcher != null) { try { password = secDispatcher.decrypt(password); } catch (SecDispatcherException ex) { throw new MojoExecutionException("Cannot decrypt password from settings", ex); } } final String email = getEmail(server); if (!isNullOrEmpty(username)) { registryAuthBuilder.username(username); } if (!isNullOrEmpty(email)) { registryAuthBuilder.email(email); } if (!isNullOrEmpty(password)) { registryAuthBuilder.password(password); } if (!isNullOrEmpty(registryUrl)) { registryAuthBuilder.serverAddress(registryUrl); } return registryAuthBuilder.build(); } else { // settings.xml has no entry for the configured serverId, warn the user getLog().warn("No entry found in settings.xml for serverId=" + serverId + ", cannot configure authentication for that registry"); } } return null; }
[ "protected", "RegistryAuth", "registryAuth", "(", ")", "throws", "MojoExecutionException", "{", "if", "(", "settings", "!=", "null", "&&", "serverId", "!=", "null", ")", "{", "final", "Server", "server", "=", "settings", ".", "getServer", "(", "serverId", ")", ";", "if", "(", "server", "!=", "null", ")", "{", "final", "RegistryAuth", ".", "Builder", "registryAuthBuilder", "=", "RegistryAuth", ".", "builder", "(", ")", ";", "final", "String", "username", "=", "server", ".", "getUsername", "(", ")", ";", "String", "password", "=", "server", ".", "getPassword", "(", ")", ";", "if", "(", "secDispatcher", "!=", "null", ")", "{", "try", "{", "password", "=", "secDispatcher", ".", "decrypt", "(", "password", ")", ";", "}", "catch", "(", "SecDispatcherException", "ex", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Cannot decrypt password from settings\"", ",", "ex", ")", ";", "}", "}", "final", "String", "email", "=", "getEmail", "(", "server", ")", ";", "if", "(", "!", "isNullOrEmpty", "(", "username", ")", ")", "{", "registryAuthBuilder", ".", "username", "(", "username", ")", ";", "}", "if", "(", "!", "isNullOrEmpty", "(", "email", ")", ")", "{", "registryAuthBuilder", ".", "email", "(", "email", ")", ";", "}", "if", "(", "!", "isNullOrEmpty", "(", "password", ")", ")", "{", "registryAuthBuilder", ".", "password", "(", "password", ")", ";", "}", "if", "(", "!", "isNullOrEmpty", "(", "registryUrl", ")", ")", "{", "registryAuthBuilder", ".", "serverAddress", "(", "registryUrl", ")", ";", "}", "return", "registryAuthBuilder", ".", "build", "(", ")", ";", "}", "else", "{", "// settings.xml has no entry for the configured serverId, warn the user", "getLog", "(", ")", ".", "warn", "(", "\"No entry found in settings.xml for serverId=\"", "+", "serverId", "+", "\", cannot configure authentication for that registry\"", ")", ";", "}", "}", "return", "null", ";", "}" ]
Builds the registryAuth object from server details. @return {@link RegistryAuth} @throws MojoExecutionException
[ "Builds", "the", "registryAuth", "object", "from", "server", "details", "." ]
c5bbc1c4993f5dc37c96457fa5de5af8308f7829
https://github.com/spotify/docker-maven-plugin/blob/c5bbc1c4993f5dc37c96457fa5de5af8308f7829/src/main/java/com/spotify/docker/AbstractDockerMojo.java#L239-L277
22,637
uber/AutoDispose
autodispose/src/main/java/com/uber/autodispose/AutoDisposeEndConsumerHelper.java
AutoDisposeEndConsumerHelper.setOnce
public static boolean setOnce(AtomicReference<Disposable> upstream, Disposable next, Class<?> observer) { AutoDisposeUtil.checkNotNull(next, "next is null"); if (!upstream.compareAndSet(null, next)) { next.dispose(); if (upstream.get() != AutoDisposableHelper.DISPOSED) { reportDoubleSubscription(observer); } return false; } return true; }
java
public static boolean setOnce(AtomicReference<Disposable> upstream, Disposable next, Class<?> observer) { AutoDisposeUtil.checkNotNull(next, "next is null"); if (!upstream.compareAndSet(null, next)) { next.dispose(); if (upstream.get() != AutoDisposableHelper.DISPOSED) { reportDoubleSubscription(observer); } return false; } return true; }
[ "public", "static", "boolean", "setOnce", "(", "AtomicReference", "<", "Disposable", ">", "upstream", ",", "Disposable", "next", ",", "Class", "<", "?", ">", "observer", ")", "{", "AutoDisposeUtil", ".", "checkNotNull", "(", "next", ",", "\"next is null\"", ")", ";", "if", "(", "!", "upstream", ".", "compareAndSet", "(", "null", ",", "next", ")", ")", "{", "next", ".", "dispose", "(", ")", ";", "if", "(", "upstream", ".", "get", "(", ")", "!=", "AutoDisposableHelper", ".", "DISPOSED", ")", "{", "reportDoubleSubscription", "(", "observer", ")", ";", "}", "return", "false", ";", "}", "return", "true", ";", "}" ]
Atomically updates the target upstream AtomicReference from null to the non-null next Disposable, otherwise disposes next and reports a ProtocolViolationException if the AtomicReference doesn't contain the shared disposed indicator. @param upstream the target AtomicReference to update @param next the Disposable to set on it atomically @param observer the class of the consumer to have a personalized error message if the upstream already contains a non-cancelled Disposable. @return true if successful, false if the content of the AtomicReference was non null
[ "Atomically", "updates", "the", "target", "upstream", "AtomicReference", "from", "null", "to", "the", "non", "-", "null", "next", "Disposable", "otherwise", "disposes", "next", "and", "reports", "a", "ProtocolViolationException", "if", "the", "AtomicReference", "doesn", "t", "contain", "the", "shared", "disposed", "indicator", "." ]
1115b0274f7960354289bb3ae7ba75b0c5a47457
https://github.com/uber/AutoDispose/blob/1115b0274f7960354289bb3ae7ba75b0c5a47457/autodispose/src/main/java/com/uber/autodispose/AutoDisposeEndConsumerHelper.java#L50-L60
22,638
uber/AutoDispose
autodispose/src/main/java/com/uber/autodispose/AutoDisposeEndConsumerHelper.java
AutoDisposeEndConsumerHelper.setOnce
public static boolean setOnce(AtomicReference<Subscription> upstream, Subscription next, Class<?> subscriber) { AutoDisposeUtil.checkNotNull(next, "next is null"); if (!upstream.compareAndSet(null, next)) { next.cancel(); if (upstream.get() != AutoSubscriptionHelper.CANCELLED) { reportDoubleSubscription(subscriber); } return false; } return true; }
java
public static boolean setOnce(AtomicReference<Subscription> upstream, Subscription next, Class<?> subscriber) { AutoDisposeUtil.checkNotNull(next, "next is null"); if (!upstream.compareAndSet(null, next)) { next.cancel(); if (upstream.get() != AutoSubscriptionHelper.CANCELLED) { reportDoubleSubscription(subscriber); } return false; } return true; }
[ "public", "static", "boolean", "setOnce", "(", "AtomicReference", "<", "Subscription", ">", "upstream", ",", "Subscription", "next", ",", "Class", "<", "?", ">", "subscriber", ")", "{", "AutoDisposeUtil", ".", "checkNotNull", "(", "next", ",", "\"next is null\"", ")", ";", "if", "(", "!", "upstream", ".", "compareAndSet", "(", "null", ",", "next", ")", ")", "{", "next", ".", "cancel", "(", ")", ";", "if", "(", "upstream", ".", "get", "(", ")", "!=", "AutoSubscriptionHelper", ".", "CANCELLED", ")", "{", "reportDoubleSubscription", "(", "subscriber", ")", ";", "}", "return", "false", ";", "}", "return", "true", ";", "}" ]
Atomically updates the target upstream AtomicReference from null to the non-null next Subscription, otherwise cancels next and reports a ProtocolViolationException if the AtomicReference doesn't contain the shared cancelled indicator. @param upstream the target AtomicReference to update @param next the Subscription to set on it atomically @param subscriber the class of the consumer to have a personalized error message if the upstream already contains a non-cancelled Subscription. @return true if successful, false if the content of the AtomicReference was non null
[ "Atomically", "updates", "the", "target", "upstream", "AtomicReference", "from", "null", "to", "the", "non", "-", "null", "next", "Subscription", "otherwise", "cancels", "next", "and", "reports", "a", "ProtocolViolationException", "if", "the", "AtomicReference", "doesn", "t", "contain", "the", "shared", "cancelled", "indicator", "." ]
1115b0274f7960354289bb3ae7ba75b0c5a47457
https://github.com/uber/AutoDispose/blob/1115b0274f7960354289bb3ae7ba75b0c5a47457/autodispose/src/main/java/com/uber/autodispose/AutoDisposeEndConsumerHelper.java#L73-L83
22,639
uber/AutoDispose
lifecycle/autodispose-lifecycle/src/main/java/com/uber/autodispose/lifecycle/LifecycleScopes.java
LifecycleScopes.resolveScopeFromLifecycle
public static <E> CompletableSource resolveScopeFromLifecycle( final LifecycleScopeProvider<E> provider) throws OutsideScopeException { return resolveScopeFromLifecycle(provider, true); }
java
public static <E> CompletableSource resolveScopeFromLifecycle( final LifecycleScopeProvider<E> provider) throws OutsideScopeException { return resolveScopeFromLifecycle(provider, true); }
[ "public", "static", "<", "E", ">", "CompletableSource", "resolveScopeFromLifecycle", "(", "final", "LifecycleScopeProvider", "<", "E", ">", "provider", ")", "throws", "OutsideScopeException", "{", "return", "resolveScopeFromLifecycle", "(", "provider", ",", "true", ")", ";", "}" ]
Overload for resolving lifecycle providers that defaults to checking start and end boundaries of lifecycles. That is, they will ensure that the lifecycle has both started and not ended. <p><em>Note:</em> This resolves the scope immediately, so consider deferring execution as needed, such as using {@link Completable#defer(Callable) defer}. @param provider the {@link LifecycleScopeProvider} to resolve. @param <E> the lifecycle event type @return a resolved {@link CompletableSource} representation of a given provider @throws OutsideScopeException if the {@link LifecycleScopeProvider#correspondingEvents()} throws an {@link OutsideScopeException} during resolution.
[ "Overload", "for", "resolving", "lifecycle", "providers", "that", "defaults", "to", "checking", "start", "and", "end", "boundaries", "of", "lifecycles", ".", "That", "is", "they", "will", "ensure", "that", "the", "lifecycle", "has", "both", "started", "and", "not", "ended", "." ]
1115b0274f7960354289bb3ae7ba75b0c5a47457
https://github.com/uber/AutoDispose/blob/1115b0274f7960354289bb3ae7ba75b0c5a47457/lifecycle/autodispose-lifecycle/src/main/java/com/uber/autodispose/lifecycle/LifecycleScopes.java#L54-L57
22,640
uber/AutoDispose
static-analysis/autodispose-error-prone/src/main/java/com/uber/autodispose/errorprone/AbstractReturnValueIgnored.java
AbstractReturnValueIgnored.describe
private Description describe(MethodInvocationTree methodInvocationTree, VisitorState state) { // Find the root of the field access chain, i.e. a.intern().trim() ==> a. ExpressionTree identifierExpr = ASTHelpers.getRootAssignable(methodInvocationTree); String identifierStr = null; Type identifierType = null; if (identifierExpr != null) { identifierStr = state.getSourceForNode(identifierExpr); if (identifierExpr instanceof JCIdent) { identifierType = ((JCIdent) identifierExpr).sym.type; } else if (identifierExpr instanceof JCFieldAccess) { identifierType = ((JCFieldAccess) identifierExpr).sym.type; } else { throw new IllegalStateException("Expected a JCIdent or a JCFieldAccess"); } } Type returnType = getReturnType(((JCMethodInvocation) methodInvocationTree).getMethodSelect()); Fix fix; if (identifierStr != null && !"this".equals(identifierStr) && returnType != null && state.getTypes().isAssignable(returnType, identifierType)) { // Fix by assigning the assigning the result of the call to the root receiver reference. fix = SuggestedFix.prefixWith(methodInvocationTree, identifierStr + " = "); } else { // Unclear what the programmer intended. Delete since we don't know what else to do. Tree parent = state.getPath().getParentPath().getLeaf(); fix = SuggestedFix.delete(parent); } return describeMatch(methodInvocationTree, fix); }
java
private Description describe(MethodInvocationTree methodInvocationTree, VisitorState state) { // Find the root of the field access chain, i.e. a.intern().trim() ==> a. ExpressionTree identifierExpr = ASTHelpers.getRootAssignable(methodInvocationTree); String identifierStr = null; Type identifierType = null; if (identifierExpr != null) { identifierStr = state.getSourceForNode(identifierExpr); if (identifierExpr instanceof JCIdent) { identifierType = ((JCIdent) identifierExpr).sym.type; } else if (identifierExpr instanceof JCFieldAccess) { identifierType = ((JCFieldAccess) identifierExpr).sym.type; } else { throw new IllegalStateException("Expected a JCIdent or a JCFieldAccess"); } } Type returnType = getReturnType(((JCMethodInvocation) methodInvocationTree).getMethodSelect()); Fix fix; if (identifierStr != null && !"this".equals(identifierStr) && returnType != null && state.getTypes().isAssignable(returnType, identifierType)) { // Fix by assigning the assigning the result of the call to the root receiver reference. fix = SuggestedFix.prefixWith(methodInvocationTree, identifierStr + " = "); } else { // Unclear what the programmer intended. Delete since we don't know what else to do. Tree parent = state.getPath().getParentPath().getLeaf(); fix = SuggestedFix.delete(parent); } return describeMatch(methodInvocationTree, fix); }
[ "private", "Description", "describe", "(", "MethodInvocationTree", "methodInvocationTree", ",", "VisitorState", "state", ")", "{", "// Find the root of the field access chain, i.e. a.intern().trim() ==> a.", "ExpressionTree", "identifierExpr", "=", "ASTHelpers", ".", "getRootAssignable", "(", "methodInvocationTree", ")", ";", "String", "identifierStr", "=", "null", ";", "Type", "identifierType", "=", "null", ";", "if", "(", "identifierExpr", "!=", "null", ")", "{", "identifierStr", "=", "state", ".", "getSourceForNode", "(", "identifierExpr", ")", ";", "if", "(", "identifierExpr", "instanceof", "JCIdent", ")", "{", "identifierType", "=", "(", "(", "JCIdent", ")", "identifierExpr", ")", ".", "sym", ".", "type", ";", "}", "else", "if", "(", "identifierExpr", "instanceof", "JCFieldAccess", ")", "{", "identifierType", "=", "(", "(", "JCFieldAccess", ")", "identifierExpr", ")", ".", "sym", ".", "type", ";", "}", "else", "{", "throw", "new", "IllegalStateException", "(", "\"Expected a JCIdent or a JCFieldAccess\"", ")", ";", "}", "}", "Type", "returnType", "=", "getReturnType", "(", "(", "(", "JCMethodInvocation", ")", "methodInvocationTree", ")", ".", "getMethodSelect", "(", ")", ")", ";", "Fix", "fix", ";", "if", "(", "identifierStr", "!=", "null", "&&", "!", "\"this\"", ".", "equals", "(", "identifierStr", ")", "&&", "returnType", "!=", "null", "&&", "state", ".", "getTypes", "(", ")", ".", "isAssignable", "(", "returnType", ",", "identifierType", ")", ")", "{", "// Fix by assigning the assigning the result of the call to the root receiver reference.", "fix", "=", "SuggestedFix", ".", "prefixWith", "(", "methodInvocationTree", ",", "identifierStr", "+", "\" = \"", ")", ";", "}", "else", "{", "// Unclear what the programmer intended. Delete since we don't know what else to do.", "Tree", "parent", "=", "state", ".", "getPath", "(", ")", ".", "getParentPath", "(", ")", ".", "getLeaf", "(", ")", ";", "fix", "=", "SuggestedFix", ".", "delete", "(", "parent", ")", ";", "}", "return", "describeMatch", "(", "methodInvocationTree", ",", "fix", ")", ";", "}" ]
Fixes the error by assigning the result of the call to the receiver reference, or deleting the method call.
[ "Fixes", "the", "error", "by", "assigning", "the", "result", "of", "the", "call", "to", "the", "receiver", "reference", "or", "deleting", "the", "method", "call", "." ]
1115b0274f7960354289bb3ae7ba75b0c5a47457
https://github.com/uber/AutoDispose/blob/1115b0274f7960354289bb3ae7ba75b0c5a47457/static-analysis/autodispose-error-prone/src/main/java/com/uber/autodispose/errorprone/AbstractReturnValueIgnored.java#L262-L293
22,641
uber/AutoDispose
autodispose/src/main/java/com/uber/autodispose/HalfSerializer.java
HalfSerializer.onNext
public static <T> boolean onNext(Subscriber<? super T> subscriber, T value, AtomicInteger wip, AtomicThrowable error) { if (wip.get() == 0 && wip.compareAndSet(0, 1)) { subscriber.onNext(value); if (wip.decrementAndGet() != 0) { Throwable ex = error.terminate(); if (ex != null) { subscriber.onError(ex); } else { subscriber.onComplete(); } return true; } } return false; }
java
public static <T> boolean onNext(Subscriber<? super T> subscriber, T value, AtomicInteger wip, AtomicThrowable error) { if (wip.get() == 0 && wip.compareAndSet(0, 1)) { subscriber.onNext(value); if (wip.decrementAndGet() != 0) { Throwable ex = error.terminate(); if (ex != null) { subscriber.onError(ex); } else { subscriber.onComplete(); } return true; } } return false; }
[ "public", "static", "<", "T", ">", "boolean", "onNext", "(", "Subscriber", "<", "?", "super", "T", ">", "subscriber", ",", "T", "value", ",", "AtomicInteger", "wip", ",", "AtomicThrowable", "error", ")", "{", "if", "(", "wip", ".", "get", "(", ")", "==", "0", "&&", "wip", ".", "compareAndSet", "(", "0", ",", "1", ")", ")", "{", "subscriber", ".", "onNext", "(", "value", ")", ";", "if", "(", "wip", ".", "decrementAndGet", "(", ")", "!=", "0", ")", "{", "Throwable", "ex", "=", "error", ".", "terminate", "(", ")", ";", "if", "(", "ex", "!=", "null", ")", "{", "subscriber", ".", "onError", "(", "ex", ")", ";", "}", "else", "{", "subscriber", ".", "onComplete", "(", ")", ";", "}", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Emits the given value if possible and terminates if there was an onComplete or onError while emitting, drops the value otherwise. @param <T> the value type @param subscriber the target Subscriber to emit to @param value the value to emit @param wip the serialization work-in-progress counter/indicator @param error the holder of Throwables @return true if a terminal event was emitted to {@code observer}, false if not
[ "Emits", "the", "given", "value", "if", "possible", "and", "terminates", "if", "there", "was", "an", "onComplete", "or", "onError", "while", "emitting", "drops", "the", "value", "otherwise", "." ]
1115b0274f7960354289bb3ae7ba75b0c5a47457
https://github.com/uber/AutoDispose/blob/1115b0274f7960354289bb3ae7ba75b0c5a47457/autodispose/src/main/java/com/uber/autodispose/HalfSerializer.java#L50-L67
22,642
drewnoakes/metadata-extractor
Source/com/drew/metadata/Metadata.java
Metadata.containsDirectoryOfType
public boolean containsDirectoryOfType(Class<? extends Directory> type) { for (Directory dir : _directories) { if (type.isAssignableFrom(dir.getClass())) return true; } return false; }
java
public boolean containsDirectoryOfType(Class<? extends Directory> type) { for (Directory dir : _directories) { if (type.isAssignableFrom(dir.getClass())) return true; } return false; }
[ "public", "boolean", "containsDirectoryOfType", "(", "Class", "<", "?", "extends", "Directory", ">", "type", ")", "{", "for", "(", "Directory", "dir", ":", "_directories", ")", "{", "if", "(", "type", ".", "isAssignableFrom", "(", "dir", ".", "getClass", "(", ")", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Indicates whether an instance of the given directory type exists in this Metadata instance. @param type the {@link Directory} type @return <code>true</code> if a {@link Directory} of the specified type exists, otherwise <code>false</code>
[ "Indicates", "whether", "an", "instance", "of", "the", "given", "directory", "type", "exists", "in", "this", "Metadata", "instance", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/Metadata.java#L113-L120
22,643
drewnoakes/metadata-extractor
Source/com/drew/imaging/tiff/TiffReader.java
TiffReader.processTiff
public void processTiff(@NotNull final RandomAccessReader reader, @NotNull final TiffHandler handler, final int tiffHeaderOffset) throws TiffProcessingException, IOException { // This must be either "MM" or "II". short byteOrderIdentifier = reader.getInt16(tiffHeaderOffset); if (byteOrderIdentifier == 0x4d4d) { // "MM" reader.setMotorolaByteOrder(true); } else if (byteOrderIdentifier == 0x4949) { // "II" reader.setMotorolaByteOrder(false); } else { throw new TiffProcessingException("Unclear distinction between Motorola/Intel byte ordering: " + byteOrderIdentifier); } // Check the next two values for correctness. final int tiffMarker = reader.getUInt16(2 + tiffHeaderOffset); handler.setTiffMarker(tiffMarker); int firstIfdOffset = reader.getInt32(4 + tiffHeaderOffset) + tiffHeaderOffset; // David Ekholm sent a digital camera image that has this problem // TODO getLength should be avoided as it causes RandomAccessStreamReader to read to the end of the stream if (firstIfdOffset >= reader.getLength() - 1) { handler.warn("First IFD offset is beyond the end of the TIFF data segment -- trying default offset"); // First directory normally starts immediately after the offset bytes, so try that firstIfdOffset = tiffHeaderOffset + 2 + 2 + 4; } Set<Integer> processedIfdOffsets = new HashSet<Integer>(); processIfd(handler, reader, processedIfdOffsets, firstIfdOffset, tiffHeaderOffset); }
java
public void processTiff(@NotNull final RandomAccessReader reader, @NotNull final TiffHandler handler, final int tiffHeaderOffset) throws TiffProcessingException, IOException { // This must be either "MM" or "II". short byteOrderIdentifier = reader.getInt16(tiffHeaderOffset); if (byteOrderIdentifier == 0x4d4d) { // "MM" reader.setMotorolaByteOrder(true); } else if (byteOrderIdentifier == 0x4949) { // "II" reader.setMotorolaByteOrder(false); } else { throw new TiffProcessingException("Unclear distinction between Motorola/Intel byte ordering: " + byteOrderIdentifier); } // Check the next two values for correctness. final int tiffMarker = reader.getUInt16(2 + tiffHeaderOffset); handler.setTiffMarker(tiffMarker); int firstIfdOffset = reader.getInt32(4 + tiffHeaderOffset) + tiffHeaderOffset; // David Ekholm sent a digital camera image that has this problem // TODO getLength should be avoided as it causes RandomAccessStreamReader to read to the end of the stream if (firstIfdOffset >= reader.getLength() - 1) { handler.warn("First IFD offset is beyond the end of the TIFF data segment -- trying default offset"); // First directory normally starts immediately after the offset bytes, so try that firstIfdOffset = tiffHeaderOffset + 2 + 2 + 4; } Set<Integer> processedIfdOffsets = new HashSet<Integer>(); processIfd(handler, reader, processedIfdOffsets, firstIfdOffset, tiffHeaderOffset); }
[ "public", "void", "processTiff", "(", "@", "NotNull", "final", "RandomAccessReader", "reader", ",", "@", "NotNull", "final", "TiffHandler", "handler", ",", "final", "int", "tiffHeaderOffset", ")", "throws", "TiffProcessingException", ",", "IOException", "{", "// This must be either \"MM\" or \"II\".", "short", "byteOrderIdentifier", "=", "reader", ".", "getInt16", "(", "tiffHeaderOffset", ")", ";", "if", "(", "byteOrderIdentifier", "==", "0x4d4d", ")", "{", "// \"MM\"", "reader", ".", "setMotorolaByteOrder", "(", "true", ")", ";", "}", "else", "if", "(", "byteOrderIdentifier", "==", "0x4949", ")", "{", "// \"II\"", "reader", ".", "setMotorolaByteOrder", "(", "false", ")", ";", "}", "else", "{", "throw", "new", "TiffProcessingException", "(", "\"Unclear distinction between Motorola/Intel byte ordering: \"", "+", "byteOrderIdentifier", ")", ";", "}", "// Check the next two values for correctness.", "final", "int", "tiffMarker", "=", "reader", ".", "getUInt16", "(", "2", "+", "tiffHeaderOffset", ")", ";", "handler", ".", "setTiffMarker", "(", "tiffMarker", ")", ";", "int", "firstIfdOffset", "=", "reader", ".", "getInt32", "(", "4", "+", "tiffHeaderOffset", ")", "+", "tiffHeaderOffset", ";", "// David Ekholm sent a digital camera image that has this problem", "// TODO getLength should be avoided as it causes RandomAccessStreamReader to read to the end of the stream", "if", "(", "firstIfdOffset", ">=", "reader", ".", "getLength", "(", ")", "-", "1", ")", "{", "handler", ".", "warn", "(", "\"First IFD offset is beyond the end of the TIFF data segment -- trying default offset\"", ")", ";", "// First directory normally starts immediately after the offset bytes, so try that", "firstIfdOffset", "=", "tiffHeaderOffset", "+", "2", "+", "2", "+", "4", ";", "}", "Set", "<", "Integer", ">", "processedIfdOffsets", "=", "new", "HashSet", "<", "Integer", ">", "(", ")", ";", "processIfd", "(", "handler", ",", "reader", ",", "processedIfdOffsets", ",", "firstIfdOffset", ",", "tiffHeaderOffset", ")", ";", "}" ]
Processes a TIFF data sequence. @param reader the {@link RandomAccessReader} from which the data should be read @param handler the {@link TiffHandler} that will coordinate processing and accept read values @param tiffHeaderOffset the offset within <code>reader</code> at which the TIFF header starts @throws TiffProcessingException if an error occurred during the processing of TIFF data that could not be ignored or recovered from @throws IOException an error occurred while accessing the required data
[ "Processes", "a", "TIFF", "data", "sequence", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/imaging/tiff/TiffReader.java#L48-L79
22,644
drewnoakes/metadata-extractor
Source/com/drew/lang/ByteTrie.java
ByteTrie.addPath
public void addPath(T value, byte[]... parts) { int depth = 0; ByteTrieNode<T> node = _root; for (byte[] part : parts) { for (byte b : part) { ByteTrieNode<T> child = node._children.get(b); if (child == null) { child = new ByteTrieNode<T>(); node._children.put(b, child); } node = child; depth++; } } if (depth == 0) throw new IllegalArgumentException("Parts must contain at least one byte."); node.setValue(value); _maxDepth = Math.max(_maxDepth, depth); }
java
public void addPath(T value, byte[]... parts) { int depth = 0; ByteTrieNode<T> node = _root; for (byte[] part : parts) { for (byte b : part) { ByteTrieNode<T> child = node._children.get(b); if (child == null) { child = new ByteTrieNode<T>(); node._children.put(b, child); } node = child; depth++; } } if (depth == 0) throw new IllegalArgumentException("Parts must contain at least one byte."); node.setValue(value); _maxDepth = Math.max(_maxDepth, depth); }
[ "public", "void", "addPath", "(", "T", "value", ",", "byte", "[", "]", "...", "parts", ")", "{", "int", "depth", "=", "0", ";", "ByteTrieNode", "<", "T", ">", "node", "=", "_root", ";", "for", "(", "byte", "[", "]", "part", ":", "parts", ")", "{", "for", "(", "byte", "b", ":", "part", ")", "{", "ByteTrieNode", "<", "T", ">", "child", "=", "node", ".", "_children", ".", "get", "(", "b", ")", ";", "if", "(", "child", "==", "null", ")", "{", "child", "=", "new", "ByteTrieNode", "<", "T", ">", "(", ")", ";", "node", ".", "_children", ".", "put", "(", "b", ",", "child", ")", ";", "}", "node", "=", "child", ";", "depth", "++", ";", "}", "}", "if", "(", "depth", "==", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"Parts must contain at least one byte.\"", ")", ";", "node", ".", "setValue", "(", "value", ")", ";", "_maxDepth", "=", "Math", ".", "max", "(", "_maxDepth", ",", "depth", ")", ";", "}" ]
Store the given value at the specified path.
[ "Store", "the", "given", "value", "at", "the", "specified", "path", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/lang/ByteTrie.java#L74-L93
22,645
drewnoakes/metadata-extractor
Samples/com/drew/metadata/SampleUsage.java
SampleUsage.print
private static void print(Metadata metadata, String method) { System.out.println(); System.out.println("-------------------------------------------------"); System.out.print(' '); System.out.print(method); System.out.println("-------------------------------------------------"); System.out.println(); // // A Metadata object contains multiple Directory objects // for (Directory directory : metadata.getDirectories()) { // // Each Directory stores values in Tag objects // for (Tag tag : directory.getTags()) { System.out.println(tag); } // // Each Directory may also contain error messages // for (String error : directory.getErrors()) { System.err.println("ERROR: " + error); } } }
java
private static void print(Metadata metadata, String method) { System.out.println(); System.out.println("-------------------------------------------------"); System.out.print(' '); System.out.print(method); System.out.println("-------------------------------------------------"); System.out.println(); // // A Metadata object contains multiple Directory objects // for (Directory directory : metadata.getDirectories()) { // // Each Directory stores values in Tag objects // for (Tag tag : directory.getTags()) { System.out.println(tag); } // // Each Directory may also contain error messages // for (String error : directory.getErrors()) { System.err.println("ERROR: " + error); } } }
[ "private", "static", "void", "print", "(", "Metadata", "metadata", ",", "String", "method", ")", "{", "System", ".", "out", ".", "println", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"-------------------------------------------------\"", ")", ";", "System", ".", "out", ".", "print", "(", "'", "'", ")", ";", "System", ".", "out", ".", "print", "(", "method", ")", ";", "System", ".", "out", ".", "println", "(", "\"-------------------------------------------------\"", ")", ";", "System", ".", "out", ".", "println", "(", ")", ";", "//", "// A Metadata object contains multiple Directory objects", "//", "for", "(", "Directory", "directory", ":", "metadata", ".", "getDirectories", "(", ")", ")", "{", "//", "// Each Directory stores values in Tag objects", "//", "for", "(", "Tag", "tag", ":", "directory", ".", "getTags", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "tag", ")", ";", "}", "//", "// Each Directory may also contain error messages", "//", "for", "(", "String", "error", ":", "directory", ".", "getErrors", "(", ")", ")", "{", "System", ".", "err", ".", "println", "(", "\"ERROR: \"", "+", "error", ")", ";", "}", "}", "}" ]
Write all extracted values to stdout.
[ "Write", "all", "extracted", "values", "to", "stdout", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Samples/com/drew/metadata/SampleUsage.java#L111-L139
22,646
drewnoakes/metadata-extractor
Source/com/drew/metadata/Directory.java
Directory.containsTag
@java.lang.SuppressWarnings({ "UnnecessaryBoxing" }) public boolean containsTag(int tagType) { return _tagMap.containsKey(Integer.valueOf(tagType)); }
java
@java.lang.SuppressWarnings({ "UnnecessaryBoxing" }) public boolean containsTag(int tagType) { return _tagMap.containsKey(Integer.valueOf(tagType)); }
[ "@", "java", ".", "lang", ".", "SuppressWarnings", "(", "{", "\"UnnecessaryBoxing\"", "}", ")", "public", "boolean", "containsTag", "(", "int", "tagType", ")", "{", "return", "_tagMap", ".", "containsKey", "(", "Integer", ".", "valueOf", "(", "tagType", ")", ")", ";", "}" ]
Indicates whether the specified tag type has been set. @param tagType the tag type to check for @return true if a value exists for the specified tag type, false if not
[ "Indicates", "whether", "the", "specified", "tag", "type", "has", "been", "set", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/Directory.java#L107-L111
22,647
drewnoakes/metadata-extractor
Source/com/drew/imaging/riff/RiffReader.java
RiffReader.processRiff
public void processRiff(@NotNull final SequentialReader reader, @NotNull final RiffHandler handler) throws RiffProcessingException, IOException { // RIFF files are always little-endian reader.setMotorolaByteOrder(false); // PROCESS FILE HEADER final String fileFourCC = reader.getString(4); if (!fileFourCC.equals("RIFF")) throw new RiffProcessingException("Invalid RIFF header: " + fileFourCC); // The total size of the chunks that follow plus 4 bytes for the FourCC final int fileSize = reader.getInt32(); int sizeLeft = fileSize; final String identifier = reader.getString(4); sizeLeft -= 4; if (!handler.shouldAcceptRiffIdentifier(identifier)) return; // PROCESS CHUNKS processChunks(reader, sizeLeft, handler); }
java
public void processRiff(@NotNull final SequentialReader reader, @NotNull final RiffHandler handler) throws RiffProcessingException, IOException { // RIFF files are always little-endian reader.setMotorolaByteOrder(false); // PROCESS FILE HEADER final String fileFourCC = reader.getString(4); if (!fileFourCC.equals("RIFF")) throw new RiffProcessingException("Invalid RIFF header: " + fileFourCC); // The total size of the chunks that follow plus 4 bytes for the FourCC final int fileSize = reader.getInt32(); int sizeLeft = fileSize; final String identifier = reader.getString(4); sizeLeft -= 4; if (!handler.shouldAcceptRiffIdentifier(identifier)) return; // PROCESS CHUNKS processChunks(reader, sizeLeft, handler); }
[ "public", "void", "processRiff", "(", "@", "NotNull", "final", "SequentialReader", "reader", ",", "@", "NotNull", "final", "RiffHandler", "handler", ")", "throws", "RiffProcessingException", ",", "IOException", "{", "// RIFF files are always little-endian", "reader", ".", "setMotorolaByteOrder", "(", "false", ")", ";", "// PROCESS FILE HEADER", "final", "String", "fileFourCC", "=", "reader", ".", "getString", "(", "4", ")", ";", "if", "(", "!", "fileFourCC", ".", "equals", "(", "\"RIFF\"", ")", ")", "throw", "new", "RiffProcessingException", "(", "\"Invalid RIFF header: \"", "+", "fileFourCC", ")", ";", "// The total size of the chunks that follow plus 4 bytes for the FourCC", "final", "int", "fileSize", "=", "reader", ".", "getInt32", "(", ")", ";", "int", "sizeLeft", "=", "fileSize", ";", "final", "String", "identifier", "=", "reader", ".", "getString", "(", "4", ")", ";", "sizeLeft", "-=", "4", ";", "if", "(", "!", "handler", ".", "shouldAcceptRiffIdentifier", "(", "identifier", ")", ")", "return", ";", "// PROCESS CHUNKS", "processChunks", "(", "reader", ",", "sizeLeft", ",", "handler", ")", ";", "}" ]
Processes a RIFF data sequence. @param reader the {@link SequentialReader} from which the data should be read @param handler the {@link RiffHandler} that will coordinate processing and accept read values @throws RiffProcessingException if an error occurred during the processing of RIFF data that could not be ignored or recovered from @throws IOException an error occurred while accessing the required data
[ "Processes", "a", "RIFF", "data", "sequence", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/imaging/riff/RiffReader.java#L51-L76
22,648
drewnoakes/metadata-extractor
Source/com/drew/imaging/jpeg/JpegSegmentData.java
JpegSegmentData.getSegmentTypes
public Iterable<JpegSegmentType> getSegmentTypes() { Set<JpegSegmentType> segmentTypes = new HashSet<JpegSegmentType>(); for (Byte segmentTypeByte : _segmentDataMap.keySet()) { JpegSegmentType segmentType = JpegSegmentType.fromByte(segmentTypeByte); if (segmentType == null) { throw new IllegalStateException("Should not have a segmentTypeByte that is not in the enum: " + Integer.toHexString(segmentTypeByte)); } segmentTypes.add(segmentType); } return segmentTypes; }
java
public Iterable<JpegSegmentType> getSegmentTypes() { Set<JpegSegmentType> segmentTypes = new HashSet<JpegSegmentType>(); for (Byte segmentTypeByte : _segmentDataMap.keySet()) { JpegSegmentType segmentType = JpegSegmentType.fromByte(segmentTypeByte); if (segmentType == null) { throw new IllegalStateException("Should not have a segmentTypeByte that is not in the enum: " + Integer.toHexString(segmentTypeByte)); } segmentTypes.add(segmentType); } return segmentTypes; }
[ "public", "Iterable", "<", "JpegSegmentType", ">", "getSegmentTypes", "(", ")", "{", "Set", "<", "JpegSegmentType", ">", "segmentTypes", "=", "new", "HashSet", "<", "JpegSegmentType", ">", "(", ")", ";", "for", "(", "Byte", "segmentTypeByte", ":", "_segmentDataMap", ".", "keySet", "(", ")", ")", "{", "JpegSegmentType", "segmentType", "=", "JpegSegmentType", ".", "fromByte", "(", "segmentTypeByte", ")", ";", "if", "(", "segmentType", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Should not have a segmentTypeByte that is not in the enum: \"", "+", "Integer", ".", "toHexString", "(", "segmentTypeByte", ")", ")", ";", "}", "segmentTypes", ".", "add", "(", "segmentType", ")", ";", "}", "return", "segmentTypes", ";", "}" ]
Gets the set of JPEG segment type identifiers.
[ "Gets", "the", "set", "of", "JPEG", "segment", "type", "identifiers", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/imaging/jpeg/JpegSegmentData.java#L63-L77
22,649
drewnoakes/metadata-extractor
Source/com/drew/imaging/jpeg/JpegSegmentData.java
JpegSegmentData.getSegments
@NotNull public Iterable<byte[]> getSegments(byte segmentType) { final List<byte[]> segmentList = getSegmentList(segmentType); return segmentList == null ? new ArrayList<byte[]>() : segmentList; }
java
@NotNull public Iterable<byte[]> getSegments(byte segmentType) { final List<byte[]> segmentList = getSegmentList(segmentType); return segmentList == null ? new ArrayList<byte[]>() : segmentList; }
[ "@", "NotNull", "public", "Iterable", "<", "byte", "[", "]", ">", "getSegments", "(", "byte", "segmentType", ")", "{", "final", "List", "<", "byte", "[", "]", ">", "segmentList", "=", "getSegmentList", "(", "segmentType", ")", ";", "return", "segmentList", "==", "null", "?", "new", "ArrayList", "<", "byte", "[", "]", ">", "(", ")", ":", "segmentList", ";", "}" ]
Returns all instances of a given JPEG segment. If no instances exist, an empty sequence is returned. @param segmentType a number which identifies the type of JPEG segment being queried @return zero or more byte arrays, each holding the data of a JPEG segment
[ "Returns", "all", "instances", "of", "a", "given", "JPEG", "segment", ".", "If", "no", "instances", "exist", "an", "empty", "sequence", "is", "returned", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/imaging/jpeg/JpegSegmentData.java#L153-L158
22,650
drewnoakes/metadata-extractor
Source/com/drew/imaging/jpeg/JpegSegmentData.java
JpegSegmentData.getSegmentCount
public int getSegmentCount(byte segmentType) { final List<byte[]> segmentList = getSegmentList(segmentType); return segmentList == null ? 0 : segmentList.size(); }
java
public int getSegmentCount(byte segmentType) { final List<byte[]> segmentList = getSegmentList(segmentType); return segmentList == null ? 0 : segmentList.size(); }
[ "public", "int", "getSegmentCount", "(", "byte", "segmentType", ")", "{", "final", "List", "<", "byte", "[", "]", ">", "segmentList", "=", "getSegmentList", "(", "segmentType", ")", ";", "return", "segmentList", "==", "null", "?", "0", ":", "segmentList", ".", "size", "(", ")", ";", "}" ]
Returns the count of segment data byte arrays stored for a given segment type. @param segmentType identifies the required segment @return the segment count (zero if no segments exist).
[ "Returns", "the", "count", "of", "segment", "data", "byte", "arrays", "stored", "for", "a", "given", "segment", "type", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/imaging/jpeg/JpegSegmentData.java#L196-L200
22,651
drewnoakes/metadata-extractor
Source/com/drew/metadata/exif/ExifTiffHandler.java
ExifTiffHandler.getReaderString
@NotNull private static String getReaderString(final @NotNull RandomAccessReader reader, final int makernoteOffset, final int bytesRequested) throws IOException { try { return reader.getString(makernoteOffset, bytesRequested, Charsets.UTF_8); } catch(BufferBoundsException e) { return ""; } }
java
@NotNull private static String getReaderString(final @NotNull RandomAccessReader reader, final int makernoteOffset, final int bytesRequested) throws IOException { try { return reader.getString(makernoteOffset, bytesRequested, Charsets.UTF_8); } catch(BufferBoundsException e) { return ""; } }
[ "@", "NotNull", "private", "static", "String", "getReaderString", "(", "final", "@", "NotNull", "RandomAccessReader", "reader", ",", "final", "int", "makernoteOffset", ",", "final", "int", "bytesRequested", ")", "throws", "IOException", "{", "try", "{", "return", "reader", ".", "getString", "(", "makernoteOffset", ",", "bytesRequested", ",", "Charsets", ".", "UTF_8", ")", ";", "}", "catch", "(", "BufferBoundsException", "e", ")", "{", "return", "\"\"", ";", "}", "}" ]
Read a given number of bytes from the stream This method is employed to "suppress" attempts to read beyond end of the file as may happen at the beginning of processMakernote when we read increasingly longer camera makes. Instead of failing altogether in this context we return an empty string which will fail all sensible attempts to compare to makes while avoiding a full-on failure.
[ "Read", "a", "given", "number", "of", "bytes", "from", "the", "stream" ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/exif/ExifTiffHandler.java#L379-L387
22,652
drewnoakes/metadata-extractor
Source/com/drew/metadata/iptc/Iso2022Converter.java
Iso2022Converter.convertISO2022CharsetToJavaCharset
@Nullable public static String convertISO2022CharsetToJavaCharset(@NotNull final byte[] bytes) { if (bytes.length > 2 && bytes[0] == ESC && bytes[1] == PERCENT_SIGN && bytes[2] == LATIN_CAPITAL_G) return UTF_8; if (bytes.length > 3 && bytes[0] == ESC && (bytes[3] & 0xFF | ((bytes[2] & 0xFF) << 8) | ((bytes[1] & 0xFF) << 16)) == DOT && bytes[4] == LATIN_CAPITAL_A) return ISO_8859_1; return null; }
java
@Nullable public static String convertISO2022CharsetToJavaCharset(@NotNull final byte[] bytes) { if (bytes.length > 2 && bytes[0] == ESC && bytes[1] == PERCENT_SIGN && bytes[2] == LATIN_CAPITAL_G) return UTF_8; if (bytes.length > 3 && bytes[0] == ESC && (bytes[3] & 0xFF | ((bytes[2] & 0xFF) << 8) | ((bytes[1] & 0xFF) << 16)) == DOT && bytes[4] == LATIN_CAPITAL_A) return ISO_8859_1; return null; }
[ "@", "Nullable", "public", "static", "String", "convertISO2022CharsetToJavaCharset", "(", "@", "NotNull", "final", "byte", "[", "]", "bytes", ")", "{", "if", "(", "bytes", ".", "length", ">", "2", "&&", "bytes", "[", "0", "]", "==", "ESC", "&&", "bytes", "[", "1", "]", "==", "PERCENT_SIGN", "&&", "bytes", "[", "2", "]", "==", "LATIN_CAPITAL_G", ")", "return", "UTF_8", ";", "if", "(", "bytes", ".", "length", ">", "3", "&&", "bytes", "[", "0", "]", "==", "ESC", "&&", "(", "bytes", "[", "3", "]", "&", "0xFF", "|", "(", "(", "bytes", "[", "2", "]", "&", "0xFF", ")", "<<", "8", ")", "|", "(", "(", "bytes", "[", "1", "]", "&", "0xFF", ")", "<<", "16", ")", ")", "==", "DOT", "&&", "bytes", "[", "4", "]", "==", "LATIN_CAPITAL_A", ")", "return", "ISO_8859_1", ";", "return", "null", ";", "}" ]
Converts the given ISO2022 char set to a Java charset name. @param bytes string data encoded using ISO2022 @return the Java charset name as a string, or <code>null</code> if the conversion was not possible
[ "Converts", "the", "given", "ISO2022", "char", "set", "to", "a", "Java", "charset", "name", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/iptc/Iso2022Converter.java#L48-L58
22,653
drewnoakes/metadata-extractor
Source/com/drew/metadata/eps/EpsReader.java
EpsReader.extract
public void extract(@NotNull final InputStream inputStream, @NotNull final Metadata metadata) throws IOException { RandomAccessStreamReader reader = new RandomAccessStreamReader(inputStream); EpsDirectory directory = new EpsDirectory(); metadata.addDirectory(directory); /* * 0xC5D0D3C6 signifies an EPS Header block which contains 32-bytes of basic information * * 0x25215053 (%!PS) signifies an EPS File and leads straight into the PostScript */ switch (reader.getInt32(0)) { case 0xC5D0D3C6: reader.setMotorolaByteOrder(false); int postScriptOffset = reader.getInt32(4); int postScriptLength = reader.getInt32(8); int wmfOffset = reader.getInt32(12); int wmfSize = reader.getInt32(16); int tifOffset = reader.getInt32(20); int tifSize = reader.getInt32(24); //int checkSum = reader.getInt32(28); // Get Tiff/WMF preview data if applicable if (tifSize != 0) { directory.setInt(EpsDirectory.TAG_TIFF_PREVIEW_SIZE, tifSize); directory.setInt(EpsDirectory.TAG_TIFF_PREVIEW_OFFSET, tifOffset); // Get Tiff metadata try { ByteArrayReader byteArrayReader = new ByteArrayReader(reader.getBytes(tifOffset, tifSize)); new TiffReader().processTiff(byteArrayReader, new PhotoshopTiffHandler(metadata, null), 0); } catch (TiffProcessingException ex) { directory.addError("Unable to process TIFF data: " + ex.getMessage()); } } else if (wmfSize != 0) { directory.setInt(EpsDirectory.TAG_WMF_PREVIEW_SIZE, wmfSize); directory.setInt(EpsDirectory.TAG_WMF_PREVIEW_OFFSET, wmfOffset); } // TODO avoid allocating byte array here -- read directly from InputStream extract(directory, metadata, new SequentialByteArrayReader(reader.getBytes(postScriptOffset, postScriptLength))); break; case 0x25215053: inputStream.reset(); extract(directory, metadata, new StreamReader(inputStream)); break; default: directory.addError("File type not supported."); break; } }
java
public void extract(@NotNull final InputStream inputStream, @NotNull final Metadata metadata) throws IOException { RandomAccessStreamReader reader = new RandomAccessStreamReader(inputStream); EpsDirectory directory = new EpsDirectory(); metadata.addDirectory(directory); /* * 0xC5D0D3C6 signifies an EPS Header block which contains 32-bytes of basic information * * 0x25215053 (%!PS) signifies an EPS File and leads straight into the PostScript */ switch (reader.getInt32(0)) { case 0xC5D0D3C6: reader.setMotorolaByteOrder(false); int postScriptOffset = reader.getInt32(4); int postScriptLength = reader.getInt32(8); int wmfOffset = reader.getInt32(12); int wmfSize = reader.getInt32(16); int tifOffset = reader.getInt32(20); int tifSize = reader.getInt32(24); //int checkSum = reader.getInt32(28); // Get Tiff/WMF preview data if applicable if (tifSize != 0) { directory.setInt(EpsDirectory.TAG_TIFF_PREVIEW_SIZE, tifSize); directory.setInt(EpsDirectory.TAG_TIFF_PREVIEW_OFFSET, tifOffset); // Get Tiff metadata try { ByteArrayReader byteArrayReader = new ByteArrayReader(reader.getBytes(tifOffset, tifSize)); new TiffReader().processTiff(byteArrayReader, new PhotoshopTiffHandler(metadata, null), 0); } catch (TiffProcessingException ex) { directory.addError("Unable to process TIFF data: " + ex.getMessage()); } } else if (wmfSize != 0) { directory.setInt(EpsDirectory.TAG_WMF_PREVIEW_SIZE, wmfSize); directory.setInt(EpsDirectory.TAG_WMF_PREVIEW_OFFSET, wmfOffset); } // TODO avoid allocating byte array here -- read directly from InputStream extract(directory, metadata, new SequentialByteArrayReader(reader.getBytes(postScriptOffset, postScriptLength))); break; case 0x25215053: inputStream.reset(); extract(directory, metadata, new StreamReader(inputStream)); break; default: directory.addError("File type not supported."); break; } }
[ "public", "void", "extract", "(", "@", "NotNull", "final", "InputStream", "inputStream", ",", "@", "NotNull", "final", "Metadata", "metadata", ")", "throws", "IOException", "{", "RandomAccessStreamReader", "reader", "=", "new", "RandomAccessStreamReader", "(", "inputStream", ")", ";", "EpsDirectory", "directory", "=", "new", "EpsDirectory", "(", ")", ";", "metadata", ".", "addDirectory", "(", "directory", ")", ";", "/*\n * 0xC5D0D3C6 signifies an EPS Header block which contains 32-bytes of basic information\n *\n * 0x25215053 (%!PS) signifies an EPS File and leads straight into the PostScript\n */", "switch", "(", "reader", ".", "getInt32", "(", "0", ")", ")", "{", "case", "0xC5D0D3C6", ":", "reader", ".", "setMotorolaByteOrder", "(", "false", ")", ";", "int", "postScriptOffset", "=", "reader", ".", "getInt32", "(", "4", ")", ";", "int", "postScriptLength", "=", "reader", ".", "getInt32", "(", "8", ")", ";", "int", "wmfOffset", "=", "reader", ".", "getInt32", "(", "12", ")", ";", "int", "wmfSize", "=", "reader", ".", "getInt32", "(", "16", ")", ";", "int", "tifOffset", "=", "reader", ".", "getInt32", "(", "20", ")", ";", "int", "tifSize", "=", "reader", ".", "getInt32", "(", "24", ")", ";", "//int checkSum = reader.getInt32(28);", "// Get Tiff/WMF preview data if applicable", "if", "(", "tifSize", "!=", "0", ")", "{", "directory", ".", "setInt", "(", "EpsDirectory", ".", "TAG_TIFF_PREVIEW_SIZE", ",", "tifSize", ")", ";", "directory", ".", "setInt", "(", "EpsDirectory", ".", "TAG_TIFF_PREVIEW_OFFSET", ",", "tifOffset", ")", ";", "// Get Tiff metadata", "try", "{", "ByteArrayReader", "byteArrayReader", "=", "new", "ByteArrayReader", "(", "reader", ".", "getBytes", "(", "tifOffset", ",", "tifSize", ")", ")", ";", "new", "TiffReader", "(", ")", ".", "processTiff", "(", "byteArrayReader", ",", "new", "PhotoshopTiffHandler", "(", "metadata", ",", "null", ")", ",", "0", ")", ";", "}", "catch", "(", "TiffProcessingException", "ex", ")", "{", "directory", ".", "addError", "(", "\"Unable to process TIFF data: \"", "+", "ex", ".", "getMessage", "(", ")", ")", ";", "}", "}", "else", "if", "(", "wmfSize", "!=", "0", ")", "{", "directory", ".", "setInt", "(", "EpsDirectory", ".", "TAG_WMF_PREVIEW_SIZE", ",", "wmfSize", ")", ";", "directory", ".", "setInt", "(", "EpsDirectory", ".", "TAG_WMF_PREVIEW_OFFSET", ",", "wmfOffset", ")", ";", "}", "// TODO avoid allocating byte array here -- read directly from InputStream", "extract", "(", "directory", ",", "metadata", ",", "new", "SequentialByteArrayReader", "(", "reader", ".", "getBytes", "(", "postScriptOffset", ",", "postScriptLength", ")", ")", ")", ";", "break", ";", "case", "0x25215053", ":", "inputStream", ".", "reset", "(", ")", ";", "extract", "(", "directory", ",", "metadata", ",", "new", "StreamReader", "(", "inputStream", ")", ")", ";", "break", ";", "default", ":", "directory", ".", "addError", "(", "\"File type not supported.\"", ")", ";", "break", ";", "}", "}" ]
Filter method that determines if file will contain an EPS Header. If it does, it will read the necessary data and then set the position to the beginning of the PostScript data. If it does not, the position will not be changed. After both scenarios, the main extract method is called. @param inputStream InputStream containing file @param metadata Metadata to add directory to and extracted data
[ "Filter", "method", "that", "determines", "if", "file", "will", "contain", "an", "EPS", "Header", ".", "If", "it", "does", "it", "will", "read", "the", "necessary", "data", "and", "then", "set", "the", "position", "to", "the", "beginning", "of", "the", "PostScript", "data", ".", "If", "it", "does", "not", "the", "position", "will", "not", "be", "changed", ".", "After", "both", "scenarios", "the", "main", "extract", "method", "is", "called", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/eps/EpsReader.java#L54-L103
22,654
drewnoakes/metadata-extractor
Source/com/drew/metadata/eps/EpsReader.java
EpsReader.addToDirectory
private void addToDirectory(@NotNull final EpsDirectory directory, String name, String value) throws IOException { Integer tag = EpsDirectory._tagIntegerMap.get(name); if (tag == null) return; switch (tag) { case EpsDirectory.TAG_IMAGE_DATA: extractImageData(directory, value); break; case EpsDirectory.TAG_CONTINUE_LINE: directory.setString(_previousTag, directory.getString(_previousTag) + " " + value); break; default: if (EpsDirectory._tagNameMap.containsKey(tag) && !directory.containsTag(tag)) { directory.setString(tag, value); _previousTag = tag; } else { // Set previous tag to an Integer that doesn't exist in EpsDirectory _previousTag = 0; } break; } _previousTag = tag; }
java
private void addToDirectory(@NotNull final EpsDirectory directory, String name, String value) throws IOException { Integer tag = EpsDirectory._tagIntegerMap.get(name); if (tag == null) return; switch (tag) { case EpsDirectory.TAG_IMAGE_DATA: extractImageData(directory, value); break; case EpsDirectory.TAG_CONTINUE_LINE: directory.setString(_previousTag, directory.getString(_previousTag) + " " + value); break; default: if (EpsDirectory._tagNameMap.containsKey(tag) && !directory.containsTag(tag)) { directory.setString(tag, value); _previousTag = tag; } else { // Set previous tag to an Integer that doesn't exist in EpsDirectory _previousTag = 0; } break; } _previousTag = tag; }
[ "private", "void", "addToDirectory", "(", "@", "NotNull", "final", "EpsDirectory", "directory", ",", "String", "name", ",", "String", "value", ")", "throws", "IOException", "{", "Integer", "tag", "=", "EpsDirectory", ".", "_tagIntegerMap", ".", "get", "(", "name", ")", ";", "if", "(", "tag", "==", "null", ")", "return", ";", "switch", "(", "tag", ")", "{", "case", "EpsDirectory", ".", "TAG_IMAGE_DATA", ":", "extractImageData", "(", "directory", ",", "value", ")", ";", "break", ";", "case", "EpsDirectory", ".", "TAG_CONTINUE_LINE", ":", "directory", ".", "setString", "(", "_previousTag", ",", "directory", ".", "getString", "(", "_previousTag", ")", "+", "\" \"", "+", "value", ")", ";", "break", ";", "default", ":", "if", "(", "EpsDirectory", ".", "_tagNameMap", ".", "containsKey", "(", "tag", ")", "&&", "!", "directory", ".", "containsTag", "(", "tag", ")", ")", "{", "directory", ".", "setString", "(", "tag", ",", "value", ")", ";", "_previousTag", "=", "tag", ";", "}", "else", "{", "// Set previous tag to an Integer that doesn't exist in EpsDirectory", "_previousTag", "=", "0", ";", "}", "break", ";", "}", "_previousTag", "=", "tag", ";", "}" ]
Default case that adds comment with keyword to directory @param directory EpsDirectory to add extracted data to @param name String that holds name of current comment @param value String that holds value of current comment
[ "Default", "case", "that", "adds", "comment", "with", "keyword", "to", "directory" ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/eps/EpsReader.java#L165-L190
22,655
drewnoakes/metadata-extractor
Source/com/drew/metadata/eps/EpsReader.java
EpsReader.tryHexToInt
private static int tryHexToInt(byte b) { if (b >= '0' && b <= '9') return b - '0'; if (b >= 'A' && b <= 'F') return b - 'A' + 10; if (b >= 'a' && b <= 'f') return b - 'a' + 10; return -1; }
java
private static int tryHexToInt(byte b) { if (b >= '0' && b <= '9') return b - '0'; if (b >= 'A' && b <= 'F') return b - 'A' + 10; if (b >= 'a' && b <= 'f') return b - 'a' + 10; return -1; }
[ "private", "static", "int", "tryHexToInt", "(", "byte", "b", ")", "{", "if", "(", "b", ">=", "'", "'", "&&", "b", "<=", "'", "'", ")", "return", "b", "-", "'", "'", ";", "if", "(", "b", ">=", "'", "'", "&&", "b", "<=", "'", "'", ")", "return", "b", "-", "'", "'", "+", "10", ";", "if", "(", "b", ">=", "'", "'", "&&", "b", "<=", "'", "'", ")", "return", "b", "-", "'", "'", "+", "10", ";", "return", "-", "1", ";", "}" ]
Treats a byte as an ASCII character, and returns it's numerical value in hexadecimal. If conversion is not possible, returns -1.
[ "Treats", "a", "byte", "as", "an", "ASCII", "character", "and", "returns", "it", "s", "numerical", "value", "in", "hexadecimal", ".", "If", "conversion", "is", "not", "possible", "returns", "-", "1", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/eps/EpsReader.java#L385-L394
22,656
drewnoakes/metadata-extractor
Source/com/drew/metadata/exif/GpsDirectory.java
GpsDirectory.getGeoLocation
@Nullable public GeoLocation getGeoLocation() { Rational[] latitudes = getRationalArray(TAG_LATITUDE); Rational[] longitudes = getRationalArray(TAG_LONGITUDE); String latitudeRef = getString(TAG_LATITUDE_REF); String longitudeRef = getString(TAG_LONGITUDE_REF); // Make sure we have the required values if (latitudes == null || latitudes.length != 3) return null; if (longitudes == null || longitudes.length != 3) return null; if (latitudeRef == null || longitudeRef == null) return null; Double lat = GeoLocation.degreesMinutesSecondsToDecimal(latitudes[0], latitudes[1], latitudes[2], latitudeRef.equalsIgnoreCase("S")); Double lon = GeoLocation.degreesMinutesSecondsToDecimal(longitudes[0], longitudes[1], longitudes[2], longitudeRef.equalsIgnoreCase("W")); // This can return null, in cases where the conversion was not possible if (lat == null || lon == null) return null; return new GeoLocation(lat, lon); }
java
@Nullable public GeoLocation getGeoLocation() { Rational[] latitudes = getRationalArray(TAG_LATITUDE); Rational[] longitudes = getRationalArray(TAG_LONGITUDE); String latitudeRef = getString(TAG_LATITUDE_REF); String longitudeRef = getString(TAG_LONGITUDE_REF); // Make sure we have the required values if (latitudes == null || latitudes.length != 3) return null; if (longitudes == null || longitudes.length != 3) return null; if (latitudeRef == null || longitudeRef == null) return null; Double lat = GeoLocation.degreesMinutesSecondsToDecimal(latitudes[0], latitudes[1], latitudes[2], latitudeRef.equalsIgnoreCase("S")); Double lon = GeoLocation.degreesMinutesSecondsToDecimal(longitudes[0], longitudes[1], longitudes[2], longitudeRef.equalsIgnoreCase("W")); // This can return null, in cases where the conversion was not possible if (lat == null || lon == null) return null; return new GeoLocation(lat, lon); }
[ "@", "Nullable", "public", "GeoLocation", "getGeoLocation", "(", ")", "{", "Rational", "[", "]", "latitudes", "=", "getRationalArray", "(", "TAG_LATITUDE", ")", ";", "Rational", "[", "]", "longitudes", "=", "getRationalArray", "(", "TAG_LONGITUDE", ")", ";", "String", "latitudeRef", "=", "getString", "(", "TAG_LATITUDE_REF", ")", ";", "String", "longitudeRef", "=", "getString", "(", "TAG_LONGITUDE_REF", ")", ";", "// Make sure we have the required values", "if", "(", "latitudes", "==", "null", "||", "latitudes", ".", "length", "!=", "3", ")", "return", "null", ";", "if", "(", "longitudes", "==", "null", "||", "longitudes", ".", "length", "!=", "3", ")", "return", "null", ";", "if", "(", "latitudeRef", "==", "null", "||", "longitudeRef", "==", "null", ")", "return", "null", ";", "Double", "lat", "=", "GeoLocation", ".", "degreesMinutesSecondsToDecimal", "(", "latitudes", "[", "0", "]", ",", "latitudes", "[", "1", "]", ",", "latitudes", "[", "2", "]", ",", "latitudeRef", ".", "equalsIgnoreCase", "(", "\"S\"", ")", ")", ";", "Double", "lon", "=", "GeoLocation", ".", "degreesMinutesSecondsToDecimal", "(", "longitudes", "[", "0", "]", ",", "longitudes", "[", "1", "]", ",", "longitudes", "[", "2", "]", ",", "longitudeRef", ".", "equalsIgnoreCase", "(", "\"W\"", ")", ")", ";", "// This can return null, in cases where the conversion was not possible", "if", "(", "lat", "==", "null", "||", "lon", "==", "null", ")", "return", "null", ";", "return", "new", "GeoLocation", "(", "lat", ",", "lon", ")", ";", "}" ]
Parses various tags in an attempt to obtain a single object representing the latitude and longitude at which this image was captured. @return The geographical location of this image, if possible, otherwise null
[ "Parses", "various", "tags", "in", "an", "attempt", "to", "obtain", "a", "single", "object", "representing", "the", "latitude", "and", "longitude", "at", "which", "this", "image", "was", "captured", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/exif/GpsDirectory.java#L174-L198
22,657
drewnoakes/metadata-extractor
Source/com/drew/metadata/exif/GpsDirectory.java
GpsDirectory.getGpsDate
@Nullable public Date getGpsDate() { String date = getString(TAG_DATE_STAMP); Rational[] timeComponents = getRationalArray(TAG_TIME_STAMP); // Make sure we have the required values if (date == null) return null; if (timeComponents == null || timeComponents.length != 3) return null; String dateTime = String.format(Locale.US, "%s %02d:%02d:%02.3f UTC", date, timeComponents[0].intValue(), timeComponents[1].intValue(), timeComponents[2].doubleValue()); try { DateFormat parser = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss.S z"); return parser.parse(dateTime); } catch (ParseException e) { return null; } }
java
@Nullable public Date getGpsDate() { String date = getString(TAG_DATE_STAMP); Rational[] timeComponents = getRationalArray(TAG_TIME_STAMP); // Make sure we have the required values if (date == null) return null; if (timeComponents == null || timeComponents.length != 3) return null; String dateTime = String.format(Locale.US, "%s %02d:%02d:%02.3f UTC", date, timeComponents[0].intValue(), timeComponents[1].intValue(), timeComponents[2].doubleValue()); try { DateFormat parser = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss.S z"); return parser.parse(dateTime); } catch (ParseException e) { return null; } }
[ "@", "Nullable", "public", "Date", "getGpsDate", "(", ")", "{", "String", "date", "=", "getString", "(", "TAG_DATE_STAMP", ")", ";", "Rational", "[", "]", "timeComponents", "=", "getRationalArray", "(", "TAG_TIME_STAMP", ")", ";", "// Make sure we have the required values", "if", "(", "date", "==", "null", ")", "return", "null", ";", "if", "(", "timeComponents", "==", "null", "||", "timeComponents", ".", "length", "!=", "3", ")", "return", "null", ";", "String", "dateTime", "=", "String", ".", "format", "(", "Locale", ".", "US", ",", "\"%s %02d:%02d:%02.3f UTC\"", ",", "date", ",", "timeComponents", "[", "0", "]", ".", "intValue", "(", ")", ",", "timeComponents", "[", "1", "]", ".", "intValue", "(", ")", ",", "timeComponents", "[", "2", "]", ".", "doubleValue", "(", ")", ")", ";", "try", "{", "DateFormat", "parser", "=", "new", "SimpleDateFormat", "(", "\"yyyy:MM:dd HH:mm:ss.S z\"", ")", ";", "return", "parser", ".", "parse", "(", "dateTime", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "return", "null", ";", "}", "}" ]
Parses the date stamp tag and the time stamp tag to obtain a single Date object representing the date and time when this image was captured. @return A Date object representing when this image was captured, if possible, otherwise null
[ "Parses", "the", "date", "stamp", "tag", "and", "the", "time", "stamp", "tag", "to", "obtain", "a", "single", "Date", "object", "representing", "the", "date", "and", "time", "when", "this", "image", "was", "captured", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/exif/GpsDirectory.java#L206-L226
22,658
drewnoakes/metadata-extractor
Source/com/drew/lang/RandomAccessReader.java
RandomAccessReader.getBit
public boolean getBit(int index) throws IOException { int byteIndex = index / 8; int bitIndex = index % 8; validateIndex(byteIndex, 1); byte b = getByte(byteIndex); return ((b >> bitIndex) & 1) == 1; }
java
public boolean getBit(int index) throws IOException { int byteIndex = index / 8; int bitIndex = index % 8; validateIndex(byteIndex, 1); byte b = getByte(byteIndex); return ((b >> bitIndex) & 1) == 1; }
[ "public", "boolean", "getBit", "(", "int", "index", ")", "throws", "IOException", "{", "int", "byteIndex", "=", "index", "/", "8", ";", "int", "bitIndex", "=", "index", "%", "8", ";", "validateIndex", "(", "byteIndex", ",", "1", ")", ";", "byte", "b", "=", "getByte", "(", "byteIndex", ")", ";", "return", "(", "(", "b", ">>", "bitIndex", ")", "&", "1", ")", "==", "1", ";", "}" ]
Gets whether a bit at a specific index is set or not. @param index the number of bits at which to test @return true if the bit is set, otherwise false @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
[ "Gets", "whether", "a", "bit", "at", "a", "specific", "index", "is", "set", "or", "not", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/lang/RandomAccessReader.java#L140-L149
22,659
drewnoakes/metadata-extractor
Source/com/drew/lang/RandomAccessReader.java
RandomAccessReader.getUInt16
public int getUInt16(int index) throws IOException { validateIndex(index, 2); if (_isMotorolaByteOrder) { // Motorola - MSB first return (getByte(index ) << 8 & 0xFF00) | (getByte(index + 1) & 0xFF); } else { // Intel ordering - LSB first return (getByte(index + 1) << 8 & 0xFF00) | (getByte(index ) & 0xFF); } }
java
public int getUInt16(int index) throws IOException { validateIndex(index, 2); if (_isMotorolaByteOrder) { // Motorola - MSB first return (getByte(index ) << 8 & 0xFF00) | (getByte(index + 1) & 0xFF); } else { // Intel ordering - LSB first return (getByte(index + 1) << 8 & 0xFF00) | (getByte(index ) & 0xFF); } }
[ "public", "int", "getUInt16", "(", "int", "index", ")", "throws", "IOException", "{", "validateIndex", "(", "index", ",", "2", ")", ";", "if", "(", "_isMotorolaByteOrder", ")", "{", "// Motorola - MSB first", "return", "(", "getByte", "(", "index", ")", "<<", "8", "&", "0xFF00", ")", "|", "(", "getByte", "(", "index", "+", "1", ")", "&", "0xFF", ")", ";", "}", "else", "{", "// Intel ordering - LSB first", "return", "(", "getByte", "(", "index", "+", "1", ")", "<<", "8", "&", "0xFF00", ")", "|", "(", "getByte", "(", "index", ")", "&", "0xFF", ")", ";", "}", "}" ]
Returns an unsigned 16-bit int calculated from two bytes of data at the specified index. @param index position within the data buffer to read first byte @return the 16 bit int value, between 0x0000 and 0xFFFF @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
[ "Returns", "an", "unsigned", "16", "-", "bit", "int", "calculated", "from", "two", "bytes", "of", "data", "at", "the", "specified", "index", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/lang/RandomAccessReader.java#L186-L199
22,660
drewnoakes/metadata-extractor
Source/com/drew/lang/RandomAccessReader.java
RandomAccessReader.getInt24
public int getInt24(int index) throws IOException { validateIndex(index, 3); if (_isMotorolaByteOrder) { // Motorola - MSB first (big endian) return (((int)getByte(index )) << 16 & 0xFF0000) | (((int)getByte(index + 1)) << 8 & 0xFF00) | (((int)getByte(index + 2)) & 0xFF); } else { // Intel ordering - LSB first (little endian) return (((int)getByte(index + 2)) << 16 & 0xFF0000) | (((int)getByte(index + 1)) << 8 & 0xFF00) | (((int)getByte(index )) & 0xFF); } }
java
public int getInt24(int index) throws IOException { validateIndex(index, 3); if (_isMotorolaByteOrder) { // Motorola - MSB first (big endian) return (((int)getByte(index )) << 16 & 0xFF0000) | (((int)getByte(index + 1)) << 8 & 0xFF00) | (((int)getByte(index + 2)) & 0xFF); } else { // Intel ordering - LSB first (little endian) return (((int)getByte(index + 2)) << 16 & 0xFF0000) | (((int)getByte(index + 1)) << 8 & 0xFF00) | (((int)getByte(index )) & 0xFF); } }
[ "public", "int", "getInt24", "(", "int", "index", ")", "throws", "IOException", "{", "validateIndex", "(", "index", ",", "3", ")", ";", "if", "(", "_isMotorolaByteOrder", ")", "{", "// Motorola - MSB first (big endian)", "return", "(", "(", "(", "int", ")", "getByte", "(", "index", ")", ")", "<<", "16", "&", "0xFF0000", ")", "|", "(", "(", "(", "int", ")", "getByte", "(", "index", "+", "1", ")", ")", "<<", "8", "&", "0xFF00", ")", "|", "(", "(", "(", "int", ")", "getByte", "(", "index", "+", "2", ")", ")", "&", "0xFF", ")", ";", "}", "else", "{", "// Intel ordering - LSB first (little endian)", "return", "(", "(", "(", "int", ")", "getByte", "(", "index", "+", "2", ")", ")", "<<", "16", "&", "0xFF0000", ")", "|", "(", "(", "(", "int", ")", "getByte", "(", "index", "+", "1", ")", ")", "<<", "8", "&", "0xFF00", ")", "|", "(", "(", "(", "int", ")", "getByte", "(", "index", ")", ")", "&", "0xFF", ")", ";", "}", "}" ]
Get a 24-bit unsigned integer from the buffer, returning it as an int. @param index position within the data buffer to read first byte @return the unsigned 24-bit int value as a long, between 0x00000000 and 0x00FFFFFF @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
[ "Get", "a", "24", "-", "bit", "unsigned", "integer", "from", "the", "buffer", "returning", "it", "as", "an", "int", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/lang/RandomAccessReader.java#L230-L245
22,661
drewnoakes/metadata-extractor
Source/com/drew/lang/RandomAccessReader.java
RandomAccessReader.getInt32
public int getInt32(int index) throws IOException { validateIndex(index, 4); if (_isMotorolaByteOrder) { // Motorola - MSB first (big endian) return (getByte(index ) << 24 & 0xFF000000) | (getByte(index + 1) << 16 & 0xFF0000) | (getByte(index + 2) << 8 & 0xFF00) | (getByte(index + 3) & 0xFF); } else { // Intel ordering - LSB first (little endian) return (getByte(index + 3) << 24 & 0xFF000000) | (getByte(index + 2) << 16 & 0xFF0000) | (getByte(index + 1) << 8 & 0xFF00) | (getByte(index ) & 0xFF); } }
java
public int getInt32(int index) throws IOException { validateIndex(index, 4); if (_isMotorolaByteOrder) { // Motorola - MSB first (big endian) return (getByte(index ) << 24 & 0xFF000000) | (getByte(index + 1) << 16 & 0xFF0000) | (getByte(index + 2) << 8 & 0xFF00) | (getByte(index + 3) & 0xFF); } else { // Intel ordering - LSB first (little endian) return (getByte(index + 3) << 24 & 0xFF000000) | (getByte(index + 2) << 16 & 0xFF0000) | (getByte(index + 1) << 8 & 0xFF00) | (getByte(index ) & 0xFF); } }
[ "public", "int", "getInt32", "(", "int", "index", ")", "throws", "IOException", "{", "validateIndex", "(", "index", ",", "4", ")", ";", "if", "(", "_isMotorolaByteOrder", ")", "{", "// Motorola - MSB first (big endian)", "return", "(", "getByte", "(", "index", ")", "<<", "24", "&", "0xFF000000", ")", "|", "(", "getByte", "(", "index", "+", "1", ")", "<<", "16", "&", "0xFF0000", ")", "|", "(", "getByte", "(", "index", "+", "2", ")", "<<", "8", "&", "0xFF00", ")", "|", "(", "getByte", "(", "index", "+", "3", ")", "&", "0xFF", ")", ";", "}", "else", "{", "// Intel ordering - LSB first (little endian)", "return", "(", "getByte", "(", "index", "+", "3", ")", "<<", "24", "&", "0xFF000000", ")", "|", "(", "getByte", "(", "index", "+", "2", ")", "<<", "16", "&", "0xFF0000", ")", "|", "(", "getByte", "(", "index", "+", "1", ")", "<<", "8", "&", "0xFF00", ")", "|", "(", "getByte", "(", "index", ")", "&", "0xFF", ")", ";", "}", "}" ]
Returns a signed 32-bit integer from four bytes of data at the specified index the buffer. @param index position within the data buffer to read first byte @return the signed 32 bit int value, between 0x00000000 and 0xFFFFFFFF @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
[ "Returns", "a", "signed", "32", "-", "bit", "integer", "from", "four", "bytes", "of", "data", "at", "the", "specified", "index", "the", "buffer", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/lang/RandomAccessReader.java#L280-L297
22,662
drewnoakes/metadata-extractor
Source/com/drew/metadata/TagDescriptor.java
TagDescriptor.getEncodedTextDescription
@Nullable protected String getEncodedTextDescription(int tagType) { byte[] commentBytes = _directory.getByteArray(tagType); if (commentBytes == null) return null; if (commentBytes.length == 0) return ""; final Map<String, String> encodingMap = new HashMap<String, String>(); encodingMap.put("ASCII", System.getProperty("file.encoding")); // Someone suggested "ISO-8859-1". encodingMap.put("UNICODE", "UTF-16LE"); encodingMap.put("JIS", "Shift-JIS"); // We assume this charset for now. Another suggestion is "JIS". try { if (commentBytes.length >= 10) { String firstTenBytesString = new String(commentBytes, 0, 10); // try each encoding name for (Map.Entry<String, String> pair : encodingMap.entrySet()) { String encodingName = pair.getKey(); String charset = pair.getValue(); if (firstTenBytesString.startsWith(encodingName)) { // skip any null or blank characters commonly present after the encoding name, up to a limit of 10 from the start for (int j = encodingName.length(); j < 10; j++) { byte b = commentBytes[j]; if (b != '\0' && b != ' ') return new String(commentBytes, j, commentBytes.length - j, charset).trim(); } return new String(commentBytes, 10, commentBytes.length - 10, charset).trim(); } } } // special handling fell through, return a plain string representation return new String(commentBytes, System.getProperty("file.encoding")).trim(); } catch (UnsupportedEncodingException ex) { return null; } }
java
@Nullable protected String getEncodedTextDescription(int tagType) { byte[] commentBytes = _directory.getByteArray(tagType); if (commentBytes == null) return null; if (commentBytes.length == 0) return ""; final Map<String, String> encodingMap = new HashMap<String, String>(); encodingMap.put("ASCII", System.getProperty("file.encoding")); // Someone suggested "ISO-8859-1". encodingMap.put("UNICODE", "UTF-16LE"); encodingMap.put("JIS", "Shift-JIS"); // We assume this charset for now. Another suggestion is "JIS". try { if (commentBytes.length >= 10) { String firstTenBytesString = new String(commentBytes, 0, 10); // try each encoding name for (Map.Entry<String, String> pair : encodingMap.entrySet()) { String encodingName = pair.getKey(); String charset = pair.getValue(); if (firstTenBytesString.startsWith(encodingName)) { // skip any null or blank characters commonly present after the encoding name, up to a limit of 10 from the start for (int j = encodingName.length(); j < 10; j++) { byte b = commentBytes[j]; if (b != '\0' && b != ' ') return new String(commentBytes, j, commentBytes.length - j, charset).trim(); } return new String(commentBytes, 10, commentBytes.length - 10, charset).trim(); } } } // special handling fell through, return a plain string representation return new String(commentBytes, System.getProperty("file.encoding")).trim(); } catch (UnsupportedEncodingException ex) { return null; } }
[ "@", "Nullable", "protected", "String", "getEncodedTextDescription", "(", "int", "tagType", ")", "{", "byte", "[", "]", "commentBytes", "=", "_directory", ".", "getByteArray", "(", "tagType", ")", ";", "if", "(", "commentBytes", "==", "null", ")", "return", "null", ";", "if", "(", "commentBytes", ".", "length", "==", "0", ")", "return", "\"\"", ";", "final", "Map", "<", "String", ",", "String", ">", "encodingMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "encodingMap", ".", "put", "(", "\"ASCII\"", ",", "System", ".", "getProperty", "(", "\"file.encoding\"", ")", ")", ";", "// Someone suggested \"ISO-8859-1\".", "encodingMap", ".", "put", "(", "\"UNICODE\"", ",", "\"UTF-16LE\"", ")", ";", "encodingMap", ".", "put", "(", "\"JIS\"", ",", "\"Shift-JIS\"", ")", ";", "// We assume this charset for now. Another suggestion is \"JIS\".", "try", "{", "if", "(", "commentBytes", ".", "length", ">=", "10", ")", "{", "String", "firstTenBytesString", "=", "new", "String", "(", "commentBytes", ",", "0", ",", "10", ")", ";", "// try each encoding name", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "pair", ":", "encodingMap", ".", "entrySet", "(", ")", ")", "{", "String", "encodingName", "=", "pair", ".", "getKey", "(", ")", ";", "String", "charset", "=", "pair", ".", "getValue", "(", ")", ";", "if", "(", "firstTenBytesString", ".", "startsWith", "(", "encodingName", ")", ")", "{", "// skip any null or blank characters commonly present after the encoding name, up to a limit of 10 from the start", "for", "(", "int", "j", "=", "encodingName", ".", "length", "(", ")", ";", "j", "<", "10", ";", "j", "++", ")", "{", "byte", "b", "=", "commentBytes", "[", "j", "]", ";", "if", "(", "b", "!=", "'", "'", "&&", "b", "!=", "'", "'", ")", "return", "new", "String", "(", "commentBytes", ",", "j", ",", "commentBytes", ".", "length", "-", "j", ",", "charset", ")", ".", "trim", "(", ")", ";", "}", "return", "new", "String", "(", "commentBytes", ",", "10", ",", "commentBytes", ".", "length", "-", "10", ",", "charset", ")", ".", "trim", "(", ")", ";", "}", "}", "}", "// special handling fell through, return a plain string representation", "return", "new", "String", "(", "commentBytes", ",", "System", ".", "getProperty", "(", "\"file.encoding\"", ")", ")", ".", "trim", "(", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "ex", ")", "{", "return", "null", ";", "}", "}" ]
EXIF UserComment, GPSProcessingMethod and GPSAreaInformation
[ "EXIF", "UserComment", "GPSProcessingMethod", "and", "GPSAreaInformation" ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/metadata/TagDescriptor.java#L467-L505
22,663
drewnoakes/metadata-extractor
Source/com/drew/lang/SequentialReader.java
SequentialReader.getInt32
public int getInt32() throws IOException { if (_isMotorolaByteOrder) { // Motorola - MSB first (big endian) return (getByte() << 24 & 0xFF000000) | (getByte() << 16 & 0xFF0000) | (getByte() << 8 & 0xFF00) | (getByte() & 0xFF); } else { // Intel ordering - LSB first (little endian) return (getByte() & 0xFF) | (getByte() << 8 & 0xFF00) | (getByte() << 16 & 0xFF0000) | (getByte() << 24 & 0xFF000000); } }
java
public int getInt32() throws IOException { if (_isMotorolaByteOrder) { // Motorola - MSB first (big endian) return (getByte() << 24 & 0xFF000000) | (getByte() << 16 & 0xFF0000) | (getByte() << 8 & 0xFF00) | (getByte() & 0xFF); } else { // Intel ordering - LSB first (little endian) return (getByte() & 0xFF) | (getByte() << 8 & 0xFF00) | (getByte() << 16 & 0xFF0000) | (getByte() << 24 & 0xFF000000); } }
[ "public", "int", "getInt32", "(", ")", "throws", "IOException", "{", "if", "(", "_isMotorolaByteOrder", ")", "{", "// Motorola - MSB first (big endian)", "return", "(", "getByte", "(", ")", "<<", "24", "&", "0xFF000000", ")", "|", "(", "getByte", "(", ")", "<<", "16", "&", "0xFF0000", ")", "|", "(", "getByte", "(", ")", "<<", "8", "&", "0xFF00", ")", "|", "(", "getByte", "(", ")", "&", "0xFF", ")", ";", "}", "else", "{", "// Intel ordering - LSB first (little endian)", "return", "(", "getByte", "(", ")", "&", "0xFF", ")", "|", "(", "getByte", "(", ")", "<<", "8", "&", "0xFF00", ")", "|", "(", "getByte", "(", ")", "<<", "16", "&", "0xFF0000", ")", "|", "(", "getByte", "(", ")", "<<", "24", "&", "0xFF000000", ")", ";", "}", "}" ]
Returns a signed 32-bit integer from four bytes of data. @return the signed 32 bit int value, between 0x00000000 and 0xFFFFFFFF @throws IOException the buffer does not contain enough bytes to service the request
[ "Returns", "a", "signed", "32", "-", "bit", "integer", "from", "four", "bytes", "of", "data", "." ]
a958e0b61b50e590731b3be1dca8df8e21ebd43c
https://github.com/drewnoakes/metadata-extractor/blob/a958e0b61b50e590731b3be1dca8df8e21ebd43c/Source/com/drew/lang/SequentialReader.java#L217-L232
22,664
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/ShapeBadgeItem.java
ShapeBadgeItem.draw
void draw(Canvas canvas) { mCanvasRect.set(0.0f, 0.0f, canvas.getWidth(), canvas.getHeight()); switch (mShape) { case SHAPE_RECTANGLE: canvas.drawRect(mCanvasRect, mCanvasPaint); break; case SHAPE_OVAL: canvas.drawOval(mCanvasRect, mCanvasPaint); break; case SHAPE_STAR_3_VERTICES: case SHAPE_STAR_4_VERTICES: case SHAPE_STAR_5_VERTICES: case SHAPE_STAR_6_VERTICES: drawStar(canvas, mShape); break; case SHAPE_HEART: drawHeart(canvas); break; } }
java
void draw(Canvas canvas) { mCanvasRect.set(0.0f, 0.0f, canvas.getWidth(), canvas.getHeight()); switch (mShape) { case SHAPE_RECTANGLE: canvas.drawRect(mCanvasRect, mCanvasPaint); break; case SHAPE_OVAL: canvas.drawOval(mCanvasRect, mCanvasPaint); break; case SHAPE_STAR_3_VERTICES: case SHAPE_STAR_4_VERTICES: case SHAPE_STAR_5_VERTICES: case SHAPE_STAR_6_VERTICES: drawStar(canvas, mShape); break; case SHAPE_HEART: drawHeart(canvas); break; } }
[ "void", "draw", "(", "Canvas", "canvas", ")", "{", "mCanvasRect", ".", "set", "(", "0.0f", ",", "0.0f", ",", "canvas", ".", "getWidth", "(", ")", ",", "canvas", ".", "getHeight", "(", ")", ")", ";", "switch", "(", "mShape", ")", "{", "case", "SHAPE_RECTANGLE", ":", "canvas", ".", "drawRect", "(", "mCanvasRect", ",", "mCanvasPaint", ")", ";", "break", ";", "case", "SHAPE_OVAL", ":", "canvas", ".", "drawOval", "(", "mCanvasRect", ",", "mCanvasPaint", ")", ";", "break", ";", "case", "SHAPE_STAR_3_VERTICES", ":", "case", "SHAPE_STAR_4_VERTICES", ":", "case", "SHAPE_STAR_5_VERTICES", ":", "case", "SHAPE_STAR_6_VERTICES", ":", "drawStar", "(", "canvas", ",", "mShape", ")", ";", "break", ";", "case", "SHAPE_HEART", ":", "drawHeart", "(", "canvas", ")", ";", "break", ";", "}", "}" ]
draw's specified shape @param canvas on which shape has to be drawn
[ "draw", "s", "specified", "shape" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/ShapeBadgeItem.java#L174-L193
22,665
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/ShapeBadgeItem.java
ShapeBadgeItem.refreshMargin
private void refreshMargin() { if (isWeakReferenceValid()) { ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getTextView().get().getLayoutParams(); layoutParams.bottomMargin = mEdgeMarginInPx; layoutParams.topMargin = mEdgeMarginInPx; layoutParams.rightMargin = mEdgeMarginInPx; layoutParams.leftMargin = mEdgeMarginInPx; getTextView().get().setLayoutParams(layoutParams); } }
java
private void refreshMargin() { if (isWeakReferenceValid()) { ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getTextView().get().getLayoutParams(); layoutParams.bottomMargin = mEdgeMarginInPx; layoutParams.topMargin = mEdgeMarginInPx; layoutParams.rightMargin = mEdgeMarginInPx; layoutParams.leftMargin = mEdgeMarginInPx; getTextView().get().setLayoutParams(layoutParams); } }
[ "private", "void", "refreshMargin", "(", ")", "{", "if", "(", "isWeakReferenceValid", "(", ")", ")", "{", "ViewGroup", ".", "MarginLayoutParams", "layoutParams", "=", "(", "ViewGroup", ".", "MarginLayoutParams", ")", "getTextView", "(", ")", ".", "get", "(", ")", ".", "getLayoutParams", "(", ")", ";", "layoutParams", ".", "bottomMargin", "=", "mEdgeMarginInPx", ";", "layoutParams", ".", "topMargin", "=", "mEdgeMarginInPx", ";", "layoutParams", ".", "rightMargin", "=", "mEdgeMarginInPx", ";", "layoutParams", ".", "leftMargin", "=", "mEdgeMarginInPx", ";", "getTextView", "(", ")", ".", "get", "(", ")", ".", "setLayoutParams", "(", "layoutParams", ")", ";", "}", "}" ]
refresh's margin if set
[ "refresh", "s", "margin", "if", "set" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/ShapeBadgeItem.java#L268-L277
22,666
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/TextBadgeItem.java
TextBadgeItem.refreshDrawable
private void refreshDrawable() { if (isWeakReferenceValid()) { TextView textView = getTextView().get(); textView.setBackgroundDrawable(getBadgeDrawable(textView.getContext())); } }
java
private void refreshDrawable() { if (isWeakReferenceValid()) { TextView textView = getTextView().get(); textView.setBackgroundDrawable(getBadgeDrawable(textView.getContext())); } }
[ "private", "void", "refreshDrawable", "(", ")", "{", "if", "(", "isWeakReferenceValid", "(", ")", ")", "{", "TextView", "textView", "=", "getTextView", "(", ")", ".", "get", "(", ")", ";", "textView", ".", "setBackgroundDrawable", "(", "getBadgeDrawable", "(", "textView", ".", "getContext", "(", ")", ")", ")", ";", "}", "}" ]
refresh's background drawable
[ "refresh", "s", "background", "drawable" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/TextBadgeItem.java#L275-L280
22,667
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/TextBadgeItem.java
TextBadgeItem.setTextColor
private void setTextColor() { if (isWeakReferenceValid()) { TextView textView = getTextView().get(); textView.setTextColor(getTextColor(textView.getContext())); } }
java
private void setTextColor() { if (isWeakReferenceValid()) { TextView textView = getTextView().get(); textView.setTextColor(getTextColor(textView.getContext())); } }
[ "private", "void", "setTextColor", "(", ")", "{", "if", "(", "isWeakReferenceValid", "(", ")", ")", "{", "TextView", "textView", "=", "getTextView", "(", ")", ".", "get", "(", ")", ";", "textView", ".", "setTextColor", "(", "getTextColor", "(", "textView", ".", "getContext", "(", ")", ")", ")", ";", "}", "}" ]
set's new text color
[ "set", "s", "new", "text", "color" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/TextBadgeItem.java#L285-L290
22,668
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BadgeItem.java
BadgeItem.bindToBottomTab
void bindToBottomTab(BottomNavigationTab bottomNavigationTab) { // set initial bindings bottomNavigationTab.badgeView.clearPrevious(); if (bottomNavigationTab.badgeItem != null) { // removing old reference bottomNavigationTab.badgeItem.setTextView(null); } bottomNavigationTab.setBadgeItem(this); setTextView(bottomNavigationTab.badgeView); // allow sub class to modify the things bindToBottomTabInternal(bottomNavigationTab); // make view visible because gone by default bottomNavigationTab.badgeView.setVisibility(View.VISIBLE); // set layout params based on gravity FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) bottomNavigationTab.badgeView.getLayoutParams(); layoutParams.gravity = getGravity(); bottomNavigationTab.badgeView.setLayoutParams(layoutParams); // if hidden hide if (isHidden()) { // if hide is called before the initialisation of bottom-bar this will handle that // by hiding it. hide(); } }
java
void bindToBottomTab(BottomNavigationTab bottomNavigationTab) { // set initial bindings bottomNavigationTab.badgeView.clearPrevious(); if (bottomNavigationTab.badgeItem != null) { // removing old reference bottomNavigationTab.badgeItem.setTextView(null); } bottomNavigationTab.setBadgeItem(this); setTextView(bottomNavigationTab.badgeView); // allow sub class to modify the things bindToBottomTabInternal(bottomNavigationTab); // make view visible because gone by default bottomNavigationTab.badgeView.setVisibility(View.VISIBLE); // set layout params based on gravity FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) bottomNavigationTab.badgeView.getLayoutParams(); layoutParams.gravity = getGravity(); bottomNavigationTab.badgeView.setLayoutParams(layoutParams); // if hidden hide if (isHidden()) { // if hide is called before the initialisation of bottom-bar this will handle that // by hiding it. hide(); } }
[ "void", "bindToBottomTab", "(", "BottomNavigationTab", "bottomNavigationTab", ")", "{", "// set initial bindings", "bottomNavigationTab", ".", "badgeView", ".", "clearPrevious", "(", ")", ";", "if", "(", "bottomNavigationTab", ".", "badgeItem", "!=", "null", ")", "{", "// removing old reference", "bottomNavigationTab", ".", "badgeItem", ".", "setTextView", "(", "null", ")", ";", "}", "bottomNavigationTab", ".", "setBadgeItem", "(", "this", ")", ";", "setTextView", "(", "bottomNavigationTab", ".", "badgeView", ")", ";", "// allow sub class to modify the things", "bindToBottomTabInternal", "(", "bottomNavigationTab", ")", ";", "// make view visible because gone by default", "bottomNavigationTab", ".", "badgeView", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "// set layout params based on gravity", "FrameLayout", ".", "LayoutParams", "layoutParams", "=", "(", "FrameLayout", ".", "LayoutParams", ")", "bottomNavigationTab", ".", "badgeView", ".", "getLayoutParams", "(", ")", ";", "layoutParams", ".", "gravity", "=", "getGravity", "(", ")", ";", "bottomNavigationTab", ".", "badgeView", ".", "setLayoutParams", "(", "layoutParams", ")", ";", "// if hidden hide", "if", "(", "isHidden", "(", ")", ")", "{", "// if hide is called before the initialisation of bottom-bar this will handle that", "// by hiding it.", "hide", "(", ")", ";", "}", "}" ]
binds all badgeItem, BottomNavigationTab and BadgeTextView @param bottomNavigationTab to which badgeItem needs to be attached
[ "binds", "all", "badgeItem", "BottomNavigationTab", "and", "BadgeTextView" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BadgeItem.java#L91-L118
22,669
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/utils/Utils.java
Utils.fetchContextColor
public static int fetchContextColor(Context context, int androidAttribute) { TypedValue typedValue = new TypedValue(); TypedArray a = context.obtainStyledAttributes(typedValue.data, new int[]{androidAttribute}); int color = a.getColor(0, 0); a.recycle(); return color; }
java
public static int fetchContextColor(Context context, int androidAttribute) { TypedValue typedValue = new TypedValue(); TypedArray a = context.obtainStyledAttributes(typedValue.data, new int[]{androidAttribute}); int color = a.getColor(0, 0); a.recycle(); return color; }
[ "public", "static", "int", "fetchContextColor", "(", "Context", "context", ",", "int", "androidAttribute", ")", "{", "TypedValue", "typedValue", "=", "new", "TypedValue", "(", ")", ";", "TypedArray", "a", "=", "context", ".", "obtainStyledAttributes", "(", "typedValue", ".", "data", ",", "new", "int", "[", "]", "{", "androidAttribute", "}", ")", ";", "int", "color", "=", "a", ".", "getColor", "(", "0", ",", "0", ")", ";", "a", ".", "recycle", "(", ")", ";", "return", "color", ";", "}" ]
This method can be extended to get all android attributes color, string, dimension ...etc @param context used to fetch android attribute @param androidAttribute attribute codes like R.attr.colorAccent @return in this case color of android attribute
[ "This", "method", "can", "be", "extended", "to", "get", "all", "android", "attributes", "color", "string", "dimension", "...", "etc" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/utils/Utils.java#L42-L51
22,670
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java
BottomNavigationBar.parseAttrs
private void parseAttrs(Context context, AttributeSet attrs) { if (attrs != null) { TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.BottomNavigationBar, 0, 0); mActiveColor = typedArray.getColor(R.styleable.BottomNavigationBar_bnbActiveColor, Utils.fetchContextColor(context, R.attr.colorAccent)); mInActiveColor = typedArray.getColor(R.styleable.BottomNavigationBar_bnbInactiveColor, Color.LTGRAY); mBackgroundColor = typedArray.getColor(R.styleable.BottomNavigationBar_bnbBackgroundColor, Color.WHITE); mAutoHideEnabled = typedArray.getBoolean(R.styleable.BottomNavigationBar_bnbAutoHideEnabled, true); mElevation = typedArray.getDimension(R.styleable.BottomNavigationBar_bnbElevation, getResources().getDimension(R.dimen.bottom_navigation_elevation)); setAnimationDuration(typedArray.getInt(R.styleable.BottomNavigationBar_bnbAnimationDuration, DEFAULT_ANIMATION_DURATION)); switch (typedArray.getInt(R.styleable.BottomNavigationBar_bnbMode, MODE_DEFAULT)) { case MODE_FIXED: mMode = MODE_FIXED; break; case MODE_SHIFTING: mMode = MODE_SHIFTING; break; case MODE_FIXED_NO_TITLE: mMode = MODE_FIXED_NO_TITLE; break; case MODE_SHIFTING_NO_TITLE: mMode = MODE_SHIFTING_NO_TITLE; break; case MODE_DEFAULT: default: mMode = MODE_DEFAULT; break; } switch (typedArray.getInt(R.styleable.BottomNavigationBar_bnbBackgroundStyle, BACKGROUND_STYLE_DEFAULT)) { case BACKGROUND_STYLE_STATIC: mBackgroundStyle = BACKGROUND_STYLE_STATIC; break; case BACKGROUND_STYLE_RIPPLE: mBackgroundStyle = BACKGROUND_STYLE_RIPPLE; break; case BACKGROUND_STYLE_DEFAULT: default: mBackgroundStyle = BACKGROUND_STYLE_DEFAULT; break; } typedArray.recycle(); } else { mActiveColor = Utils.fetchContextColor(context, R.attr.colorAccent); mInActiveColor = Color.LTGRAY; mBackgroundColor = Color.WHITE; mElevation = getResources().getDimension(R.dimen.bottom_navigation_elevation); } }
java
private void parseAttrs(Context context, AttributeSet attrs) { if (attrs != null) { TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.BottomNavigationBar, 0, 0); mActiveColor = typedArray.getColor(R.styleable.BottomNavigationBar_bnbActiveColor, Utils.fetchContextColor(context, R.attr.colorAccent)); mInActiveColor = typedArray.getColor(R.styleable.BottomNavigationBar_bnbInactiveColor, Color.LTGRAY); mBackgroundColor = typedArray.getColor(R.styleable.BottomNavigationBar_bnbBackgroundColor, Color.WHITE); mAutoHideEnabled = typedArray.getBoolean(R.styleable.BottomNavigationBar_bnbAutoHideEnabled, true); mElevation = typedArray.getDimension(R.styleable.BottomNavigationBar_bnbElevation, getResources().getDimension(R.dimen.bottom_navigation_elevation)); setAnimationDuration(typedArray.getInt(R.styleable.BottomNavigationBar_bnbAnimationDuration, DEFAULT_ANIMATION_DURATION)); switch (typedArray.getInt(R.styleable.BottomNavigationBar_bnbMode, MODE_DEFAULT)) { case MODE_FIXED: mMode = MODE_FIXED; break; case MODE_SHIFTING: mMode = MODE_SHIFTING; break; case MODE_FIXED_NO_TITLE: mMode = MODE_FIXED_NO_TITLE; break; case MODE_SHIFTING_NO_TITLE: mMode = MODE_SHIFTING_NO_TITLE; break; case MODE_DEFAULT: default: mMode = MODE_DEFAULT; break; } switch (typedArray.getInt(R.styleable.BottomNavigationBar_bnbBackgroundStyle, BACKGROUND_STYLE_DEFAULT)) { case BACKGROUND_STYLE_STATIC: mBackgroundStyle = BACKGROUND_STYLE_STATIC; break; case BACKGROUND_STYLE_RIPPLE: mBackgroundStyle = BACKGROUND_STYLE_RIPPLE; break; case BACKGROUND_STYLE_DEFAULT: default: mBackgroundStyle = BACKGROUND_STYLE_DEFAULT; break; } typedArray.recycle(); } else { mActiveColor = Utils.fetchContextColor(context, R.attr.colorAccent); mInActiveColor = Color.LTGRAY; mBackgroundColor = Color.WHITE; mElevation = getResources().getDimension(R.dimen.bottom_navigation_elevation); } }
[ "private", "void", "parseAttrs", "(", "Context", "context", ",", "AttributeSet", "attrs", ")", "{", "if", "(", "attrs", "!=", "null", ")", "{", "TypedArray", "typedArray", "=", "context", ".", "getTheme", "(", ")", ".", "obtainStyledAttributes", "(", "attrs", ",", "R", ".", "styleable", ".", "BottomNavigationBar", ",", "0", ",", "0", ")", ";", "mActiveColor", "=", "typedArray", ".", "getColor", "(", "R", ".", "styleable", ".", "BottomNavigationBar_bnbActiveColor", ",", "Utils", ".", "fetchContextColor", "(", "context", ",", "R", ".", "attr", ".", "colorAccent", ")", ")", ";", "mInActiveColor", "=", "typedArray", ".", "getColor", "(", "R", ".", "styleable", ".", "BottomNavigationBar_bnbInactiveColor", ",", "Color", ".", "LTGRAY", ")", ";", "mBackgroundColor", "=", "typedArray", ".", "getColor", "(", "R", ".", "styleable", ".", "BottomNavigationBar_bnbBackgroundColor", ",", "Color", ".", "WHITE", ")", ";", "mAutoHideEnabled", "=", "typedArray", ".", "getBoolean", "(", "R", ".", "styleable", ".", "BottomNavigationBar_bnbAutoHideEnabled", ",", "true", ")", ";", "mElevation", "=", "typedArray", ".", "getDimension", "(", "R", ".", "styleable", ".", "BottomNavigationBar_bnbElevation", ",", "getResources", "(", ")", ".", "getDimension", "(", "R", ".", "dimen", ".", "bottom_navigation_elevation", ")", ")", ";", "setAnimationDuration", "(", "typedArray", ".", "getInt", "(", "R", ".", "styleable", ".", "BottomNavigationBar_bnbAnimationDuration", ",", "DEFAULT_ANIMATION_DURATION", ")", ")", ";", "switch", "(", "typedArray", ".", "getInt", "(", "R", ".", "styleable", ".", "BottomNavigationBar_bnbMode", ",", "MODE_DEFAULT", ")", ")", "{", "case", "MODE_FIXED", ":", "mMode", "=", "MODE_FIXED", ";", "break", ";", "case", "MODE_SHIFTING", ":", "mMode", "=", "MODE_SHIFTING", ";", "break", ";", "case", "MODE_FIXED_NO_TITLE", ":", "mMode", "=", "MODE_FIXED_NO_TITLE", ";", "break", ";", "case", "MODE_SHIFTING_NO_TITLE", ":", "mMode", "=", "MODE_SHIFTING_NO_TITLE", ";", "break", ";", "case", "MODE_DEFAULT", ":", "default", ":", "mMode", "=", "MODE_DEFAULT", ";", "break", ";", "}", "switch", "(", "typedArray", ".", "getInt", "(", "R", ".", "styleable", ".", "BottomNavigationBar_bnbBackgroundStyle", ",", "BACKGROUND_STYLE_DEFAULT", ")", ")", "{", "case", "BACKGROUND_STYLE_STATIC", ":", "mBackgroundStyle", "=", "BACKGROUND_STYLE_STATIC", ";", "break", ";", "case", "BACKGROUND_STYLE_RIPPLE", ":", "mBackgroundStyle", "=", "BACKGROUND_STYLE_RIPPLE", ";", "break", ";", "case", "BACKGROUND_STYLE_DEFAULT", ":", "default", ":", "mBackgroundStyle", "=", "BACKGROUND_STYLE_DEFAULT", ";", "break", ";", "}", "typedArray", ".", "recycle", "(", ")", ";", "}", "else", "{", "mActiveColor", "=", "Utils", ".", "fetchContextColor", "(", "context", ",", "R", ".", "attr", ".", "colorAccent", ")", ";", "mInActiveColor", "=", "Color", ".", "LTGRAY", ";", "mBackgroundColor", "=", "Color", ".", "WHITE", ";", "mElevation", "=", "getResources", "(", ")", ".", "getDimension", "(", "R", ".", "dimen", ".", "bottom_navigation_elevation", ")", ";", "}", "}" ]
This method initiates the bottomNavigationBar properties, Tries to get them form XML if not preset sets them to their default values. @param context context of the bottomNavigationBar @param attrs attributes mentioned in the layout XML by user
[ "This", "method", "initiates", "the", "bottomNavigationBar", "properties", "Tries", "to", "get", "them", "form", "XML", "if", "not", "preset", "sets", "them", "to", "their", "default", "values", "." ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java#L146-L203
22,671
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java
BottomNavigationBar.init
private void init() { // MarginLayoutParams marginParams = new ViewGroup.MarginLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getContext().getResources().getDimension(R.dimen.bottom_navigation_padded_height))); // marginParams.setMargins(0, (int) getContext().getResources().getDimension(R.dimen.bottom_navigation_top_margin_correction), 0, 0); setLayoutParams(new ViewGroup.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))); LayoutInflater inflater = LayoutInflater.from(getContext()); View parentView = inflater.inflate(R.layout.bottom_navigation_bar_container, this, true); mBackgroundOverlay = parentView.findViewById(R.id.bottom_navigation_bar_overLay); mContainer = parentView.findViewById(R.id.bottom_navigation_bar_container); mTabContainer = parentView.findViewById(R.id.bottom_navigation_bar_item_container); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.setOutlineProvider(ViewOutlineProvider.BOUNDS); } else { //to do } ViewCompat.setElevation(this, mElevation); setClipToPadding(false); }
java
private void init() { // MarginLayoutParams marginParams = new ViewGroup.MarginLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getContext().getResources().getDimension(R.dimen.bottom_navigation_padded_height))); // marginParams.setMargins(0, (int) getContext().getResources().getDimension(R.dimen.bottom_navigation_top_margin_correction), 0, 0); setLayoutParams(new ViewGroup.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))); LayoutInflater inflater = LayoutInflater.from(getContext()); View parentView = inflater.inflate(R.layout.bottom_navigation_bar_container, this, true); mBackgroundOverlay = parentView.findViewById(R.id.bottom_navigation_bar_overLay); mContainer = parentView.findViewById(R.id.bottom_navigation_bar_container); mTabContainer = parentView.findViewById(R.id.bottom_navigation_bar_item_container); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.setOutlineProvider(ViewOutlineProvider.BOUNDS); } else { //to do } ViewCompat.setElevation(this, mElevation); setClipToPadding(false); }
[ "private", "void", "init", "(", ")", "{", "// MarginLayoutParams marginParams = new ViewGroup.MarginLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getContext().getResources().getDimension(R.dimen.bottom_navigation_padded_height)));", "// marginParams.setMargins(0, (int) getContext().getResources().getDimension(R.dimen.bottom_navigation_top_margin_correction), 0, 0);", "setLayoutParams", "(", "new", "ViewGroup", ".", "LayoutParams", "(", "new", "ViewGroup", ".", "LayoutParams", "(", "ViewGroup", ".", "LayoutParams", ".", "MATCH_PARENT", ",", "ViewGroup", ".", "LayoutParams", ".", "WRAP_CONTENT", ")", ")", ")", ";", "LayoutInflater", "inflater", "=", "LayoutInflater", ".", "from", "(", "getContext", "(", ")", ")", ";", "View", "parentView", "=", "inflater", ".", "inflate", "(", "R", ".", "layout", ".", "bottom_navigation_bar_container", ",", "this", ",", "true", ")", ";", "mBackgroundOverlay", "=", "parentView", ".", "findViewById", "(", "R", ".", "id", ".", "bottom_navigation_bar_overLay", ")", ";", "mContainer", "=", "parentView", ".", "findViewById", "(", "R", ".", "id", ".", "bottom_navigation_bar_container", ")", ";", "mTabContainer", "=", "parentView", ".", "findViewById", "(", "R", ".", "id", ".", "bottom_navigation_bar_item_container", ")", ";", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", ">=", "Build", ".", "VERSION_CODES", ".", "LOLLIPOP", ")", "{", "this", ".", "setOutlineProvider", "(", "ViewOutlineProvider", ".", "BOUNDS", ")", ";", "}", "else", "{", "//to do", "}", "ViewCompat", ".", "setElevation", "(", "this", ",", "mElevation", ")", ";", "setClipToPadding", "(", "false", ")", ";", "}" ]
This method initiates the bottomNavigationBar and handles layout related values
[ "This", "method", "initiates", "the", "bottomNavigationBar", "and", "handles", "layout", "related", "values" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java#L208-L229
22,672
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java
BottomNavigationBar.initialise
public void initialise() { mSelectedPosition = DEFAULT_SELECTED_POSITION; mBottomNavigationTabs.clear(); if (!mBottomNavigationItems.isEmpty()) { mTabContainer.removeAllViews(); if (mMode == MODE_DEFAULT) { if (mBottomNavigationItems.size() <= MIN_SIZE) { mMode = MODE_FIXED; } else { mMode = MODE_SHIFTING; } } if (mBackgroundStyle == BACKGROUND_STYLE_DEFAULT) { if (mMode == MODE_FIXED) { mBackgroundStyle = BACKGROUND_STYLE_STATIC; } else { mBackgroundStyle = BACKGROUND_STYLE_RIPPLE; } } if (mBackgroundStyle == BACKGROUND_STYLE_STATIC) { mBackgroundOverlay.setVisibility(View.GONE); mContainer.setBackgroundColor(mBackgroundColor); } int screenWidth = Utils.getScreenWidth(getContext()); if (mMode == MODE_FIXED || mMode == MODE_FIXED_NO_TITLE) { int[] widths = BottomNavigationHelper.getMeasurementsForFixedMode(getContext(), screenWidth, mBottomNavigationItems.size(), mScrollable); int itemWidth = widths[0]; for (BottomNavigationItem currentItem : mBottomNavigationItems) { FixedBottomNavigationTab bottomNavigationTab = new FixedBottomNavigationTab(getContext()); setUpTab(mMode == MODE_FIXED_NO_TITLE, bottomNavigationTab, currentItem, itemWidth, itemWidth); } } else if (mMode == MODE_SHIFTING || mMode == MODE_SHIFTING_NO_TITLE) { int[] widths = BottomNavigationHelper.getMeasurementsForShiftingMode(getContext(), screenWidth, mBottomNavigationItems.size(), mScrollable); int itemWidth = widths[0]; int itemActiveWidth = widths[1]; for (BottomNavigationItem currentItem : mBottomNavigationItems) { ShiftingBottomNavigationTab bottomNavigationTab = new ShiftingBottomNavigationTab(getContext()); setUpTab(mMode == MODE_SHIFTING_NO_TITLE, bottomNavigationTab, currentItem, itemWidth, itemActiveWidth); } } if (mBottomNavigationTabs.size() > mFirstSelectedPosition) { selectTabInternal(mFirstSelectedPosition, true, false, false); } else if (!mBottomNavigationTabs.isEmpty()) { selectTabInternal(0, true, false, false); } } }
java
public void initialise() { mSelectedPosition = DEFAULT_SELECTED_POSITION; mBottomNavigationTabs.clear(); if (!mBottomNavigationItems.isEmpty()) { mTabContainer.removeAllViews(); if (mMode == MODE_DEFAULT) { if (mBottomNavigationItems.size() <= MIN_SIZE) { mMode = MODE_FIXED; } else { mMode = MODE_SHIFTING; } } if (mBackgroundStyle == BACKGROUND_STYLE_DEFAULT) { if (mMode == MODE_FIXED) { mBackgroundStyle = BACKGROUND_STYLE_STATIC; } else { mBackgroundStyle = BACKGROUND_STYLE_RIPPLE; } } if (mBackgroundStyle == BACKGROUND_STYLE_STATIC) { mBackgroundOverlay.setVisibility(View.GONE); mContainer.setBackgroundColor(mBackgroundColor); } int screenWidth = Utils.getScreenWidth(getContext()); if (mMode == MODE_FIXED || mMode == MODE_FIXED_NO_TITLE) { int[] widths = BottomNavigationHelper.getMeasurementsForFixedMode(getContext(), screenWidth, mBottomNavigationItems.size(), mScrollable); int itemWidth = widths[0]; for (BottomNavigationItem currentItem : mBottomNavigationItems) { FixedBottomNavigationTab bottomNavigationTab = new FixedBottomNavigationTab(getContext()); setUpTab(mMode == MODE_FIXED_NO_TITLE, bottomNavigationTab, currentItem, itemWidth, itemWidth); } } else if (mMode == MODE_SHIFTING || mMode == MODE_SHIFTING_NO_TITLE) { int[] widths = BottomNavigationHelper.getMeasurementsForShiftingMode(getContext(), screenWidth, mBottomNavigationItems.size(), mScrollable); int itemWidth = widths[0]; int itemActiveWidth = widths[1]; for (BottomNavigationItem currentItem : mBottomNavigationItems) { ShiftingBottomNavigationTab bottomNavigationTab = new ShiftingBottomNavigationTab(getContext()); setUpTab(mMode == MODE_SHIFTING_NO_TITLE, bottomNavigationTab, currentItem, itemWidth, itemActiveWidth); } } if (mBottomNavigationTabs.size() > mFirstSelectedPosition) { selectTabInternal(mFirstSelectedPosition, true, false, false); } else if (!mBottomNavigationTabs.isEmpty()) { selectTabInternal(0, true, false, false); } } }
[ "public", "void", "initialise", "(", ")", "{", "mSelectedPosition", "=", "DEFAULT_SELECTED_POSITION", ";", "mBottomNavigationTabs", ".", "clear", "(", ")", ";", "if", "(", "!", "mBottomNavigationItems", ".", "isEmpty", "(", ")", ")", "{", "mTabContainer", ".", "removeAllViews", "(", ")", ";", "if", "(", "mMode", "==", "MODE_DEFAULT", ")", "{", "if", "(", "mBottomNavigationItems", ".", "size", "(", ")", "<=", "MIN_SIZE", ")", "{", "mMode", "=", "MODE_FIXED", ";", "}", "else", "{", "mMode", "=", "MODE_SHIFTING", ";", "}", "}", "if", "(", "mBackgroundStyle", "==", "BACKGROUND_STYLE_DEFAULT", ")", "{", "if", "(", "mMode", "==", "MODE_FIXED", ")", "{", "mBackgroundStyle", "=", "BACKGROUND_STYLE_STATIC", ";", "}", "else", "{", "mBackgroundStyle", "=", "BACKGROUND_STYLE_RIPPLE", ";", "}", "}", "if", "(", "mBackgroundStyle", "==", "BACKGROUND_STYLE_STATIC", ")", "{", "mBackgroundOverlay", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "mContainer", ".", "setBackgroundColor", "(", "mBackgroundColor", ")", ";", "}", "int", "screenWidth", "=", "Utils", ".", "getScreenWidth", "(", "getContext", "(", ")", ")", ";", "if", "(", "mMode", "==", "MODE_FIXED", "||", "mMode", "==", "MODE_FIXED_NO_TITLE", ")", "{", "int", "[", "]", "widths", "=", "BottomNavigationHelper", ".", "getMeasurementsForFixedMode", "(", "getContext", "(", ")", ",", "screenWidth", ",", "mBottomNavigationItems", ".", "size", "(", ")", ",", "mScrollable", ")", ";", "int", "itemWidth", "=", "widths", "[", "0", "]", ";", "for", "(", "BottomNavigationItem", "currentItem", ":", "mBottomNavigationItems", ")", "{", "FixedBottomNavigationTab", "bottomNavigationTab", "=", "new", "FixedBottomNavigationTab", "(", "getContext", "(", ")", ")", ";", "setUpTab", "(", "mMode", "==", "MODE_FIXED_NO_TITLE", ",", "bottomNavigationTab", ",", "currentItem", ",", "itemWidth", ",", "itemWidth", ")", ";", "}", "}", "else", "if", "(", "mMode", "==", "MODE_SHIFTING", "||", "mMode", "==", "MODE_SHIFTING_NO_TITLE", ")", "{", "int", "[", "]", "widths", "=", "BottomNavigationHelper", ".", "getMeasurementsForShiftingMode", "(", "getContext", "(", ")", ",", "screenWidth", ",", "mBottomNavigationItems", ".", "size", "(", ")", ",", "mScrollable", ")", ";", "int", "itemWidth", "=", "widths", "[", "0", "]", ";", "int", "itemActiveWidth", "=", "widths", "[", "1", "]", ";", "for", "(", "BottomNavigationItem", "currentItem", ":", "mBottomNavigationItems", ")", "{", "ShiftingBottomNavigationTab", "bottomNavigationTab", "=", "new", "ShiftingBottomNavigationTab", "(", "getContext", "(", ")", ")", ";", "setUpTab", "(", "mMode", "==", "MODE_SHIFTING_NO_TITLE", ",", "bottomNavigationTab", ",", "currentItem", ",", "itemWidth", ",", "itemActiveWidth", ")", ";", "}", "}", "if", "(", "mBottomNavigationTabs", ".", "size", "(", ")", ">", "mFirstSelectedPosition", ")", "{", "selectTabInternal", "(", "mFirstSelectedPosition", ",", "true", ",", "false", ",", "false", ")", ";", "}", "else", "if", "(", "!", "mBottomNavigationTabs", ".", "isEmpty", "(", ")", ")", "{", "selectTabInternal", "(", "0", ",", "true", ",", "false", ",", "false", ")", ";", "}", "}", "}" ]
This method should be called at the end of all customisation method. This method will take all changes in to consideration and redraws tabs.
[ "This", "method", "should", "be", "called", "at", "the", "end", "of", "all", "customisation", "method", ".", "This", "method", "will", "take", "all", "changes", "in", "to", "consideration", "and", "redraws", "tabs", "." ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java#L360-L417
22,673
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java
BottomNavigationBar.clearAll
public void clearAll() { mTabContainer.removeAllViews(); mBottomNavigationTabs.clear(); mBottomNavigationItems.clear(); mBackgroundOverlay.setVisibility(View.GONE); mContainer.setBackgroundColor(Color.TRANSPARENT); mSelectedPosition = DEFAULT_SELECTED_POSITION; }
java
public void clearAll() { mTabContainer.removeAllViews(); mBottomNavigationTabs.clear(); mBottomNavigationItems.clear(); mBackgroundOverlay.setVisibility(View.GONE); mContainer.setBackgroundColor(Color.TRANSPARENT); mSelectedPosition = DEFAULT_SELECTED_POSITION; }
[ "public", "void", "clearAll", "(", ")", "{", "mTabContainer", ".", "removeAllViews", "(", ")", ";", "mBottomNavigationTabs", ".", "clear", "(", ")", ";", "mBottomNavigationItems", ".", "clear", "(", ")", ";", "mBackgroundOverlay", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "mContainer", ".", "setBackgroundColor", "(", "Color", ".", "TRANSPARENT", ")", ";", "mSelectedPosition", "=", "DEFAULT_SELECTED_POSITION", ";", "}" ]
Clears all stored data and this helps to re-initialise tabs from scratch
[ "Clears", "all", "stored", "data", "and", "this", "helps", "to", "re", "-", "initialise", "tabs", "from", "scratch" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java#L447-L454
22,674
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java
BottomNavigationBar.setUpTab
private void setUpTab(boolean isNoTitleMode, BottomNavigationTab bottomNavigationTab, BottomNavigationItem currentItem, int itemWidth, int itemActiveWidth) { bottomNavigationTab.setIsNoTitleMode(isNoTitleMode); bottomNavigationTab.setInactiveWidth(itemWidth); bottomNavigationTab.setActiveWidth(itemActiveWidth); bottomNavigationTab.setPosition(mBottomNavigationItems.indexOf(currentItem)); bottomNavigationTab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { BottomNavigationTab bottomNavigationTabView = (BottomNavigationTab) v; selectTabInternal(bottomNavigationTabView.getPosition(), false, true, false); } }); mBottomNavigationTabs.add(bottomNavigationTab); BottomNavigationHelper.bindTabWithData(currentItem, bottomNavigationTab, this); bottomNavigationTab.initialise(mBackgroundStyle == BACKGROUND_STYLE_STATIC); mTabContainer.addView(bottomNavigationTab); }
java
private void setUpTab(boolean isNoTitleMode, BottomNavigationTab bottomNavigationTab, BottomNavigationItem currentItem, int itemWidth, int itemActiveWidth) { bottomNavigationTab.setIsNoTitleMode(isNoTitleMode); bottomNavigationTab.setInactiveWidth(itemWidth); bottomNavigationTab.setActiveWidth(itemActiveWidth); bottomNavigationTab.setPosition(mBottomNavigationItems.indexOf(currentItem)); bottomNavigationTab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { BottomNavigationTab bottomNavigationTabView = (BottomNavigationTab) v; selectTabInternal(bottomNavigationTabView.getPosition(), false, true, false); } }); mBottomNavigationTabs.add(bottomNavigationTab); BottomNavigationHelper.bindTabWithData(currentItem, bottomNavigationTab, this); bottomNavigationTab.initialise(mBackgroundStyle == BACKGROUND_STYLE_STATIC); mTabContainer.addView(bottomNavigationTab); }
[ "private", "void", "setUpTab", "(", "boolean", "isNoTitleMode", ",", "BottomNavigationTab", "bottomNavigationTab", ",", "BottomNavigationItem", "currentItem", ",", "int", "itemWidth", ",", "int", "itemActiveWidth", ")", "{", "bottomNavigationTab", ".", "setIsNoTitleMode", "(", "isNoTitleMode", ")", ";", "bottomNavigationTab", ".", "setInactiveWidth", "(", "itemWidth", ")", ";", "bottomNavigationTab", ".", "setActiveWidth", "(", "itemActiveWidth", ")", ";", "bottomNavigationTab", ".", "setPosition", "(", "mBottomNavigationItems", ".", "indexOf", "(", "currentItem", ")", ")", ";", "bottomNavigationTab", ".", "setOnClickListener", "(", "new", "OnClickListener", "(", ")", "{", "@", "Override", "public", "void", "onClick", "(", "View", "v", ")", "{", "BottomNavigationTab", "bottomNavigationTabView", "=", "(", "BottomNavigationTab", ")", "v", ";", "selectTabInternal", "(", "bottomNavigationTabView", ".", "getPosition", "(", ")", ",", "false", ",", "true", ",", "false", ")", ";", "}", "}", ")", ";", "mBottomNavigationTabs", ".", "add", "(", "bottomNavigationTab", ")", ";", "BottomNavigationHelper", ".", "bindTabWithData", "(", "currentItem", ",", "bottomNavigationTab", ",", "this", ")", ";", "bottomNavigationTab", ".", "initialise", "(", "mBackgroundStyle", "==", "BACKGROUND_STYLE_STATIC", ")", ";", "mTabContainer", ".", "addView", "(", "bottomNavigationTab", ")", ";", "}" ]
Internal method to setup tabs @param isNoTitleMode if no title mode is required @param bottomNavigationTab Tab item @param currentItem data structure for tab item @param itemWidth tab item in-active width @param itemActiveWidth tab item active width
[ "Internal", "method", "to", "setup", "tabs" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java#L492-L513
22,675
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java
BottomNavigationBar.selectTabInternal
private void selectTabInternal(int newPosition, boolean firstTab, boolean callListener, boolean forcedSelection) { int oldPosition = mSelectedPosition; if (mSelectedPosition != newPosition) { if (mBackgroundStyle == BACKGROUND_STYLE_STATIC) { if (mSelectedPosition != -1) mBottomNavigationTabs.get(mSelectedPosition).unSelect(true, mAnimationDuration); mBottomNavigationTabs.get(newPosition).select(true, mAnimationDuration); } else if (mBackgroundStyle == BACKGROUND_STYLE_RIPPLE) { if (mSelectedPosition != -1) mBottomNavigationTabs.get(mSelectedPosition).unSelect(false, mAnimationDuration); mBottomNavigationTabs.get(newPosition).select(false, mAnimationDuration); final BottomNavigationTab clickedView = mBottomNavigationTabs.get(newPosition); if (firstTab) { // Running a ripple on the opening app won't be good so on firstTab this won't run. mContainer.setBackgroundColor(clickedView.getActiveColor()); mBackgroundOverlay.setVisibility(View.GONE); } else { mBackgroundOverlay.post(new Runnable() { @Override public void run() { // try { BottomNavigationHelper.setBackgroundWithRipple(clickedView, mContainer, mBackgroundOverlay, clickedView.getActiveColor(), mRippleAnimationDuration); // } catch (Exception e) { // mContainer.setBackgroundColor(clickedView.getActiveColor()); // mBackgroundOverlay.setVisibility(View.GONE); // } } }); } } mSelectedPosition = newPosition; } if (callListener) { sendListenerCall(oldPosition, newPosition, forcedSelection); } }
java
private void selectTabInternal(int newPosition, boolean firstTab, boolean callListener, boolean forcedSelection) { int oldPosition = mSelectedPosition; if (mSelectedPosition != newPosition) { if (mBackgroundStyle == BACKGROUND_STYLE_STATIC) { if (mSelectedPosition != -1) mBottomNavigationTabs.get(mSelectedPosition).unSelect(true, mAnimationDuration); mBottomNavigationTabs.get(newPosition).select(true, mAnimationDuration); } else if (mBackgroundStyle == BACKGROUND_STYLE_RIPPLE) { if (mSelectedPosition != -1) mBottomNavigationTabs.get(mSelectedPosition).unSelect(false, mAnimationDuration); mBottomNavigationTabs.get(newPosition).select(false, mAnimationDuration); final BottomNavigationTab clickedView = mBottomNavigationTabs.get(newPosition); if (firstTab) { // Running a ripple on the opening app won't be good so on firstTab this won't run. mContainer.setBackgroundColor(clickedView.getActiveColor()); mBackgroundOverlay.setVisibility(View.GONE); } else { mBackgroundOverlay.post(new Runnable() { @Override public void run() { // try { BottomNavigationHelper.setBackgroundWithRipple(clickedView, mContainer, mBackgroundOverlay, clickedView.getActiveColor(), mRippleAnimationDuration); // } catch (Exception e) { // mContainer.setBackgroundColor(clickedView.getActiveColor()); // mBackgroundOverlay.setVisibility(View.GONE); // } } }); } } mSelectedPosition = newPosition; } if (callListener) { sendListenerCall(oldPosition, newPosition, forcedSelection); } }
[ "private", "void", "selectTabInternal", "(", "int", "newPosition", ",", "boolean", "firstTab", ",", "boolean", "callListener", ",", "boolean", "forcedSelection", ")", "{", "int", "oldPosition", "=", "mSelectedPosition", ";", "if", "(", "mSelectedPosition", "!=", "newPosition", ")", "{", "if", "(", "mBackgroundStyle", "==", "BACKGROUND_STYLE_STATIC", ")", "{", "if", "(", "mSelectedPosition", "!=", "-", "1", ")", "mBottomNavigationTabs", ".", "get", "(", "mSelectedPosition", ")", ".", "unSelect", "(", "true", ",", "mAnimationDuration", ")", ";", "mBottomNavigationTabs", ".", "get", "(", "newPosition", ")", ".", "select", "(", "true", ",", "mAnimationDuration", ")", ";", "}", "else", "if", "(", "mBackgroundStyle", "==", "BACKGROUND_STYLE_RIPPLE", ")", "{", "if", "(", "mSelectedPosition", "!=", "-", "1", ")", "mBottomNavigationTabs", ".", "get", "(", "mSelectedPosition", ")", ".", "unSelect", "(", "false", ",", "mAnimationDuration", ")", ";", "mBottomNavigationTabs", ".", "get", "(", "newPosition", ")", ".", "select", "(", "false", ",", "mAnimationDuration", ")", ";", "final", "BottomNavigationTab", "clickedView", "=", "mBottomNavigationTabs", ".", "get", "(", "newPosition", ")", ";", "if", "(", "firstTab", ")", "{", "// Running a ripple on the opening app won't be good so on firstTab this won't run.", "mContainer", ".", "setBackgroundColor", "(", "clickedView", ".", "getActiveColor", "(", ")", ")", ";", "mBackgroundOverlay", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "else", "{", "mBackgroundOverlay", ".", "post", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "// try {", "BottomNavigationHelper", ".", "setBackgroundWithRipple", "(", "clickedView", ",", "mContainer", ",", "mBackgroundOverlay", ",", "clickedView", ".", "getActiveColor", "(", ")", ",", "mRippleAnimationDuration", ")", ";", "// } catch (Exception e) {", "// mContainer.setBackgroundColor(clickedView.getActiveColor());", "// mBackgroundOverlay.setVisibility(View.GONE);", "// }", "}", "}", ")", ";", "}", "}", "mSelectedPosition", "=", "newPosition", ";", "}", "if", "(", "callListener", ")", "{", "sendListenerCall", "(", "oldPosition", ",", "newPosition", ",", "forcedSelection", ")", ";", "}", "}" ]
Internal Method to select a tab @param newPosition to select a tab after bottom navigation bar is initialised @param firstTab if firstTab the no ripple animation will be done @param callListener is listener callbacks enabled for this change @param forcedSelection if bottom navigation bar forced to select tab (in this case call on selected irrespective of previous state
[ "Internal", "Method", "to", "select", "a", "tab" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java#L523-L560
22,676
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java
BottomNavigationBar.sendListenerCall
private void sendListenerCall(int oldPosition, int newPosition, boolean forcedSelection) { if (mTabSelectedListener != null) { // && oldPosition != -1) { if (forcedSelection) { mTabSelectedListener.onTabSelected(newPosition); } else { if (oldPosition == newPosition) { mTabSelectedListener.onTabReselected(newPosition); } else { mTabSelectedListener.onTabSelected(newPosition); if (oldPosition != -1) { mTabSelectedListener.onTabUnselected(oldPosition); } } } } }
java
private void sendListenerCall(int oldPosition, int newPosition, boolean forcedSelection) { if (mTabSelectedListener != null) { // && oldPosition != -1) { if (forcedSelection) { mTabSelectedListener.onTabSelected(newPosition); } else { if (oldPosition == newPosition) { mTabSelectedListener.onTabReselected(newPosition); } else { mTabSelectedListener.onTabSelected(newPosition); if (oldPosition != -1) { mTabSelectedListener.onTabUnselected(oldPosition); } } } } }
[ "private", "void", "sendListenerCall", "(", "int", "oldPosition", ",", "int", "newPosition", ",", "boolean", "forcedSelection", ")", "{", "if", "(", "mTabSelectedListener", "!=", "null", ")", "{", "// && oldPosition != -1) {", "if", "(", "forcedSelection", ")", "{", "mTabSelectedListener", ".", "onTabSelected", "(", "newPosition", ")", ";", "}", "else", "{", "if", "(", "oldPosition", "==", "newPosition", ")", "{", "mTabSelectedListener", ".", "onTabReselected", "(", "newPosition", ")", ";", "}", "else", "{", "mTabSelectedListener", ".", "onTabSelected", "(", "newPosition", ")", ";", "if", "(", "oldPosition", "!=", "-", "1", ")", "{", "mTabSelectedListener", ".", "onTabUnselected", "(", "oldPosition", ")", ";", "}", "}", "}", "}", "}" ]
Internal method used to send callbacks to listener @param oldPosition old selected tab position, -1 if this is first call @param newPosition newly selected tab position @param forcedSelection if bottom navigation bar forced to select tab (in this case call on selected irrespective of previous state
[ "Internal", "method", "used", "to", "send", "callbacks", "to", "listener" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java#L569-L585
22,677
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BadgeTextView.java
BadgeTextView.setDimens
void setDimens(int width, int height) { mAreDimensOverridden = true; mDesiredWidth = width; mDesiredHeight = height; requestLayout(); }
java
void setDimens(int width, int height) { mAreDimensOverridden = true; mDesiredWidth = width; mDesiredHeight = height; requestLayout(); }
[ "void", "setDimens", "(", "int", "width", ",", "int", "height", ")", "{", "mAreDimensOverridden", "=", "true", ";", "mDesiredWidth", "=", "width", ";", "mDesiredHeight", "=", "height", ";", "requestLayout", "(", ")", ";", "}" ]
if width and height of the view needs to be changed @param width new width that needs to be set @param height new height that needs to be set
[ "if", "width", "and", "height", "of", "the", "view", "needs", "to", "be", "changed" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BadgeTextView.java#L63-L68
22,678
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationHelper.java
BottomNavigationHelper.getMeasurementsForFixedMode
static int[] getMeasurementsForFixedMode(Context context, int screenWidth, int noOfTabs, boolean scrollable) { int[] result = new int[2]; int minWidth = (int) context.getResources().getDimension(R.dimen.fixed_min_width_small_views); int maxWidth = (int) context.getResources().getDimension(R.dimen.fixed_min_width); int itemWidth = screenWidth / noOfTabs; if (itemWidth < minWidth && scrollable) { itemWidth = (int) context.getResources().getDimension(R.dimen.fixed_min_width); } else if (itemWidth > maxWidth) { itemWidth = maxWidth; } result[0] = itemWidth; return result; }
java
static int[] getMeasurementsForFixedMode(Context context, int screenWidth, int noOfTabs, boolean scrollable) { int[] result = new int[2]; int minWidth = (int) context.getResources().getDimension(R.dimen.fixed_min_width_small_views); int maxWidth = (int) context.getResources().getDimension(R.dimen.fixed_min_width); int itemWidth = screenWidth / noOfTabs; if (itemWidth < minWidth && scrollable) { itemWidth = (int) context.getResources().getDimension(R.dimen.fixed_min_width); } else if (itemWidth > maxWidth) { itemWidth = maxWidth; } result[0] = itemWidth; return result; }
[ "static", "int", "[", "]", "getMeasurementsForFixedMode", "(", "Context", "context", ",", "int", "screenWidth", ",", "int", "noOfTabs", ",", "boolean", "scrollable", ")", "{", "int", "[", "]", "result", "=", "new", "int", "[", "2", "]", ";", "int", "minWidth", "=", "(", "int", ")", "context", ".", "getResources", "(", ")", ".", "getDimension", "(", "R", ".", "dimen", ".", "fixed_min_width_small_views", ")", ";", "int", "maxWidth", "=", "(", "int", ")", "context", ".", "getResources", "(", ")", ".", "getDimension", "(", "R", ".", "dimen", ".", "fixed_min_width", ")", ";", "int", "itemWidth", "=", "screenWidth", "/", "noOfTabs", ";", "if", "(", "itemWidth", "<", "minWidth", "&&", "scrollable", ")", "{", "itemWidth", "=", "(", "int", ")", "context", ".", "getResources", "(", ")", ".", "getDimension", "(", "R", ".", "dimen", ".", "fixed_min_width", ")", ";", "}", "else", "if", "(", "itemWidth", ">", "maxWidth", ")", "{", "itemWidth", "=", "maxWidth", ";", "}", "result", "[", "0", "]", "=", "itemWidth", ";", "return", "result", ";", "}" ]
Used to get Measurements for MODE_FIXED @param context to fetch measurements @param screenWidth total screen width @param noOfTabs no of bottom bar tabs @param scrollable is bottom bar scrollable @return width of each tab
[ "Used", "to", "get", "Measurements", "for", "MODE_FIXED" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationHelper.java#L35-L53
22,679
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationHelper.java
BottomNavigationHelper.getMeasurementsForShiftingMode
static int[] getMeasurementsForShiftingMode(Context context, int screenWidth, int noOfTabs, boolean scrollable) { int[] result = new int[2]; int minWidth = (int) context.getResources().getDimension(R.dimen.shifting_min_width_inactive); int maxWidth = (int) context.getResources().getDimension(R.dimen.shifting_max_width_inactive); double minPossibleWidth = minWidth * (noOfTabs + 0.5); double maxPossibleWidth = maxWidth * (noOfTabs + 0.75); int itemWidth; int itemActiveWidth; if (screenWidth < minPossibleWidth) { if (scrollable) { itemWidth = minWidth; itemActiveWidth = (int) (minWidth * 1.5); } else { itemWidth = (int) (screenWidth / (noOfTabs + 0.5)); itemActiveWidth = (int) (itemWidth * 1.5); } } else if (screenWidth > maxPossibleWidth) { itemWidth = maxWidth; itemActiveWidth = (int) (itemWidth * 1.75); } else { double minPossibleWidth1 = minWidth * (noOfTabs + 0.625); double minPossibleWidth2 = minWidth * (noOfTabs + 0.75); itemWidth = (int) (screenWidth / (noOfTabs + 0.5)); itemActiveWidth = (int) (itemWidth * 1.5); if (screenWidth > minPossibleWidth1) { itemWidth = (int) (screenWidth / (noOfTabs + 0.625)); itemActiveWidth = (int) (itemWidth * 1.625); if (screenWidth > minPossibleWidth2) { itemWidth = (int) (screenWidth / (noOfTabs + 0.75)); itemActiveWidth = (int) (itemWidth * 1.75); } } } result[0] = itemWidth; result[1] = itemActiveWidth; return result; }
java
static int[] getMeasurementsForShiftingMode(Context context, int screenWidth, int noOfTabs, boolean scrollable) { int[] result = new int[2]; int minWidth = (int) context.getResources().getDimension(R.dimen.shifting_min_width_inactive); int maxWidth = (int) context.getResources().getDimension(R.dimen.shifting_max_width_inactive); double minPossibleWidth = minWidth * (noOfTabs + 0.5); double maxPossibleWidth = maxWidth * (noOfTabs + 0.75); int itemWidth; int itemActiveWidth; if (screenWidth < minPossibleWidth) { if (scrollable) { itemWidth = minWidth; itemActiveWidth = (int) (minWidth * 1.5); } else { itemWidth = (int) (screenWidth / (noOfTabs + 0.5)); itemActiveWidth = (int) (itemWidth * 1.5); } } else if (screenWidth > maxPossibleWidth) { itemWidth = maxWidth; itemActiveWidth = (int) (itemWidth * 1.75); } else { double minPossibleWidth1 = minWidth * (noOfTabs + 0.625); double minPossibleWidth2 = minWidth * (noOfTabs + 0.75); itemWidth = (int) (screenWidth / (noOfTabs + 0.5)); itemActiveWidth = (int) (itemWidth * 1.5); if (screenWidth > minPossibleWidth1) { itemWidth = (int) (screenWidth / (noOfTabs + 0.625)); itemActiveWidth = (int) (itemWidth * 1.625); if (screenWidth > minPossibleWidth2) { itemWidth = (int) (screenWidth / (noOfTabs + 0.75)); itemActiveWidth = (int) (itemWidth * 1.75); } } } result[0] = itemWidth; result[1] = itemActiveWidth; return result; }
[ "static", "int", "[", "]", "getMeasurementsForShiftingMode", "(", "Context", "context", ",", "int", "screenWidth", ",", "int", "noOfTabs", ",", "boolean", "scrollable", ")", "{", "int", "[", "]", "result", "=", "new", "int", "[", "2", "]", ";", "int", "minWidth", "=", "(", "int", ")", "context", ".", "getResources", "(", ")", ".", "getDimension", "(", "R", ".", "dimen", ".", "shifting_min_width_inactive", ")", ";", "int", "maxWidth", "=", "(", "int", ")", "context", ".", "getResources", "(", ")", ".", "getDimension", "(", "R", ".", "dimen", ".", "shifting_max_width_inactive", ")", ";", "double", "minPossibleWidth", "=", "minWidth", "*", "(", "noOfTabs", "+", "0.5", ")", ";", "double", "maxPossibleWidth", "=", "maxWidth", "*", "(", "noOfTabs", "+", "0.75", ")", ";", "int", "itemWidth", ";", "int", "itemActiveWidth", ";", "if", "(", "screenWidth", "<", "minPossibleWidth", ")", "{", "if", "(", "scrollable", ")", "{", "itemWidth", "=", "minWidth", ";", "itemActiveWidth", "=", "(", "int", ")", "(", "minWidth", "*", "1.5", ")", ";", "}", "else", "{", "itemWidth", "=", "(", "int", ")", "(", "screenWidth", "/", "(", "noOfTabs", "+", "0.5", ")", ")", ";", "itemActiveWidth", "=", "(", "int", ")", "(", "itemWidth", "*", "1.5", ")", ";", "}", "}", "else", "if", "(", "screenWidth", ">", "maxPossibleWidth", ")", "{", "itemWidth", "=", "maxWidth", ";", "itemActiveWidth", "=", "(", "int", ")", "(", "itemWidth", "*", "1.75", ")", ";", "}", "else", "{", "double", "minPossibleWidth1", "=", "minWidth", "*", "(", "noOfTabs", "+", "0.625", ")", ";", "double", "minPossibleWidth2", "=", "minWidth", "*", "(", "noOfTabs", "+", "0.75", ")", ";", "itemWidth", "=", "(", "int", ")", "(", "screenWidth", "/", "(", "noOfTabs", "+", "0.5", ")", ")", ";", "itemActiveWidth", "=", "(", "int", ")", "(", "itemWidth", "*", "1.5", ")", ";", "if", "(", "screenWidth", ">", "minPossibleWidth1", ")", "{", "itemWidth", "=", "(", "int", ")", "(", "screenWidth", "/", "(", "noOfTabs", "+", "0.625", ")", ")", ";", "itemActiveWidth", "=", "(", "int", ")", "(", "itemWidth", "*", "1.625", ")", ";", "if", "(", "screenWidth", ">", "minPossibleWidth2", ")", "{", "itemWidth", "=", "(", "int", ")", "(", "screenWidth", "/", "(", "noOfTabs", "+", "0.75", ")", ")", ";", "itemActiveWidth", "=", "(", "int", ")", "(", "itemWidth", "*", "1.75", ")", ";", "}", "}", "}", "result", "[", "0", "]", "=", "itemWidth", ";", "result", "[", "1", "]", "=", "itemActiveWidth", ";", "return", "result", ";", "}" ]
Used to get Measurements for MODE_SHIFTING @param context to fetch measurements @param screenWidth total screen width @param noOfTabs no of bottom bar tabs @param scrollable is bottom bar scrollable @return min and max width of each tab
[ "Used", "to", "get", "Measurements", "for", "MODE_SHIFTING" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationHelper.java#L64-L106
22,680
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationHelper.java
BottomNavigationHelper.bindTabWithData
static void bindTabWithData(BottomNavigationItem bottomNavigationItem, BottomNavigationTab bottomNavigationTab, BottomNavigationBar bottomNavigationBar) { Context context = bottomNavigationBar.getContext(); bottomNavigationTab.setLabel(bottomNavigationItem.getTitle(context)); bottomNavigationTab.setIcon(bottomNavigationItem.getIcon(context)); int activeColor = bottomNavigationItem.getActiveColor(context); int inActiveColor = bottomNavigationItem.getInActiveColor(context); if (activeColor != Utils.NO_COLOR) { bottomNavigationTab.setActiveColor(activeColor); } else { bottomNavigationTab.setActiveColor(bottomNavigationBar.getActiveColor()); } if (inActiveColor != Utils.NO_COLOR) { bottomNavigationTab.setInactiveColor(inActiveColor); } else { bottomNavigationTab.setInactiveColor(bottomNavigationBar.getInActiveColor()); } if (bottomNavigationItem.isInActiveIconAvailable()) { Drawable inactiveDrawable = bottomNavigationItem.getInactiveIcon(context); if (inactiveDrawable != null) { bottomNavigationTab.setInactiveIcon(inactiveDrawable); } } bottomNavigationTab.setItemBackgroundColor(bottomNavigationBar.getBackgroundColor()); BadgeItem badgeItem = bottomNavigationItem.getBadgeItem(); if (badgeItem != null) { badgeItem.bindToBottomTab(bottomNavigationTab); } }
java
static void bindTabWithData(BottomNavigationItem bottomNavigationItem, BottomNavigationTab bottomNavigationTab, BottomNavigationBar bottomNavigationBar) { Context context = bottomNavigationBar.getContext(); bottomNavigationTab.setLabel(bottomNavigationItem.getTitle(context)); bottomNavigationTab.setIcon(bottomNavigationItem.getIcon(context)); int activeColor = bottomNavigationItem.getActiveColor(context); int inActiveColor = bottomNavigationItem.getInActiveColor(context); if (activeColor != Utils.NO_COLOR) { bottomNavigationTab.setActiveColor(activeColor); } else { bottomNavigationTab.setActiveColor(bottomNavigationBar.getActiveColor()); } if (inActiveColor != Utils.NO_COLOR) { bottomNavigationTab.setInactiveColor(inActiveColor); } else { bottomNavigationTab.setInactiveColor(bottomNavigationBar.getInActiveColor()); } if (bottomNavigationItem.isInActiveIconAvailable()) { Drawable inactiveDrawable = bottomNavigationItem.getInactiveIcon(context); if (inactiveDrawable != null) { bottomNavigationTab.setInactiveIcon(inactiveDrawable); } } bottomNavigationTab.setItemBackgroundColor(bottomNavigationBar.getBackgroundColor()); BadgeItem badgeItem = bottomNavigationItem.getBadgeItem(); if (badgeItem != null) { badgeItem.bindToBottomTab(bottomNavigationTab); } }
[ "static", "void", "bindTabWithData", "(", "BottomNavigationItem", "bottomNavigationItem", ",", "BottomNavigationTab", "bottomNavigationTab", ",", "BottomNavigationBar", "bottomNavigationBar", ")", "{", "Context", "context", "=", "bottomNavigationBar", ".", "getContext", "(", ")", ";", "bottomNavigationTab", ".", "setLabel", "(", "bottomNavigationItem", ".", "getTitle", "(", "context", ")", ")", ";", "bottomNavigationTab", ".", "setIcon", "(", "bottomNavigationItem", ".", "getIcon", "(", "context", ")", ")", ";", "int", "activeColor", "=", "bottomNavigationItem", ".", "getActiveColor", "(", "context", ")", ";", "int", "inActiveColor", "=", "bottomNavigationItem", ".", "getInActiveColor", "(", "context", ")", ";", "if", "(", "activeColor", "!=", "Utils", ".", "NO_COLOR", ")", "{", "bottomNavigationTab", ".", "setActiveColor", "(", "activeColor", ")", ";", "}", "else", "{", "bottomNavigationTab", ".", "setActiveColor", "(", "bottomNavigationBar", ".", "getActiveColor", "(", ")", ")", ";", "}", "if", "(", "inActiveColor", "!=", "Utils", ".", "NO_COLOR", ")", "{", "bottomNavigationTab", ".", "setInactiveColor", "(", "inActiveColor", ")", ";", "}", "else", "{", "bottomNavigationTab", ".", "setInactiveColor", "(", "bottomNavigationBar", ".", "getInActiveColor", "(", ")", ")", ";", "}", "if", "(", "bottomNavigationItem", ".", "isInActiveIconAvailable", "(", ")", ")", "{", "Drawable", "inactiveDrawable", "=", "bottomNavigationItem", ".", "getInactiveIcon", "(", "context", ")", ";", "if", "(", "inactiveDrawable", "!=", "null", ")", "{", "bottomNavigationTab", ".", "setInactiveIcon", "(", "inactiveDrawable", ")", ";", "}", "}", "bottomNavigationTab", ".", "setItemBackgroundColor", "(", "bottomNavigationBar", ".", "getBackgroundColor", "(", ")", ")", ";", "BadgeItem", "badgeItem", "=", "bottomNavigationItem", ".", "getBadgeItem", "(", ")", ";", "if", "(", "badgeItem", "!=", "null", ")", "{", "badgeItem", ".", "bindToBottomTab", "(", "bottomNavigationTab", ")", ";", "}", "}" ]
Used to get set data to the Tab views from navigation items @param bottomNavigationItem holds all the data @param bottomNavigationTab view to which data need to be set @param bottomNavigationBar view which holds all the tabs
[ "Used", "to", "get", "set", "data", "to", "the", "Tab", "views", "from", "navigation", "items" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationHelper.java#L115-L150
22,681
Ashok-Varma/BottomNavigation
bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationHelper.java
BottomNavigationHelper.setBackgroundWithRipple
static void setBackgroundWithRipple(View clickedView, final View backgroundView, final View bgOverlay, final int newColor, int animationDuration) { int centerX = (int) (clickedView.getX() + (clickedView.getMeasuredWidth() / 2)); int centerY = clickedView.getMeasuredHeight() / 2; int finalRadius = backgroundView.getWidth(); backgroundView.clearAnimation(); bgOverlay.clearAnimation(); Animator circularReveal; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { circularReveal = ViewAnimationUtils .createCircularReveal(bgOverlay, centerX, centerY, 0, finalRadius); } else { bgOverlay.setAlpha(0); circularReveal = ObjectAnimator.ofFloat(bgOverlay, "alpha", 0, 1); } circularReveal.setDuration(animationDuration); circularReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { onCancel(); } @Override public void onAnimationCancel(Animator animation) { onCancel(); } private void onCancel() { backgroundView.setBackgroundColor(newColor); bgOverlay.setVisibility(View.GONE); } }); bgOverlay.setBackgroundColor(newColor); bgOverlay.setVisibility(View.VISIBLE); circularReveal.start(); }
java
static void setBackgroundWithRipple(View clickedView, final View backgroundView, final View bgOverlay, final int newColor, int animationDuration) { int centerX = (int) (clickedView.getX() + (clickedView.getMeasuredWidth() / 2)); int centerY = clickedView.getMeasuredHeight() / 2; int finalRadius = backgroundView.getWidth(); backgroundView.clearAnimation(); bgOverlay.clearAnimation(); Animator circularReveal; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { circularReveal = ViewAnimationUtils .createCircularReveal(bgOverlay, centerX, centerY, 0, finalRadius); } else { bgOverlay.setAlpha(0); circularReveal = ObjectAnimator.ofFloat(bgOverlay, "alpha", 0, 1); } circularReveal.setDuration(animationDuration); circularReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { onCancel(); } @Override public void onAnimationCancel(Animator animation) { onCancel(); } private void onCancel() { backgroundView.setBackgroundColor(newColor); bgOverlay.setVisibility(View.GONE); } }); bgOverlay.setBackgroundColor(newColor); bgOverlay.setVisibility(View.VISIBLE); circularReveal.start(); }
[ "static", "void", "setBackgroundWithRipple", "(", "View", "clickedView", ",", "final", "View", "backgroundView", ",", "final", "View", "bgOverlay", ",", "final", "int", "newColor", ",", "int", "animationDuration", ")", "{", "int", "centerX", "=", "(", "int", ")", "(", "clickedView", ".", "getX", "(", ")", "+", "(", "clickedView", ".", "getMeasuredWidth", "(", ")", "/", "2", ")", ")", ";", "int", "centerY", "=", "clickedView", ".", "getMeasuredHeight", "(", ")", "/", "2", ";", "int", "finalRadius", "=", "backgroundView", ".", "getWidth", "(", ")", ";", "backgroundView", ".", "clearAnimation", "(", ")", ";", "bgOverlay", ".", "clearAnimation", "(", ")", ";", "Animator", "circularReveal", ";", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", ">=", "Build", ".", "VERSION_CODES", ".", "LOLLIPOP", ")", "{", "circularReveal", "=", "ViewAnimationUtils", ".", "createCircularReveal", "(", "bgOverlay", ",", "centerX", ",", "centerY", ",", "0", ",", "finalRadius", ")", ";", "}", "else", "{", "bgOverlay", ".", "setAlpha", "(", "0", ")", ";", "circularReveal", "=", "ObjectAnimator", ".", "ofFloat", "(", "bgOverlay", ",", "\"alpha\"", ",", "0", ",", "1", ")", ";", "}", "circularReveal", ".", "setDuration", "(", "animationDuration", ")", ";", "circularReveal", ".", "addListener", "(", "new", "AnimatorListenerAdapter", "(", ")", "{", "@", "Override", "public", "void", "onAnimationEnd", "(", "Animator", "animation", ")", "{", "onCancel", "(", ")", ";", "}", "@", "Override", "public", "void", "onAnimationCancel", "(", "Animator", "animation", ")", "{", "onCancel", "(", ")", ";", "}", "private", "void", "onCancel", "(", ")", "{", "backgroundView", ".", "setBackgroundColor", "(", "newColor", ")", ";", "bgOverlay", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "}", ")", ";", "bgOverlay", ".", "setBackgroundColor", "(", "newColor", ")", ";", "bgOverlay", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "circularReveal", ".", "start", "(", ")", ";", "}" ]
Used to set the ripple animation when a tab is selected @param clickedView the view that is clicked (to get dimens where ripple starts) @param backgroundView temporary view to which final background color is set @param bgOverlay temporary view which is animated to get ripple effect @param newColor the new color i.e ripple color @param animationDuration duration for which animation runs
[ "Used", "to", "set", "the", "ripple", "animation", "when", "a", "tab", "is", "selected" ]
a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b
https://github.com/Ashok-Varma/BottomNavigation/blob/a5c486a6dfa1ebe7049e2e025e0d967111ecfd0b/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationHelper.java#L161-L201
22,682
raphw/byte-buddy
byte-buddy-gradle-plugin/src/main/java/net/bytebuddy/build/gradle/AbstractUserConfiguration.java
AbstractUserConfiguration.getClassPath
public Iterable<? extends File> getClassPath(File root, Iterable<? extends File> classPath) { return this.classPath == null ? new PrefixIterable(root, classPath) : this.classPath; }
java
public Iterable<? extends File> getClassPath(File root, Iterable<? extends File> classPath) { return this.classPath == null ? new PrefixIterable(root, classPath) : this.classPath; }
[ "public", "Iterable", "<", "?", "extends", "File", ">", "getClassPath", "(", "File", "root", ",", "Iterable", "<", "?", "extends", "File", ">", "classPath", ")", "{", "return", "this", ".", "classPath", "==", "null", "?", "new", "PrefixIterable", "(", "root", ",", "classPath", ")", ":", "this", ".", "classPath", ";", "}" ]
Returns the class path or builds a class path from the supplied arguments if no class path was set. @param root The root directory of the project being built. @param classPath The class path dependencies. @return An iterable of all elements of the class path to be used.
[ "Returns", "the", "class", "path", "or", "builds", "a", "class", "path", "from", "the", "supplied", "arguments", "if", "no", "class", "path", "was", "set", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-gradle-plugin/src/main/java/net/bytebuddy/build/gradle/AbstractUserConfiguration.java#L38-L42
22,683
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/implementation/DefaultMethodCall.java
DefaultMethodCall.filterRelevant
private List<TypeDescription> filterRelevant(TypeDescription typeDescription) { List<TypeDescription> filtered = new ArrayList<TypeDescription>(prioritizedInterfaces.size()); Set<TypeDescription> relevant = new HashSet<TypeDescription>(typeDescription.getInterfaces().asErasures()); for (TypeDescription prioritizedInterface : prioritizedInterfaces) { if (relevant.remove(prioritizedInterface)) { filtered.add(prioritizedInterface); } } return filtered; }
java
private List<TypeDescription> filterRelevant(TypeDescription typeDescription) { List<TypeDescription> filtered = new ArrayList<TypeDescription>(prioritizedInterfaces.size()); Set<TypeDescription> relevant = new HashSet<TypeDescription>(typeDescription.getInterfaces().asErasures()); for (TypeDescription prioritizedInterface : prioritizedInterfaces) { if (relevant.remove(prioritizedInterface)) { filtered.add(prioritizedInterface); } } return filtered; }
[ "private", "List", "<", "TypeDescription", ">", "filterRelevant", "(", "TypeDescription", "typeDescription", ")", "{", "List", "<", "TypeDescription", ">", "filtered", "=", "new", "ArrayList", "<", "TypeDescription", ">", "(", "prioritizedInterfaces", ".", "size", "(", ")", ")", ";", "Set", "<", "TypeDescription", ">", "relevant", "=", "new", "HashSet", "<", "TypeDescription", ">", "(", "typeDescription", ".", "getInterfaces", "(", ")", ".", "asErasures", "(", ")", ")", ";", "for", "(", "TypeDescription", "prioritizedInterface", ":", "prioritizedInterfaces", ")", "{", "if", "(", "relevant", ".", "remove", "(", "prioritizedInterface", ")", ")", "{", "filtered", ".", "add", "(", "prioritizedInterface", ")", ";", "}", "}", "return", "filtered", ";", "}" ]
Filters the relevant prioritized interfaces for a given type, i.e. finds the types that are directly declared on a given instrumented type. @param typeDescription The instrumented type for which the prioritized interfaces are to be filtered. @return A list of prioritized interfaces that are additionally implemented by the given type.
[ "Filters", "the", "relevant", "prioritized", "interfaces", "for", "a", "given", "type", "i", ".", "e", ".", "finds", "the", "types", "that", "are", "directly", "declared", "on", "a", "given", "instrumented", "type", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/implementation/DefaultMethodCall.java#L165-L174
22,684
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.definedField
public static <T extends FieldDescription> ElementMatcher.Junction<T> definedField(ElementMatcher<? super FieldDescription.InDefinedShape> matcher) { return new DefinedShapeMatcher<T, FieldDescription.InDefinedShape>(matcher); }
java
public static <T extends FieldDescription> ElementMatcher.Junction<T> definedField(ElementMatcher<? super FieldDescription.InDefinedShape> matcher) { return new DefinedShapeMatcher<T, FieldDescription.InDefinedShape>(matcher); }
[ "public", "static", "<", "T", "extends", "FieldDescription", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "definedField", "(", "ElementMatcher", "<", "?", "super", "FieldDescription", ".", "InDefinedShape", ">", "matcher", ")", "{", "return", "new", "DefinedShapeMatcher", "<", "T", ",", "FieldDescription", ".", "InDefinedShape", ">", "(", "matcher", ")", ";", "}" ]
Matches a field in its defined shape. @param matcher The matcher to apply to the matched field's defined shape. @param <T> The matched object's type. @return A matcher that matches a matched field's defined shape.
[ "Matches", "a", "field", "in", "its", "defined", "shape", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L161-L163
22,685
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.definedMethod
public static <T extends MethodDescription> ElementMatcher.Junction<T> definedMethod(ElementMatcher<? super MethodDescription.InDefinedShape> matcher) { return new DefinedShapeMatcher<T, MethodDescription.InDefinedShape>(matcher); }
java
public static <T extends MethodDescription> ElementMatcher.Junction<T> definedMethod(ElementMatcher<? super MethodDescription.InDefinedShape> matcher) { return new DefinedShapeMatcher<T, MethodDescription.InDefinedShape>(matcher); }
[ "public", "static", "<", "T", "extends", "MethodDescription", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "definedMethod", "(", "ElementMatcher", "<", "?", "super", "MethodDescription", ".", "InDefinedShape", ">", "matcher", ")", "{", "return", "new", "DefinedShapeMatcher", "<", "T", ",", "MethodDescription", ".", "InDefinedShape", ">", "(", "matcher", ")", ";", "}" ]
Matches a method in its defined shape. @param matcher The matcher to apply to the matched method's defined shape. @param <T> The matched object's type. @return A matcher that matches a matched method's defined shape.
[ "Matches", "a", "method", "in", "its", "defined", "shape", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L205-L207
22,686
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.definedParameter
public static <T extends ParameterDescription> ElementMatcher.Junction<T> definedParameter(ElementMatcher<? super ParameterDescription.InDefinedShape> matcher) { return new DefinedShapeMatcher<T, ParameterDescription.InDefinedShape>(matcher); }
java
public static <T extends ParameterDescription> ElementMatcher.Junction<T> definedParameter(ElementMatcher<? super ParameterDescription.InDefinedShape> matcher) { return new DefinedShapeMatcher<T, ParameterDescription.InDefinedShape>(matcher); }
[ "public", "static", "<", "T", "extends", "ParameterDescription", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "definedParameter", "(", "ElementMatcher", "<", "?", "super", "ParameterDescription", ".", "InDefinedShape", ">", "matcher", ")", "{", "return", "new", "DefinedShapeMatcher", "<", "T", ",", "ParameterDescription", ".", "InDefinedShape", ">", "(", "matcher", ")", ";", "}" ]
Matches a parameter in its defined shape. @param matcher The matcher to apply to the matched parameter's defined shape. @param <T> The matched object's type. @return A matcher that matches a matched parameter's defined shape.
[ "Matches", "a", "parameter", "in", "its", "defined", "shape", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L227-L229
22,687
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.hasType
public static <T extends ParameterDescription> ElementMatcher.Junction<T> hasType(ElementMatcher<? super TypeDescription> matcher) { return hasGenericType(erasure(matcher)); }
java
public static <T extends ParameterDescription> ElementMatcher.Junction<T> hasType(ElementMatcher<? super TypeDescription> matcher) { return hasGenericType(erasure(matcher)); }
[ "public", "static", "<", "T", "extends", "ParameterDescription", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "hasType", "(", "ElementMatcher", "<", "?", "super", "TypeDescription", ">", "matcher", ")", "{", "return", "hasGenericType", "(", "erasure", "(", "matcher", ")", ")", ";", "}" ]
Matches a parameter's type by the given matcher. @param matcher The matcher to apply to the parameter's type. @param <T> The type of the matched object. @return A matcher that matches a parameter's type by the given matcher.
[ "Matches", "a", "parameter", "s", "type", "by", "the", "given", "matcher", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L238-L240
22,688
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.hasGenericType
public static <T extends ParameterDescription> ElementMatcher.Junction<T> hasGenericType(ElementMatcher<? super TypeDescription.Generic> matcher) { return new MethodParameterTypeMatcher<T>(matcher); }
java
public static <T extends ParameterDescription> ElementMatcher.Junction<T> hasGenericType(ElementMatcher<? super TypeDescription.Generic> matcher) { return new MethodParameterTypeMatcher<T>(matcher); }
[ "public", "static", "<", "T", "extends", "ParameterDescription", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "hasGenericType", "(", "ElementMatcher", "<", "?", "super", "TypeDescription", ".", "Generic", ">", "matcher", ")", "{", "return", "new", "MethodParameterTypeMatcher", "<", "T", ">", "(", "matcher", ")", ";", "}" ]
Matches a method parameter by its generic type. @param matcher The matcher to apply to a parameter's generic type. @param <T> The type of the matched object. @return A matcher that matches the matched parameter's generic type.
[ "Matches", "a", "method", "parameter", "by", "its", "generic", "type", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L249-L251
22,689
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.not
public static <T> ElementMatcher.Junction<T> not(ElementMatcher<? super T> matcher) { return new NegatingMatcher<T>(matcher); }
java
public static <T> ElementMatcher.Junction<T> not(ElementMatcher<? super T> matcher) { return new NegatingMatcher<T>(matcher); }
[ "public", "static", "<", "T", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "not", "(", "ElementMatcher", "<", "?", "super", "T", ">", "matcher", ")", "{", "return", "new", "NegatingMatcher", "<", "T", ">", "(", "matcher", ")", ";", "}" ]
Inverts another matcher. @param matcher The matcher to invert. @param <T> The type of the matched object. @return An inverted version of the given {@code matcher}.
[ "Inverts", "another", "matcher", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L292-L294
22,690
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.whereAny
public static <T> ElementMatcher.Junction<Iterable<? extends T>> whereAny(ElementMatcher<? super T> matcher) { return new CollectionItemMatcher<T>(matcher); }
java
public static <T> ElementMatcher.Junction<Iterable<? extends T>> whereAny(ElementMatcher<? super T> matcher) { return new CollectionItemMatcher<T>(matcher); }
[ "public", "static", "<", "T", ">", "ElementMatcher", ".", "Junction", "<", "Iterable", "<", "?", "extends", "T", ">", ">", "whereAny", "(", "ElementMatcher", "<", "?", "super", "T", ">", "matcher", ")", "{", "return", "new", "CollectionItemMatcher", "<", "T", ">", "(", "matcher", ")", ";", "}" ]
Matches an iterable by assuring that at least one element of the iterable collection matches the provided matcher. @param matcher The matcher to apply to each element. @param <T> The type of the matched object. @return A matcher that matches an iterable if at least one element matches the provided matcher.
[ "Matches", "an", "iterable", "by", "assuring", "that", "at", "least", "one", "element", "of", "the", "iterable", "collection", "matches", "the", "provided", "matcher", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L520-L522
22,691
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.whereNone
public static <T> ElementMatcher.Junction<Iterable<? extends T>> whereNone(ElementMatcher<? super T> matcher) { return not(whereAny(matcher)); }
java
public static <T> ElementMatcher.Junction<Iterable<? extends T>> whereNone(ElementMatcher<? super T> matcher) { return not(whereAny(matcher)); }
[ "public", "static", "<", "T", ">", "ElementMatcher", ".", "Junction", "<", "Iterable", "<", "?", "extends", "T", ">", ">", "whereNone", "(", "ElementMatcher", "<", "?", "super", "T", ">", "matcher", ")", "{", "return", "not", "(", "whereAny", "(", "matcher", ")", ")", ";", "}" ]
Matches an iterable by assuring that no element of the iterable collection matches the provided matcher. @param matcher The matcher to apply to each element. @param <T> The type of the matched object. @return A matcher that matches an iterable if no element matches the provided matcher.
[ "Matches", "an", "iterable", "by", "assuring", "that", "no", "element", "of", "the", "iterable", "collection", "matches", "the", "provided", "matcher", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L531-L533
22,692
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.erasure
public static <T extends TypeDescription.Generic> ElementMatcher.Junction<T> erasure(Class<?> type) { return erasure(is(type)); }
java
public static <T extends TypeDescription.Generic> ElementMatcher.Junction<T> erasure(Class<?> type) { return erasure(is(type)); }
[ "public", "static", "<", "T", "extends", "TypeDescription", ".", "Generic", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "erasure", "(", "Class", "<", "?", ">", "type", ")", "{", "return", "erasure", "(", "is", "(", "type", ")", ")", ";", "}" ]
Matches a generic type's erasure against the provided type. As a wildcard does not define an erasure, a runtime exception is thrown when this matcher is applied to a wildcard. @param type The type to match a generic type's erasure against. @param <T> The type of the matched object. @return A matcher that matches a generic type's raw type against the provided non-generic type.
[ "Matches", "a", "generic", "type", "s", "erasure", "against", "the", "provided", "type", ".", "As", "a", "wildcard", "does", "not", "define", "an", "erasure", "a", "runtime", "exception", "is", "thrown", "when", "this", "matcher", "is", "applied", "to", "a", "wildcard", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L543-L545
22,693
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.erasure
public static <T extends TypeDescription.Generic> ElementMatcher.Junction<T> erasure(ElementMatcher<? super TypeDescription> matcher) { return new ErasureMatcher<T>(matcher); }
java
public static <T extends TypeDescription.Generic> ElementMatcher.Junction<T> erasure(ElementMatcher<? super TypeDescription> matcher) { return new ErasureMatcher<T>(matcher); }
[ "public", "static", "<", "T", "extends", "TypeDescription", ".", "Generic", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "erasure", "(", "ElementMatcher", "<", "?", "super", "TypeDescription", ">", "matcher", ")", "{", "return", "new", "ErasureMatcher", "<", "T", ">", "(", "matcher", ")", ";", "}" ]
Converts a matcher for a type description into a matcher for the matched type's erasure. As a wildcard does not define an erasure, a runtime exception is thrown when this matcher is applied to a wildcard. @param matcher The matcher to match the matched object's raw type against. @param <T> The type of the matched object. @return A type matcher for a generic type that matches the matched type's raw type against the given type description matcher.
[ "Converts", "a", "matcher", "for", "a", "type", "description", "into", "a", "matcher", "for", "the", "matched", "type", "s", "erasure", ".", "As", "a", "wildcard", "does", "not", "define", "an", "erasure", "a", "runtime", "exception", "is", "thrown", "when", "this", "matcher", "is", "applied", "to", "a", "wildcard", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L567-L569
22,694
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.erasures
public static <T extends Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures( ElementMatcher<? super Iterable<? extends TypeDescription>> matcher) { return new CollectionErasureMatcher<T>(matcher); }
java
public static <T extends Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures( ElementMatcher<? super Iterable<? extends TypeDescription>> matcher) { return new CollectionErasureMatcher<T>(matcher); }
[ "public", "static", "<", "T", "extends", "Iterable", "<", "?", "extends", "TypeDescription", ".", "Generic", ">", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "erasures", "(", "ElementMatcher", "<", "?", "super", "Iterable", "<", "?", "extends", "TypeDescription", ">", ">", "matcher", ")", "{", "return", "new", "CollectionErasureMatcher", "<", "T", ">", "(", "matcher", ")", ";", "}" ]
Applies the provided matchers to an iteration og generic types' erasures. As a wildcard does not define an erasure, a runtime exception is thrown when this matcher is applied to a wildcard. @param matcher The matcher to apply at the erased types. @param <T> The type of the matched object. @return A matcher that matches an iteration of generic types' raw types against the provided matcher.
[ "Applies", "the", "provided", "matchers", "to", "an", "iteration", "og", "generic", "types", "erasures", ".", "As", "a", "wildcard", "does", "not", "define", "an", "erasure", "a", "runtime", "exception", "is", "thrown", "when", "this", "matcher", "is", "applied", "to", "a", "wildcard", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L620-L623
22,695
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.returns
public static <T extends MethodDescription> ElementMatcher.Junction<T> returns(ElementMatcher<? super TypeDescription> matcher) { return returnsGeneric(erasure(matcher)); }
java
public static <T extends MethodDescription> ElementMatcher.Junction<T> returns(ElementMatcher<? super TypeDescription> matcher) { return returnsGeneric(erasure(matcher)); }
[ "public", "static", "<", "T", "extends", "MethodDescription", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "returns", "(", "ElementMatcher", "<", "?", "super", "TypeDescription", ">", "matcher", ")", "{", "return", "returnsGeneric", "(", "erasure", "(", "matcher", ")", ")", ";", "}" ]
Matches a method's return type's erasure by the given matcher. @param matcher The matcher to apply to a method's return type's erasure. @param <T> The type of the matched object. @return A matcher that matches the matched method's return type's erasure.
[ "Matches", "a", "method", "s", "return", "type", "s", "erasure", "by", "the", "given", "matcher", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L1135-L1137
22,696
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.declaresGenericException
public static <T extends MethodDescription> ElementMatcher.Junction<T> declaresGenericException( ElementMatcher<? super Iterable<? extends TypeDescription.Generic>> matcher) { return new MethodExceptionTypeMatcher<T>(matcher); }
java
public static <T extends MethodDescription> ElementMatcher.Junction<T> declaresGenericException( ElementMatcher<? super Iterable<? extends TypeDescription.Generic>> matcher) { return new MethodExceptionTypeMatcher<T>(matcher); }
[ "public", "static", "<", "T", "extends", "MethodDescription", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "declaresGenericException", "(", "ElementMatcher", "<", "?", "super", "Iterable", "<", "?", "extends", "TypeDescription", ".", "Generic", ">", ">", "matcher", ")", "{", "return", "new", "MethodExceptionTypeMatcher", "<", "T", ">", "(", "matcher", ")", ";", "}" ]
Matches a method's generic exception types against the provided matcher. @param matcher The exception matcher to apply onto the matched method's generic exceptions. @param <T> The type of the matched object. @return A matcher that applies the provided matcher to a method's generic exception types.
[ "Matches", "a", "method", "s", "generic", "exception", "types", "against", "the", "provided", "matcher", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L1427-L1430
22,697
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.isVirtual
public static <T extends MethodDescription> ElementMatcher.Junction<T> isVirtual() { return new MethodSortMatcher<T>(MethodSortMatcher.Sort.VIRTUAL); }
java
public static <T extends MethodDescription> ElementMatcher.Junction<T> isVirtual() { return new MethodSortMatcher<T>(MethodSortMatcher.Sort.VIRTUAL); }
[ "public", "static", "<", "T", "extends", "MethodDescription", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "isVirtual", "(", ")", "{", "return", "new", "MethodSortMatcher", "<", "T", ">", "(", "MethodSortMatcher", ".", "Sort", ".", "VIRTUAL", ")", ";", "}" ]
Matches any method that is virtual, i.e. non-constructors that are non-static and non-private. @param <T> The type of the matched object. @return A matcher for virtual methods.
[ "Matches", "any", "method", "that", "is", "virtual", "i", ".", "e", ".", "non", "-", "constructors", "that", "are", "non", "-", "static", "and", "non", "-", "private", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L1557-L1559
22,698
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.isDefaultMethod
public static <T extends MethodDescription> ElementMatcher.Junction<T> isDefaultMethod() { return new MethodSortMatcher<T>(MethodSortMatcher.Sort.DEFAULT_METHOD); }
java
public static <T extends MethodDescription> ElementMatcher.Junction<T> isDefaultMethod() { return new MethodSortMatcher<T>(MethodSortMatcher.Sort.DEFAULT_METHOD); }
[ "public", "static", "<", "T", "extends", "MethodDescription", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "isDefaultMethod", "(", ")", "{", "return", "new", "MethodSortMatcher", "<", "T", ">", "(", "MethodSortMatcher", ".", "Sort", ".", "DEFAULT_METHOD", ")", ";", "}" ]
Only matches Java 8 default methods. @param <T> The type of the matched object. @return A matcher that only matches Java 8 default methods.
[ "Only", "matches", "Java", "8", "default", "methods", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L1567-L1569
22,699
raphw/byte-buddy
byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java
ElementMatchers.isSetter
public static <T extends MethodDescription> ElementMatcher.Junction<T> isSetter() { return nameStartsWith("set").and(takesArguments(1)).and(returns(TypeDescription.VOID)); }
java
public static <T extends MethodDescription> ElementMatcher.Junction<T> isSetter() { return nameStartsWith("set").and(takesArguments(1)).and(returns(TypeDescription.VOID)); }
[ "public", "static", "<", "T", "extends", "MethodDescription", ">", "ElementMatcher", ".", "Junction", "<", "T", ">", "isSetter", "(", ")", "{", "return", "nameStartsWith", "(", "\"set\"", ")", ".", "and", "(", "takesArguments", "(", "1", ")", ")", ".", "and", "(", "returns", "(", "TypeDescription", ".", "VOID", ")", ")", ";", "}" ]
Matches any Java bean setter method. @param <T> The type of the matched object. @return A matcher that matches any setter method.
[ "Matches", "any", "Java", "bean", "setter", "method", "." ]
4d2dac80efb6bed89367567260f6811c2f712d12
https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/matcher/ElementMatchers.java#L1647-L1649