id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
163,400
GoogleCloudPlatform/appengine-gcs-client
java/src/main/java/com/google/appengine/tools/cloudstorage/oauth/OauthRawGcsService.java
OauthRawGcsService.deleteObject
@Override public boolean deleteObject(GcsFilename filename, long timeoutMillis) throws IOException { HTTPRequest req = makeRequest(filename, null, DELETE, timeoutMillis); HTTPResponse resp; try { resp = urlfetch.fetch(req); } catch (IOException e) { throw createIOException(new HTTPRequestInfo(req), e); } switch (resp.getResponseCode()) { case 204: return true; case 404: return false; default: throw HttpErrorHandler.error(new HTTPRequestInfo(req), resp); } }
java
@Override public boolean deleteObject(GcsFilename filename, long timeoutMillis) throws IOException { HTTPRequest req = makeRequest(filename, null, DELETE, timeoutMillis); HTTPResponse resp; try { resp = urlfetch.fetch(req); } catch (IOException e) { throw createIOException(new HTTPRequestInfo(req), e); } switch (resp.getResponseCode()) { case 204: return true; case 404: return false; default: throw HttpErrorHandler.error(new HTTPRequestInfo(req), resp); } }
[ "@", "Override", "public", "boolean", "deleteObject", "(", "GcsFilename", "filename", ",", "long", "timeoutMillis", ")", "throws", "IOException", "{", "HTTPRequest", "req", "=", "makeRequest", "(", "filename", ",", "null", ",", "DELETE", ",", "timeoutMillis", ")", ";", "HTTPResponse", "resp", ";", "try", "{", "resp", "=", "urlfetch", ".", "fetch", "(", "req", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "createIOException", "(", "new", "HTTPRequestInfo", "(", "req", ")", ",", "e", ")", ";", "}", "switch", "(", "resp", ".", "getResponseCode", "(", ")", ")", "{", "case", "204", ":", "return", "true", ";", "case", "404", ":", "return", "false", ";", "default", ":", "throw", "HttpErrorHandler", ".", "error", "(", "new", "HTTPRequestInfo", "(", "req", ")", ",", "resp", ")", ";", "}", "}" ]
True if deleted, false if not found.
[ "True", "if", "deleted", "false", "if", "not", "found", "." ]
d11078331ecd915d753c886e96a80133599f3f98
https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/d11078331ecd915d753c886e96a80133599f3f98/java/src/main/java/com/google/appengine/tools/cloudstorage/oauth/OauthRawGcsService.java#L456-L473
163,401
GoogleCloudPlatform/appengine-gcs-client
java/src/main/java/com/google/appengine/tools/cloudstorage/oauth/OauthRawGcsService.java
OauthRawGcsService.readObjectAsync
@Override public Future<GcsFileMetadata> readObjectAsync(final ByteBuffer dst, final GcsFilename filename, long startOffsetBytes, long timeoutMillis) { Preconditions.checkArgument(startOffsetBytes >= 0, "%s: offset must be non-negative: %s", this, startOffsetBytes); final int n = dst.remaining(); Preconditions.checkArgument(n > 0, "%s: dst full: %s", this, dst); final int want = Math.min(READ_LIMIT_BYTES, n); final HTTPRequest req = makeRequest(filename, null, GET, timeoutMillis); req.setHeader( new HTTPHeader(RANGE, "bytes=" + startOffsetBytes + "-" + (startOffsetBytes + want - 1))); final HTTPRequestInfo info = new HTTPRequestInfo(req); return new FutureWrapper<HTTPResponse, GcsFileMetadata>(urlfetch.fetchAsync(req)) { @Override protected GcsFileMetadata wrap(HTTPResponse resp) throws IOException { long totalLength; switch (resp.getResponseCode()) { case 200: totalLength = getLengthFromHeader(resp, X_GOOG_CONTENT_LENGTH); break; case 206: totalLength = getLengthFromContentRange(resp); break; case 404: throw new FileNotFoundException("Could not find: " + filename); case 416: throw new BadRangeException("Requested Range not satisfiable; perhaps read past EOF? " + URLFetchUtils.describeRequestAndResponse(info, resp)); default: throw HttpErrorHandler.error(info, resp); } byte[] content = resp.getContent(); Preconditions.checkState(content.length <= want, "%s: got %s > wanted %s", this, content.length, want); dst.put(content); return getMetadataFromResponse(filename, resp, totalLength); } @Override protected Throwable convertException(Throwable e) { return OauthRawGcsService.convertException(info, e); } }; }
java
@Override public Future<GcsFileMetadata> readObjectAsync(final ByteBuffer dst, final GcsFilename filename, long startOffsetBytes, long timeoutMillis) { Preconditions.checkArgument(startOffsetBytes >= 0, "%s: offset must be non-negative: %s", this, startOffsetBytes); final int n = dst.remaining(); Preconditions.checkArgument(n > 0, "%s: dst full: %s", this, dst); final int want = Math.min(READ_LIMIT_BYTES, n); final HTTPRequest req = makeRequest(filename, null, GET, timeoutMillis); req.setHeader( new HTTPHeader(RANGE, "bytes=" + startOffsetBytes + "-" + (startOffsetBytes + want - 1))); final HTTPRequestInfo info = new HTTPRequestInfo(req); return new FutureWrapper<HTTPResponse, GcsFileMetadata>(urlfetch.fetchAsync(req)) { @Override protected GcsFileMetadata wrap(HTTPResponse resp) throws IOException { long totalLength; switch (resp.getResponseCode()) { case 200: totalLength = getLengthFromHeader(resp, X_GOOG_CONTENT_LENGTH); break; case 206: totalLength = getLengthFromContentRange(resp); break; case 404: throw new FileNotFoundException("Could not find: " + filename); case 416: throw new BadRangeException("Requested Range not satisfiable; perhaps read past EOF? " + URLFetchUtils.describeRequestAndResponse(info, resp)); default: throw HttpErrorHandler.error(info, resp); } byte[] content = resp.getContent(); Preconditions.checkState(content.length <= want, "%s: got %s > wanted %s", this, content.length, want); dst.put(content); return getMetadataFromResponse(filename, resp, totalLength); } @Override protected Throwable convertException(Throwable e) { return OauthRawGcsService.convertException(info, e); } }; }
[ "@", "Override", "public", "Future", "<", "GcsFileMetadata", ">", "readObjectAsync", "(", "final", "ByteBuffer", "dst", ",", "final", "GcsFilename", "filename", ",", "long", "startOffsetBytes", ",", "long", "timeoutMillis", ")", "{", "Preconditions", ".", "checkArgument", "(", "startOffsetBytes", ">=", "0", ",", "\"%s: offset must be non-negative: %s\"", ",", "this", ",", "startOffsetBytes", ")", ";", "final", "int", "n", "=", "dst", ".", "remaining", "(", ")", ";", "Preconditions", ".", "checkArgument", "(", "n", ">", "0", ",", "\"%s: dst full: %s\"", ",", "this", ",", "dst", ")", ";", "final", "int", "want", "=", "Math", ".", "min", "(", "READ_LIMIT_BYTES", ",", "n", ")", ";", "final", "HTTPRequest", "req", "=", "makeRequest", "(", "filename", ",", "null", ",", "GET", ",", "timeoutMillis", ")", ";", "req", ".", "setHeader", "(", "new", "HTTPHeader", "(", "RANGE", ",", "\"bytes=\"", "+", "startOffsetBytes", "+", "\"-\"", "+", "(", "startOffsetBytes", "+", "want", "-", "1", ")", ")", ")", ";", "final", "HTTPRequestInfo", "info", "=", "new", "HTTPRequestInfo", "(", "req", ")", ";", "return", "new", "FutureWrapper", "<", "HTTPResponse", ",", "GcsFileMetadata", ">", "(", "urlfetch", ".", "fetchAsync", "(", "req", ")", ")", "{", "@", "Override", "protected", "GcsFileMetadata", "wrap", "(", "HTTPResponse", "resp", ")", "throws", "IOException", "{", "long", "totalLength", ";", "switch", "(", "resp", ".", "getResponseCode", "(", ")", ")", "{", "case", "200", ":", "totalLength", "=", "getLengthFromHeader", "(", "resp", ",", "X_GOOG_CONTENT_LENGTH", ")", ";", "break", ";", "case", "206", ":", "totalLength", "=", "getLengthFromContentRange", "(", "resp", ")", ";", "break", ";", "case", "404", ":", "throw", "new", "FileNotFoundException", "(", "\"Could not find: \"", "+", "filename", ")", ";", "case", "416", ":", "throw", "new", "BadRangeException", "(", "\"Requested Range not satisfiable; perhaps read past EOF? \"", "+", "URLFetchUtils", ".", "describeRequestAndResponse", "(", "info", ",", "resp", ")", ")", ";", "default", ":", "throw", "HttpErrorHandler", ".", "error", "(", "info", ",", "resp", ")", ";", "}", "byte", "[", "]", "content", "=", "resp", ".", "getContent", "(", ")", ";", "Preconditions", ".", "checkState", "(", "content", ".", "length", "<=", "want", ",", "\"%s: got %s > wanted %s\"", ",", "this", ",", "content", ".", "length", ",", "want", ")", ";", "dst", ".", "put", "(", "content", ")", ";", "return", "getMetadataFromResponse", "(", "filename", ",", "resp", ",", "totalLength", ")", ";", "}", "@", "Override", "protected", "Throwable", "convertException", "(", "Throwable", "e", ")", "{", "return", "OauthRawGcsService", ".", "convertException", "(", "info", ",", "e", ")", ";", "}", "}", ";", "}" ]
Might not fill all of dst.
[ "Might", "not", "fill", "all", "of", "dst", "." ]
d11078331ecd915d753c886e96a80133599f3f98
https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/d11078331ecd915d753c886e96a80133599f3f98/java/src/main/java/com/google/appengine/tools/cloudstorage/oauth/OauthRawGcsService.java#L490-L534
163,402
GoogleCloudPlatform/appengine-gcs-client
java/example/src/main/java/com/google/appengine/demos/GcsExampleServlet.java
GcsExampleServlet.copy
private void copy(InputStream input, OutputStream output) throws IOException { try { byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = input.read(buffer); while (bytesRead != -1) { output.write(buffer, 0, bytesRead); bytesRead = input.read(buffer); } } finally { input.close(); output.close(); } }
java
private void copy(InputStream input, OutputStream output) throws IOException { try { byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = input.read(buffer); while (bytesRead != -1) { output.write(buffer, 0, bytesRead); bytesRead = input.read(buffer); } } finally { input.close(); output.close(); } }
[ "private", "void", "copy", "(", "InputStream", "input", ",", "OutputStream", "output", ")", "throws", "IOException", "{", "try", "{", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "BUFFER_SIZE", "]", ";", "int", "bytesRead", "=", "input", ".", "read", "(", "buffer", ")", ";", "while", "(", "bytesRead", "!=", "-", "1", ")", "{", "output", ".", "write", "(", "buffer", ",", "0", ",", "bytesRead", ")", ";", "bytesRead", "=", "input", ".", "read", "(", "buffer", ")", ";", "}", "}", "finally", "{", "input", ".", "close", "(", ")", ";", "output", ".", "close", "(", ")", ";", "}", "}" ]
Transfer the data from the inputStream to the outputStream. Then close both streams.
[ "Transfer", "the", "data", "from", "the", "inputStream", "to", "the", "outputStream", ".", "Then", "close", "both", "streams", "." ]
d11078331ecd915d753c886e96a80133599f3f98
https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/d11078331ecd915d753c886e96a80133599f3f98/java/example/src/main/java/com/google/appengine/demos/GcsExampleServlet.java#L110-L122
163,403
JavaMoney/jsr354-api
src/main/java/javax/money/CurrencyQuery.java
CurrencyQuery.getCountries
public Collection<Locale> getCountries() { Collection<Locale> result = get(KEY_QUERY_COUNTRIES, Collection.class); if (result == null) { return Collections.emptySet(); } return result; }
java
public Collection<Locale> getCountries() { Collection<Locale> result = get(KEY_QUERY_COUNTRIES, Collection.class); if (result == null) { return Collections.emptySet(); } return result; }
[ "public", "Collection", "<", "Locale", ">", "getCountries", "(", ")", "{", "Collection", "<", "Locale", ">", "result", "=", "get", "(", "KEY_QUERY_COUNTRIES", ",", "Collection", ".", "class", ")", ";", "if", "(", "result", "==", "null", ")", "{", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "return", "result", ";", "}" ]
Returns the target locales. @return the target locales, never null.
[ "Returns", "the", "target", "locales", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/CurrencyQuery.java#L73-L79
163,404
JavaMoney/jsr354-api
src/main/java/javax/money/CurrencyQuery.java
CurrencyQuery.getCurrencyCodes
public Collection<String> getCurrencyCodes() { Collection<String> result = get(KEY_QUERY_CURRENCY_CODES, Collection.class); if (result == null) { return Collections.emptySet(); } return result; }
java
public Collection<String> getCurrencyCodes() { Collection<String> result = get(KEY_QUERY_CURRENCY_CODES, Collection.class); if (result == null) { return Collections.emptySet(); } return result; }
[ "public", "Collection", "<", "String", ">", "getCurrencyCodes", "(", ")", "{", "Collection", "<", "String", ">", "result", "=", "get", "(", "KEY_QUERY_CURRENCY_CODES", ",", "Collection", ".", "class", ")", ";", "if", "(", "result", "==", "null", ")", "{", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "return", "result", ";", "}" ]
Gets the currency codes, or the regular expression to select codes. @return the query for chaining.
[ "Gets", "the", "currency", "codes", "or", "the", "regular", "expression", "to", "select", "codes", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/CurrencyQuery.java#L86-L92
163,405
JavaMoney/jsr354-api
src/main/java/javax/money/CurrencyQuery.java
CurrencyQuery.getNumericCodes
public Collection<Integer> getNumericCodes() { Collection<Integer> result = get(KEY_QUERY_NUMERIC_CODES, Collection.class); if (result == null) { return Collections.emptySet(); } return result; }
java
public Collection<Integer> getNumericCodes() { Collection<Integer> result = get(KEY_QUERY_NUMERIC_CODES, Collection.class); if (result == null) { return Collections.emptySet(); } return result; }
[ "public", "Collection", "<", "Integer", ">", "getNumericCodes", "(", ")", "{", "Collection", "<", "Integer", ">", "result", "=", "get", "(", "KEY_QUERY_NUMERIC_CODES", ",", "Collection", ".", "class", ")", ";", "if", "(", "result", "==", "null", ")", "{", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "return", "result", ";", "}" ]
Gets the numeric codes. Setting it to -1 search for currencies that have no numeric code. @return the query for chaining.
[ "Gets", "the", "numeric", "codes", ".", "Setting", "it", "to", "-", "1", "search", "for", "currencies", "that", "have", "no", "numeric", "code", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/CurrencyQuery.java#L99-L105
163,406
JavaMoney/jsr354-api
src/main/java/javax/money/MonetaryContext.java
MonetaryContext.getAmountType
public Class<? extends MonetaryAmount> getAmountType() { Class<?> clazz = get(AMOUNT_TYPE, Class.class); return clazz.asSubclass(MonetaryAmount.class); }
java
public Class<? extends MonetaryAmount> getAmountType() { Class<?> clazz = get(AMOUNT_TYPE, Class.class); return clazz.asSubclass(MonetaryAmount.class); }
[ "public", "Class", "<", "?", "extends", "MonetaryAmount", ">", "getAmountType", "(", ")", "{", "Class", "<", "?", ">", "clazz", "=", "get", "(", "AMOUNT_TYPE", ",", "Class", ".", "class", ")", ";", "return", "clazz", ".", "asSubclass", "(", "MonetaryAmount", ".", "class", ")", ";", "}" ]
Get the MonetaryAmount implementation class. @return the implementation class of the containing amount instance, never null. @see MonetaryAmount#getContext()
[ "Get", "the", "MonetaryAmount", "implementation", "class", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/MonetaryContext.java#L118-L121
163,407
JavaMoney/jsr354-api
src/main/java/javax/money/DefaultMonetaryRoundingsSingletonSpi.java
DefaultMonetaryRoundingsSingletonSpi.getProviderNames
@Override public Set<String> getProviderNames() { Set<String> result = new HashSet<>(); for (RoundingProviderSpi prov : Bootstrap.getServices(RoundingProviderSpi.class)) { try { result.add(prov.getProviderName()); } catch (Exception e) { Logger.getLogger(Monetary.class.getName()) .log(Level.SEVERE, "Error loading RoundingProviderSpi from provider: " + prov, e); } } return result; }
java
@Override public Set<String> getProviderNames() { Set<String> result = new HashSet<>(); for (RoundingProviderSpi prov : Bootstrap.getServices(RoundingProviderSpi.class)) { try { result.add(prov.getProviderName()); } catch (Exception e) { Logger.getLogger(Monetary.class.getName()) .log(Level.SEVERE, "Error loading RoundingProviderSpi from provider: " + prov, e); } } return result; }
[ "@", "Override", "public", "Set", "<", "String", ">", "getProviderNames", "(", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "RoundingProviderSpi", "prov", ":", "Bootstrap", ".", "getServices", "(", "RoundingProviderSpi", ".", "class", ")", ")", "{", "try", "{", "result", ".", "add", "(", "prov", ".", "getProviderName", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Logger", ".", "getLogger", "(", "Monetary", ".", "class", ".", "getName", "(", ")", ")", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Error loading RoundingProviderSpi from provider: \"", "+", "prov", ",", "e", ")", ";", "}", "}", "return", "result", ";", "}" ]
Get the names of all current registered providers. @return the names of all current registered providers, never null.
[ "Get", "the", "names", "of", "all", "current", "registered", "providers", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/DefaultMonetaryRoundingsSingletonSpi.java#L106-L118
163,408
JavaMoney/jsr354-api
src/main/java/javax/money/DefaultMonetaryRoundingsSingletonSpi.java
DefaultMonetaryRoundingsSingletonSpi.getDefaultProviderChain
@Override public List<String> getDefaultProviderChain() { List<String> result = new ArrayList<>(Monetary.getRoundingProviderNames()); Collections.sort(result); return result; }
java
@Override public List<String> getDefaultProviderChain() { List<String> result = new ArrayList<>(Monetary.getRoundingProviderNames()); Collections.sort(result); return result; }
[ "@", "Override", "public", "List", "<", "String", ">", "getDefaultProviderChain", "(", ")", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<>", "(", "Monetary", ".", "getRoundingProviderNames", "(", ")", ")", ";", "Collections", ".", "sort", "(", "result", ")", ";", "return", "result", ";", "}" ]
Get the default providers list to be used. @return the default provider list and ordering, not null.
[ "Get", "the", "default", "providers", "list", "to", "be", "used", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/DefaultMonetaryRoundingsSingletonSpi.java#L125-L130
163,409
JavaMoney/jsr354-api
src/main/java/javax/money/DefaultMonetaryRoundingsSingletonSpi.java
DefaultMonetaryRoundingsSingletonSpi.getRoundingNames
@Override public Set<String> getRoundingNames(String... providers) { Set<String> result = new HashSet<>(); String[] providerNames = providers; if (providerNames.length == 0) { providerNames = Monetary.getDefaultRoundingProviderChain().toArray(new String[Monetary.getDefaultRoundingProviderChain().size()]); } for (String providerName : providerNames) { for (RoundingProviderSpi prov : Bootstrap.getServices(RoundingProviderSpi.class)) { try { if (prov.getProviderName().equals(providerName) || prov.getProviderName().matches(providerName)) { result.addAll(prov.getRoundingNames()); } } catch (Exception e) { Logger.getLogger(DefaultMonetaryRoundingsSingletonSpi.class.getName()) .log(Level.SEVERE, "Error loading RoundingProviderSpi from provider: " + prov, e); } } } return result; }
java
@Override public Set<String> getRoundingNames(String... providers) { Set<String> result = new HashSet<>(); String[] providerNames = providers; if (providerNames.length == 0) { providerNames = Monetary.getDefaultRoundingProviderChain().toArray(new String[Monetary.getDefaultRoundingProviderChain().size()]); } for (String providerName : providerNames) { for (RoundingProviderSpi prov : Bootstrap.getServices(RoundingProviderSpi.class)) { try { if (prov.getProviderName().equals(providerName) || prov.getProviderName().matches(providerName)) { result.addAll(prov.getRoundingNames()); } } catch (Exception e) { Logger.getLogger(DefaultMonetaryRoundingsSingletonSpi.class.getName()) .log(Level.SEVERE, "Error loading RoundingProviderSpi from provider: " + prov, e); } } } return result; }
[ "@", "Override", "public", "Set", "<", "String", ">", "getRoundingNames", "(", "String", "...", "providers", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "HashSet", "<>", "(", ")", ";", "String", "[", "]", "providerNames", "=", "providers", ";", "if", "(", "providerNames", ".", "length", "==", "0", ")", "{", "providerNames", "=", "Monetary", ".", "getDefaultRoundingProviderChain", "(", ")", ".", "toArray", "(", "new", "String", "[", "Monetary", ".", "getDefaultRoundingProviderChain", "(", ")", ".", "size", "(", ")", "]", ")", ";", "}", "for", "(", "String", "providerName", ":", "providerNames", ")", "{", "for", "(", "RoundingProviderSpi", "prov", ":", "Bootstrap", ".", "getServices", "(", "RoundingProviderSpi", ".", "class", ")", ")", "{", "try", "{", "if", "(", "prov", ".", "getProviderName", "(", ")", ".", "equals", "(", "providerName", ")", "||", "prov", ".", "getProviderName", "(", ")", ".", "matches", "(", "providerName", ")", ")", "{", "result", ".", "addAll", "(", "prov", ".", "getRoundingNames", "(", ")", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "Logger", ".", "getLogger", "(", "DefaultMonetaryRoundingsSingletonSpi", ".", "class", ".", "getName", "(", ")", ")", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Error loading RoundingProviderSpi from provider: \"", "+", "prov", ",", "e", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
Allows to access the identifiers of the current defined roundings. @param providers the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used, not null. @return the set of custom rounding ids, never {@code null}.
[ "Allows", "to", "access", "the", "identifiers", "of", "the", "current", "defined", "roundings", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/DefaultMonetaryRoundingsSingletonSpi.java#L139-L159
163,410
JavaMoney/jsr354-api
src/main/java/javax/money/convert/ConversionQuery.java
ConversionQuery.getRateTypes
@SuppressWarnings("unchecked") public Set<RateType> getRateTypes() { Set<RateType> result = get(KEY_RATE_TYPES, Set.class); if (result == null) { return Collections.emptySet(); } return result; }
java
@SuppressWarnings("unchecked") public Set<RateType> getRateTypes() { Set<RateType> result = get(KEY_RATE_TYPES, Set.class); if (result == null) { return Collections.emptySet(); } return result; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Set", "<", "RateType", ">", "getRateTypes", "(", ")", "{", "Set", "<", "RateType", ">", "result", "=", "get", "(", "KEY_RATE_TYPES", ",", "Set", ".", "class", ")", ";", "if", "(", "result", "==", "null", ")", "{", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "return", "result", ";", "}" ]
Get the rate types set. @return the rate types set, or an empty array, but never null.
[ "Get", "the", "rate", "types", "set", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/convert/ConversionQuery.java#L67-L74
163,411
JavaMoney/jsr354-api
src/main/java/javax/money/CurrencyQueryBuilder.java
CurrencyQueryBuilder.setCountries
public CurrencyQueryBuilder setCountries(Locale... countries) { return set(CurrencyQuery.KEY_QUERY_COUNTRIES, Arrays.asList(countries)); }
java
public CurrencyQueryBuilder setCountries(Locale... countries) { return set(CurrencyQuery.KEY_QUERY_COUNTRIES, Arrays.asList(countries)); }
[ "public", "CurrencyQueryBuilder", "setCountries", "(", "Locale", "...", "countries", ")", "{", "return", "set", "(", "CurrencyQuery", ".", "KEY_QUERY_COUNTRIES", ",", "Arrays", ".", "asList", "(", "countries", ")", ")", ";", "}" ]
Sets the country for which currencies should be requested. @param countries The ISO countries. @return the query for chaining.
[ "Sets", "the", "country", "for", "which", "currencies", "should", "be", "requested", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/CurrencyQueryBuilder.java#L58-L60
163,412
JavaMoney/jsr354-api
src/main/java/javax/money/CurrencyQueryBuilder.java
CurrencyQueryBuilder.setCurrencyCodes
public CurrencyQueryBuilder setCurrencyCodes(String... codes) { return set(CurrencyQuery.KEY_QUERY_CURRENCY_CODES, Arrays.asList(codes)); }
java
public CurrencyQueryBuilder setCurrencyCodes(String... codes) { return set(CurrencyQuery.KEY_QUERY_CURRENCY_CODES, Arrays.asList(codes)); }
[ "public", "CurrencyQueryBuilder", "setCurrencyCodes", "(", "String", "...", "codes", ")", "{", "return", "set", "(", "CurrencyQuery", ".", "KEY_QUERY_CURRENCY_CODES", ",", "Arrays", ".", "asList", "(", "codes", ")", ")", ";", "}" ]
Sets the currency code, or the regular expression to select codes. @param codes the currency codes or code expressions, not null. @return the query for chaining.
[ "Sets", "the", "currency", "code", "or", "the", "regular", "expression", "to", "select", "codes", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/CurrencyQueryBuilder.java#L68-L70
163,413
JavaMoney/jsr354-api
src/main/java/javax/money/CurrencyQueryBuilder.java
CurrencyQueryBuilder.setNumericCodes
public CurrencyQueryBuilder setNumericCodes(int... codes) { return set(CurrencyQuery.KEY_QUERY_NUMERIC_CODES, Arrays.stream(codes).boxed().collect(Collectors.toList())); }
java
public CurrencyQueryBuilder setNumericCodes(int... codes) { return set(CurrencyQuery.KEY_QUERY_NUMERIC_CODES, Arrays.stream(codes).boxed().collect(Collectors.toList())); }
[ "public", "CurrencyQueryBuilder", "setNumericCodes", "(", "int", "...", "codes", ")", "{", "return", "set", "(", "CurrencyQuery", ".", "KEY_QUERY_NUMERIC_CODES", ",", "Arrays", ".", "stream", "(", "codes", ")", ".", "boxed", "(", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ")", ";", "}" ]
Set the numeric code. Setting it to -1 search for currencies that have no numeric code. @param codes the numeric codes. @return the query for chaining.
[ "Set", "the", "numeric", "code", ".", "Setting", "it", "to", "-", "1", "search", "for", "currencies", "that", "have", "no", "numeric", "code", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/CurrencyQueryBuilder.java#L78-L81
163,414
JavaMoney/jsr354-api
src/main/java/javax/money/convert/MonetaryConversions.java
MonetaryConversions.getDefaultConversionProviderChain
public static List<String> getDefaultConversionProviderChain(){ List<String> defaultChain = getMonetaryConversionsSpi() .getDefaultProviderChain(); Objects.requireNonNull(defaultChain, "No default provider chain provided by SPI: " + getMonetaryConversionsSpi().getClass().getName()); return defaultChain; }
java
public static List<String> getDefaultConversionProviderChain(){ List<String> defaultChain = getMonetaryConversionsSpi() .getDefaultProviderChain(); Objects.requireNonNull(defaultChain, "No default provider chain provided by SPI: " + getMonetaryConversionsSpi().getClass().getName()); return defaultChain; }
[ "public", "static", "List", "<", "String", ">", "getDefaultConversionProviderChain", "(", ")", "{", "List", "<", "String", ">", "defaultChain", "=", "getMonetaryConversionsSpi", "(", ")", ".", "getDefaultProviderChain", "(", ")", ";", "Objects", ".", "requireNonNull", "(", "defaultChain", ",", "\"No default provider chain provided by SPI: \"", "+", "getMonetaryConversionsSpi", "(", ")", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "return", "defaultChain", ";", "}" ]
Get the default provider used. @return the default provider, never {@code null}.
[ "Get", "the", "default", "provider", "used", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/convert/MonetaryConversions.java#L256-L262
163,415
JavaMoney/jsr354-api
src/main/java/javax/money/AbstractContext.java
AbstractContext.getKeys
public Set<String> getKeys(Class<?> type) { return data.entrySet().stream().filter(val -> type.isAssignableFrom(val.getValue() .getClass())).map(Map.Entry::getKey).collect(Collectors .toSet()); }
java
public Set<String> getKeys(Class<?> type) { return data.entrySet().stream().filter(val -> type.isAssignableFrom(val.getValue() .getClass())).map(Map.Entry::getKey).collect(Collectors .toSet()); }
[ "public", "Set", "<", "String", ">", "getKeys", "(", "Class", "<", "?", ">", "type", ")", "{", "return", "data", ".", "entrySet", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "val", "->", "type", ".", "isAssignableFrom", "(", "val", ".", "getValue", "(", ")", ".", "getClass", "(", ")", ")", ")", ".", "map", "(", "Map", ".", "Entry", "::", "getKey", ")", ".", "collect", "(", "Collectors", ".", "toSet", "(", ")", ")", ";", "}" ]
Get the present keys of all entries with a given type, checking hereby if assignable. @param type The attribute type, not null. @return all present keys of attributes being assignable to the type, never null.
[ "Get", "the", "present", "keys", "of", "all", "entries", "with", "a", "given", "type", "checking", "hereby", "if", "assignable", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/AbstractContext.java#L63-L67
163,416
JavaMoney/jsr354-api
src/main/java/javax/money/AbstractContext.java
AbstractContext.getType
public Class<?> getType(String key) { Object val = this.data.get(key); return val == null ? null : val.getClass(); }
java
public Class<?> getType(String key) { Object val = this.data.get(key); return val == null ? null : val.getClass(); }
[ "public", "Class", "<", "?", ">", "getType", "(", "String", "key", ")", "{", "Object", "val", "=", "this", ".", "data", ".", "get", "(", "key", ")", ";", "return", "val", "==", "null", "?", "null", ":", "val", ".", "getClass", "(", ")", ";", "}" ]
Get the current attribute type. @param key the entry's key, not null @return the current attribute type, or null, if no such attribute exists.
[ "Get", "the", "current", "attribute", "type", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/AbstractContext.java#L74-L77
163,417
JavaMoney/jsr354-api
src/main/java/javax/money/AbstractContext.java
AbstractContext.get
public <T> T get(String key, Class<T> type) { Object value = this.data.get(key); if (value != null && type.isAssignableFrom(value.getClass())) { return (T) value; } return null; }
java
public <T> T get(String key, Class<T> type) { Object value = this.data.get(key); if (value != null && type.isAssignableFrom(value.getClass())) { return (T) value; } return null; }
[ "public", "<", "T", ">", "T", "get", "(", "String", "key", ",", "Class", "<", "T", ">", "type", ")", "{", "Object", "value", "=", "this", ".", "data", ".", "get", "(", "key", ")", ";", "if", "(", "value", "!=", "null", "&&", "type", ".", "isAssignableFrom", "(", "value", ".", "getClass", "(", ")", ")", ")", "{", "return", "(", "T", ")", "value", ";", "}", "return", "null", ";", "}" ]
Access an attribute. @param type the attribute's type, not {@code null} @param key the attribute's key, not {@code null} @return the attribute value, or {@code null}.
[ "Access", "an", "attribute", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/AbstractContext.java#L87-L93
163,418
JavaMoney/jsr354-api
src/main/java/javax/money/AbstractContext.java
AbstractContext.get
public <T> T get(Class<T> type) { return get(type.getName(), type); }
java
public <T> T get(Class<T> type) { return get(type.getName(), type); }
[ "public", "<", "T", ">", "T", "get", "(", "Class", "<", "T", ">", "type", ")", "{", "return", "get", "(", "type", ".", "getName", "(", ")", ",", "type", ")", ";", "}" ]
Access an attribute, hereby using the class name as key. @param type the type, not {@code null} @return the type attribute value, or {@code null}.
[ "Access", "an", "attribute", "hereby", "using", "the", "class", "name", "as", "key", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/AbstractContext.java#L101-L103
163,419
JavaMoney/jsr354-api
src/main/java/javax/money/AbstractQueryBuilder.java
AbstractQueryBuilder.setTargetType
@SuppressWarnings("unchecked") public B setTargetType(Class<?> type) { Objects.requireNonNull(type); set(AbstractQuery.KEY_QUERY_TARGET_TYPE, type); return (B) this; }
java
@SuppressWarnings("unchecked") public B setTargetType(Class<?> type) { Objects.requireNonNull(type); set(AbstractQuery.KEY_QUERY_TARGET_TYPE, type); return (B) this; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "B", "setTargetType", "(", "Class", "<", "?", ">", "type", ")", "{", "Objects", ".", "requireNonNull", "(", "type", ")", ";", "set", "(", "AbstractQuery", ".", "KEY_QUERY_TARGET_TYPE", ",", "type", ")", ";", "return", "(", "B", ")", "this", ";", "}" ]
Sets the target implementation type required. This can be used to explicitly acquire a specific implementation type and use a query to configure the instance or factory to be returned. @param type the target implementation type, not null. @return this query builder for chaining.
[ "Sets", "the", "target", "implementation", "type", "required", ".", "This", "can", "be", "used", "to", "explicitly", "acquire", "a", "specific", "implementation", "type", "and", "use", "a", "query", "to", "configure", "the", "instance", "or", "factory", "to", "be", "returned", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/AbstractQueryBuilder.java#L97-L102
163,420
JavaMoney/jsr354-api
src/main/java/javax/money/convert/ProviderContext.java
ProviderContext.getRateTypes
public Set<RateType> getRateTypes() { @SuppressWarnings("unchecked") Set<RateType> rateSet = get(KEY_RATE_TYPES, Set.class); if (rateSet == null) { return Collections.emptySet(); } return Collections.unmodifiableSet(rateSet); }
java
public Set<RateType> getRateTypes() { @SuppressWarnings("unchecked") Set<RateType> rateSet = get(KEY_RATE_TYPES, Set.class); if (rateSet == null) { return Collections.emptySet(); } return Collections.unmodifiableSet(rateSet); }
[ "public", "Set", "<", "RateType", ">", "getRateTypes", "(", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Set", "<", "RateType", ">", "rateSet", "=", "get", "(", "KEY_RATE_TYPES", ",", "Set", ".", "class", ")", ";", "if", "(", "rateSet", "==", "null", ")", "{", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "return", "Collections", ".", "unmodifiableSet", "(", "rateSet", ")", ";", "}" ]
Get the deferred flag. Exchange rates can be deferred or real.time. @return the deferred flag, or {code null}.
[ "Get", "the", "deferred", "flag", ".", "Exchange", "rates", "can", "be", "deferred", "or", "real", ".", "time", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/convert/ProviderContext.java#L66-L73
163,421
JavaMoney/jsr354-api
src/main/java/javax/money/format/MonetaryFormats.java
MonetaryFormats.loadMonetaryFormatsSingletonSpi
private static MonetaryFormatsSingletonSpi loadMonetaryFormatsSingletonSpi() { try { return Optional.ofNullable(Bootstrap.getService(MonetaryFormatsSingletonSpi.class)) .orElseGet(DefaultMonetaryFormatsSingletonSpi::new); } catch (Exception e) { Logger.getLogger(MonetaryFormats.class.getName()) .log(Level.WARNING, "Failed to load MonetaryFormatsSingletonSpi, using default.", e); return new DefaultMonetaryFormatsSingletonSpi(); } }
java
private static MonetaryFormatsSingletonSpi loadMonetaryFormatsSingletonSpi() { try { return Optional.ofNullable(Bootstrap.getService(MonetaryFormatsSingletonSpi.class)) .orElseGet(DefaultMonetaryFormatsSingletonSpi::new); } catch (Exception e) { Logger.getLogger(MonetaryFormats.class.getName()) .log(Level.WARNING, "Failed to load MonetaryFormatsSingletonSpi, using default.", e); return new DefaultMonetaryFormatsSingletonSpi(); } }
[ "private", "static", "MonetaryFormatsSingletonSpi", "loadMonetaryFormatsSingletonSpi", "(", ")", "{", "try", "{", "return", "Optional", ".", "ofNullable", "(", "Bootstrap", ".", "getService", "(", "MonetaryFormatsSingletonSpi", ".", "class", ")", ")", ".", "orElseGet", "(", "DefaultMonetaryFormatsSingletonSpi", "::", "new", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Logger", ".", "getLogger", "(", "MonetaryFormats", ".", "class", ".", "getName", "(", ")", ")", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Failed to load MonetaryFormatsSingletonSpi, using default.\"", ",", "e", ")", ";", "return", "new", "DefaultMonetaryFormatsSingletonSpi", "(", ")", ";", "}", "}" ]
Loads the SPI backing bean. @return the instance of MonetaryFormatsSingletonSpi to be used by this singleton.
[ "Loads", "the", "SPI", "backing", "bean", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/format/MonetaryFormats.java#L54-L63
163,422
JavaMoney/jsr354-api
src/main/java/javax/money/format/MonetaryFormats.java
MonetaryFormats.getFormatProviderNames
public static Collection<String> getFormatProviderNames() { Collection<String> providers = Optional.ofNullable(getMonetaryFormatsSpi()).orElseThrow( () -> new MonetaryException( "No MonetaryFormatsSingletonSpi loaded, query functionality is not available.")) .getProviderNames(); if (Objects.isNull(providers)) { Logger.getLogger(MonetaryFormats.class.getName()).warning( "No supported rate/conversion providers returned by SPI: " + getMonetaryFormatsSpi().getClass().getName()); return Collections.emptySet(); } return providers; }
java
public static Collection<String> getFormatProviderNames() { Collection<String> providers = Optional.ofNullable(getMonetaryFormatsSpi()).orElseThrow( () -> new MonetaryException( "No MonetaryFormatsSingletonSpi loaded, query functionality is not available.")) .getProviderNames(); if (Objects.isNull(providers)) { Logger.getLogger(MonetaryFormats.class.getName()).warning( "No supported rate/conversion providers returned by SPI: " + getMonetaryFormatsSpi().getClass().getName()); return Collections.emptySet(); } return providers; }
[ "public", "static", "Collection", "<", "String", ">", "getFormatProviderNames", "(", ")", "{", "Collection", "<", "String", ">", "providers", "=", "Optional", ".", "ofNullable", "(", "getMonetaryFormatsSpi", "(", ")", ")", ".", "orElseThrow", "(", "(", ")", "->", "new", "MonetaryException", "(", "\"No MonetaryFormatsSingletonSpi loaded, query functionality is not available.\"", ")", ")", ".", "getProviderNames", "(", ")", ";", "if", "(", "Objects", ".", "isNull", "(", "providers", ")", ")", "{", "Logger", ".", "getLogger", "(", "MonetaryFormats", ".", "class", ".", "getName", "(", ")", ")", ".", "warning", "(", "\"No supported rate/conversion providers returned by SPI: \"", "+", "getMonetaryFormatsSpi", "(", ")", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "return", "providers", ";", "}" ]
Get the names of the currently registered format providers. @return the provider names, never null.
[ "Get", "the", "names", "of", "the", "currently", "registered", "format", "providers", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/format/MonetaryFormats.java#L169-L181
163,423
JavaMoney/jsr354-api
src/main/java/javax/money/convert/ProviderContextBuilder.java
ProviderContextBuilder.setRateTypes
public ProviderContextBuilder setRateTypes(Collection<RateType> rateTypes) { Objects.requireNonNull(rateTypes); if (rateTypes.isEmpty()) { throw new IllegalArgumentException("At least one RateType is required."); } Set<RateType> rtSet = new HashSet<>(rateTypes); set(ProviderContext.KEY_RATE_TYPES, rtSet); return this; }
java
public ProviderContextBuilder setRateTypes(Collection<RateType> rateTypes) { Objects.requireNonNull(rateTypes); if (rateTypes.isEmpty()) { throw new IllegalArgumentException("At least one RateType is required."); } Set<RateType> rtSet = new HashSet<>(rateTypes); set(ProviderContext.KEY_RATE_TYPES, rtSet); return this; }
[ "public", "ProviderContextBuilder", "setRateTypes", "(", "Collection", "<", "RateType", ">", "rateTypes", ")", "{", "Objects", ".", "requireNonNull", "(", "rateTypes", ")", ";", "if", "(", "rateTypes", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"At least one RateType is required.\"", ")", ";", "}", "Set", "<", "RateType", ">", "rtSet", "=", "new", "HashSet", "<>", "(", "rateTypes", ")", ";", "set", "(", "ProviderContext", ".", "KEY_RATE_TYPES", ",", "rtSet", ")", ";", "return", "this", ";", "}" ]
Set the rate types. @param rateTypes the rate types, not null and not empty. @return this, for chaining. @throws IllegalArgumentException when not at least one {@link RateType} is provided.
[ "Set", "the", "rate", "types", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/convert/ProviderContextBuilder.java#L93-L101
163,424
JavaMoney/jsr354-api
src/main/java/javax/money/AbstractContextBuilder.java
AbstractContextBuilder.importContext
public B importContext(AbstractContext context, boolean overwriteDuplicates){ for (Map.Entry<String, Object> en : context.data.entrySet()) { if (overwriteDuplicates) { this.data.put(en.getKey(), en.getValue()); }else{ this.data.putIfAbsent(en.getKey(), en.getValue()); } } return (B) this; }
java
public B importContext(AbstractContext context, boolean overwriteDuplicates){ for (Map.Entry<String, Object> en : context.data.entrySet()) { if (overwriteDuplicates) { this.data.put(en.getKey(), en.getValue()); }else{ this.data.putIfAbsent(en.getKey(), en.getValue()); } } return (B) this; }
[ "public", "B", "importContext", "(", "AbstractContext", "context", ",", "boolean", "overwriteDuplicates", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Object", ">", "en", ":", "context", ".", "data", ".", "entrySet", "(", ")", ")", "{", "if", "(", "overwriteDuplicates", ")", "{", "this", ".", "data", ".", "put", "(", "en", ".", "getKey", "(", ")", ",", "en", ".", "getValue", "(", ")", ")", ";", "}", "else", "{", "this", ".", "data", ".", "putIfAbsent", "(", "en", ".", "getKey", "(", ")", ",", "en", ".", "getValue", "(", ")", ")", ";", "}", "}", "return", "(", "B", ")", "this", ";", "}" ]
Apply all attributes on the given context. @param context the context to be applied, not null. @param overwriteDuplicates flag, if existing entries should be overwritten. @return this Builder, for chaining
[ "Apply", "all", "attributes", "on", "the", "given", "context", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/AbstractContextBuilder.java#L48-L57
163,425
JavaMoney/jsr354-api
src/main/java/javax/money/AbstractContextBuilder.java
AbstractContextBuilder.importContext
public B importContext(AbstractContext context){ Objects.requireNonNull(context); return importContext(context, false); }
java
public B importContext(AbstractContext context){ Objects.requireNonNull(context); return importContext(context, false); }
[ "public", "B", "importContext", "(", "AbstractContext", "context", ")", "{", "Objects", ".", "requireNonNull", "(", "context", ")", ";", "return", "importContext", "(", "context", ",", "false", ")", ";", "}" ]
Apply all attributes on the given context, hereby existing entries are preserved. @param context the context to be applied, not null. @return this Builder, for chaining @see #importContext(AbstractContext, boolean)
[ "Apply", "all", "attributes", "on", "the", "given", "context", "hereby", "existing", "entries", "are", "preserved", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/AbstractContextBuilder.java#L66-L69
163,426
JavaMoney/jsr354-api
src/main/java/javax/money/AbstractContextBuilder.java
AbstractContextBuilder.set
public B set(String key, int value) { this.data.put(key, value); return (B) this; }
java
public B set(String key, int value) { this.data.put(key, value); return (B) this; }
[ "public", "B", "set", "(", "String", "key", ",", "int", "value", ")", "{", "this", ".", "data", ".", "put", "(", "key", ",", "value", ")", ";", "return", "(", "B", ")", "this", ";", "}" ]
Sets an Integer attribute. @param key the key, non null. @param value the value @return the Builder, for chaining.
[ "Sets", "an", "Integer", "attribute", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/AbstractContextBuilder.java#L78-L81
163,427
JavaMoney/jsr354-api
src/main/java/javax/money/Monetary.java
Monetary.getRoundingNames
public static Set<String> getRoundingNames(String... providers) { return Optional.ofNullable(monetaryRoundingsSingletonSpi()).orElseThrow( () -> new MonetaryException("No MonetaryRoundingsSpi loaded, query functionality is not available.")) .getRoundingNames(providers); }
java
public static Set<String> getRoundingNames(String... providers) { return Optional.ofNullable(monetaryRoundingsSingletonSpi()).orElseThrow( () -> new MonetaryException("No MonetaryRoundingsSpi loaded, query functionality is not available.")) .getRoundingNames(providers); }
[ "public", "static", "Set", "<", "String", ">", "getRoundingNames", "(", "String", "...", "providers", ")", "{", "return", "Optional", ".", "ofNullable", "(", "monetaryRoundingsSingletonSpi", "(", ")", ")", ".", "orElseThrow", "(", "(", ")", "->", "new", "MonetaryException", "(", "\"No MonetaryRoundingsSpi loaded, query functionality is not available.\"", ")", ")", ".", "getRoundingNames", "(", "providers", ")", ";", "}" ]
Allows to access the names of the current defined roundings. @param providers the providers and ordering to be used. By default providers and ordering as defined in #getDefaultProviders is used. @return the set of custom rounding ids, never {@code null}.
[ "Allows", "to", "access", "the", "names", "of", "the", "current", "defined", "roundings", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/Monetary.java#L262-L266
163,428
JavaMoney/jsr354-api
src/main/java/javax/money/Monetary.java
Monetary.getAmountFactory
@SuppressWarnings("rawtypes") public static MonetaryAmountFactory getAmountFactory(MonetaryAmountFactoryQuery query) { return Optional.ofNullable(monetaryAmountsSingletonQuerySpi()).orElseThrow(() -> new MonetaryException( "No MonetaryAmountsSingletonQuerySpi loaded, query functionality is not available.")) .getAmountFactory(query); }
java
@SuppressWarnings("rawtypes") public static MonetaryAmountFactory getAmountFactory(MonetaryAmountFactoryQuery query) { return Optional.ofNullable(monetaryAmountsSingletonQuerySpi()).orElseThrow(() -> new MonetaryException( "No MonetaryAmountsSingletonQuerySpi loaded, query functionality is not available.")) .getAmountFactory(query); }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "static", "MonetaryAmountFactory", "getAmountFactory", "(", "MonetaryAmountFactoryQuery", "query", ")", "{", "return", "Optional", ".", "ofNullable", "(", "monetaryAmountsSingletonQuerySpi", "(", ")", ")", ".", "orElseThrow", "(", "(", ")", "->", "new", "MonetaryException", "(", "\"No MonetaryAmountsSingletonQuerySpi loaded, query functionality is not available.\"", ")", ")", ".", "getAmountFactory", "(", "query", ")", ";", "}" ]
Executes the query and returns the factory found, if there is only one factory. If multiple factories match the query, one is selected. @param query the factory query, not null. @return the factory found, or null.
[ "Executes", "the", "query", "and", "returns", "the", "factory", "found", "if", "there", "is", "only", "one", "factory", ".", "If", "multiple", "factories", "match", "the", "query", "one", "is", "selected", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/Monetary.java#L344-L349
163,429
JavaMoney/jsr354-api
src/main/java/javax/money/Monetary.java
Monetary.getAmountFactories
public static Collection<MonetaryAmountFactory<?>> getAmountFactories(MonetaryAmountFactoryQuery query) { return Optional.ofNullable(monetaryAmountsSingletonQuerySpi()).orElseThrow(() -> new MonetaryException( "No MonetaryAmountsSingletonQuerySpi loaded, query functionality is not available.")) .getAmountFactories(query); }
java
public static Collection<MonetaryAmountFactory<?>> getAmountFactories(MonetaryAmountFactoryQuery query) { return Optional.ofNullable(monetaryAmountsSingletonQuerySpi()).orElseThrow(() -> new MonetaryException( "No MonetaryAmountsSingletonQuerySpi loaded, query functionality is not available.")) .getAmountFactories(query); }
[ "public", "static", "Collection", "<", "MonetaryAmountFactory", "<", "?", ">", ">", "getAmountFactories", "(", "MonetaryAmountFactoryQuery", "query", ")", "{", "return", "Optional", ".", "ofNullable", "(", "monetaryAmountsSingletonQuerySpi", "(", ")", ")", ".", "orElseThrow", "(", "(", ")", "->", "new", "MonetaryException", "(", "\"No MonetaryAmountsSingletonQuerySpi loaded, query functionality is not available.\"", ")", ")", ".", "getAmountFactories", "(", "query", ")", ";", "}" ]
Returns all factory instances that match the query. @param query the factory query, not null. @return the instances found, never null.
[ "Returns", "all", "factory", "instances", "that", "match", "the", "query", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/Monetary.java#L357-L361
163,430
JavaMoney/jsr354-api
src/main/java/javax/money/Monetary.java
Monetary.getCurrencies
public static Collection<CurrencyUnit> getCurrencies(String... providers) { return Optional.ofNullable(MONETARY_CURRENCIES_SINGLETON_SPI()).orElseThrow( () -> new MonetaryException("No MonetaryCurrenciesSingletonSpi loaded, check your system setup.")) .getCurrencies(providers); }
java
public static Collection<CurrencyUnit> getCurrencies(String... providers) { return Optional.ofNullable(MONETARY_CURRENCIES_SINGLETON_SPI()).orElseThrow( () -> new MonetaryException("No MonetaryCurrenciesSingletonSpi loaded, check your system setup.")) .getCurrencies(providers); }
[ "public", "static", "Collection", "<", "CurrencyUnit", ">", "getCurrencies", "(", "String", "...", "providers", ")", "{", "return", "Optional", ".", "ofNullable", "(", "MONETARY_CURRENCIES_SINGLETON_SPI", "(", ")", ")", ".", "orElseThrow", "(", "(", ")", "->", "new", "MonetaryException", "(", "\"No MonetaryCurrenciesSingletonSpi loaded, check your system setup.\"", ")", ")", ".", "getCurrencies", "(", "providers", ")", ";", "}" ]
Access all currencies known. @param providers the (optional) specification of providers to consider. @return the list of known currencies, never null.
[ "Access", "all", "currencies", "known", "." ]
49a7ae436eaf45cac1040879185531ef22de5525
https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/Monetary.java#L458-L462
163,431
jfrog/artifactory-client-java
httpClient/src/main/java/org/jfrog/artifactory/client/httpClient/http/HttpBuilderBase.java
HttpBuilderBase.createConnectionMgr
private PoolingHttpClientConnectionManager createConnectionMgr() { PoolingHttpClientConnectionManager connectionMgr; // prepare SSLContext SSLContext sslContext = buildSslContext(); ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory(); // we allow to disable host name verification against CA certificate, // notice: in general this is insecure and should be avoided in production, // (this type of configuration is useful for development purposes) boolean noHostVerification = false; LayeredConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( sslContext, noHostVerification ? NoopHostnameVerifier.INSTANCE : new DefaultHostnameVerifier() ); Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", plainsf) .register("https", sslsf) .build(); connectionMgr = new PoolingHttpClientConnectionManager(r, null, null, null, connectionPoolTimeToLive, TimeUnit.SECONDS); connectionMgr.setMaxTotal(maxConnectionsTotal); connectionMgr.setDefaultMaxPerRoute(maxConnectionsPerRoute); HttpHost localhost = new HttpHost("localhost", 80); connectionMgr.setMaxPerRoute(new HttpRoute(localhost), maxConnectionsPerRoute); return connectionMgr; }
java
private PoolingHttpClientConnectionManager createConnectionMgr() { PoolingHttpClientConnectionManager connectionMgr; // prepare SSLContext SSLContext sslContext = buildSslContext(); ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory(); // we allow to disable host name verification against CA certificate, // notice: in general this is insecure and should be avoided in production, // (this type of configuration is useful for development purposes) boolean noHostVerification = false; LayeredConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( sslContext, noHostVerification ? NoopHostnameVerifier.INSTANCE : new DefaultHostnameVerifier() ); Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", plainsf) .register("https", sslsf) .build(); connectionMgr = new PoolingHttpClientConnectionManager(r, null, null, null, connectionPoolTimeToLive, TimeUnit.SECONDS); connectionMgr.setMaxTotal(maxConnectionsTotal); connectionMgr.setDefaultMaxPerRoute(maxConnectionsPerRoute); HttpHost localhost = new HttpHost("localhost", 80); connectionMgr.setMaxPerRoute(new HttpRoute(localhost), maxConnectionsPerRoute); return connectionMgr; }
[ "private", "PoolingHttpClientConnectionManager", "createConnectionMgr", "(", ")", "{", "PoolingHttpClientConnectionManager", "connectionMgr", ";", "// prepare SSLContext", "SSLContext", "sslContext", "=", "buildSslContext", "(", ")", ";", "ConnectionSocketFactory", "plainsf", "=", "PlainConnectionSocketFactory", ".", "getSocketFactory", "(", ")", ";", "// we allow to disable host name verification against CA certificate,", "// notice: in general this is insecure and should be avoided in production,", "// (this type of configuration is useful for development purposes)", "boolean", "noHostVerification", "=", "false", ";", "LayeredConnectionSocketFactory", "sslsf", "=", "new", "SSLConnectionSocketFactory", "(", "sslContext", ",", "noHostVerification", "?", "NoopHostnameVerifier", ".", "INSTANCE", ":", "new", "DefaultHostnameVerifier", "(", ")", ")", ";", "Registry", "<", "ConnectionSocketFactory", ">", "r", "=", "RegistryBuilder", ".", "<", "ConnectionSocketFactory", ">", "create", "(", ")", ".", "register", "(", "\"http\"", ",", "plainsf", ")", ".", "register", "(", "\"https\"", ",", "sslsf", ")", ".", "build", "(", ")", ";", "connectionMgr", "=", "new", "PoolingHttpClientConnectionManager", "(", "r", ",", "null", ",", "null", ",", "null", ",", "connectionPoolTimeToLive", ",", "TimeUnit", ".", "SECONDS", ")", ";", "connectionMgr", ".", "setMaxTotal", "(", "maxConnectionsTotal", ")", ";", "connectionMgr", ".", "setDefaultMaxPerRoute", "(", "maxConnectionsPerRoute", ")", ";", "HttpHost", "localhost", "=", "new", "HttpHost", "(", "\"localhost\"", ",", "80", ")", ";", "connectionMgr", ".", "setMaxPerRoute", "(", "new", "HttpRoute", "(", "localhost", ")", ",", "maxConnectionsPerRoute", ")", ";", "return", "connectionMgr", ";", "}" ]
Creates custom Http Client connection pool to be used by Http Client @return {@link PoolingHttpClientConnectionManager}
[ "Creates", "custom", "Http", "Client", "connection", "pool", "to", "be", "used", "by", "Http", "Client" ]
e7443f4ffa8bf7d3b161f9cdc59bfc3036e9b46e
https://github.com/jfrog/artifactory-client-java/blob/e7443f4ffa8bf7d3b161f9cdc59bfc3036e9b46e/httpClient/src/main/java/org/jfrog/artifactory/client/httpClient/http/HttpBuilderBase.java#L269-L295
163,432
jfrog/artifactory-client-java
services/src/main/groovy/org/jfrog/artifactory/client/impl/ArtifactoryImpl.java
ArtifactoryImpl.restCall
@Override public ArtifactoryResponse restCall(ArtifactoryRequest artifactoryRequest) throws IOException { HttpRequestBase httpRequest; String requestPath = "/" + artifactoryRequest.getApiUrl(); ContentType contentType = Util.getContentType(artifactoryRequest.getRequestType()); String queryPath = ""; if (!artifactoryRequest.getQueryParams().isEmpty()) { queryPath = Util.getQueryPath("?", artifactoryRequest.getQueryParams()); } switch (artifactoryRequest.getMethod()) { case GET: httpRequest = new HttpGet(); break; case POST: httpRequest = new HttpPost(); setEntity((HttpPost)httpRequest, artifactoryRequest.getBody(), contentType); break; case PUT: httpRequest = new HttpPut(); setEntity((HttpPut)httpRequest, artifactoryRequest.getBody(), contentType); break; case DELETE: httpRequest = new HttpDelete(); break; case PATCH: httpRequest = new HttpPatch(); setEntity((HttpPatch)httpRequest, artifactoryRequest.getBody(), contentType); break; case OPTIONS: httpRequest = new HttpOptions(); break; default: throw new IllegalArgumentException("Unsupported request method."); } httpRequest.setURI(URI.create(url + requestPath + queryPath)); addAccessTokenHeaderIfNeeded(httpRequest); if (contentType != null) { httpRequest.setHeader("Content-type", contentType.getMimeType()); } Map<String, String> headers = artifactoryRequest.getHeaders(); for (String key : headers.keySet()) { httpRequest.setHeader(key, headers.get(key)); } HttpResponse httpResponse = httpClient.execute(httpRequest); return new ArtifactoryResponseImpl(httpResponse); }
java
@Override public ArtifactoryResponse restCall(ArtifactoryRequest artifactoryRequest) throws IOException { HttpRequestBase httpRequest; String requestPath = "/" + artifactoryRequest.getApiUrl(); ContentType contentType = Util.getContentType(artifactoryRequest.getRequestType()); String queryPath = ""; if (!artifactoryRequest.getQueryParams().isEmpty()) { queryPath = Util.getQueryPath("?", artifactoryRequest.getQueryParams()); } switch (artifactoryRequest.getMethod()) { case GET: httpRequest = new HttpGet(); break; case POST: httpRequest = new HttpPost(); setEntity((HttpPost)httpRequest, artifactoryRequest.getBody(), contentType); break; case PUT: httpRequest = new HttpPut(); setEntity((HttpPut)httpRequest, artifactoryRequest.getBody(), contentType); break; case DELETE: httpRequest = new HttpDelete(); break; case PATCH: httpRequest = new HttpPatch(); setEntity((HttpPatch)httpRequest, artifactoryRequest.getBody(), contentType); break; case OPTIONS: httpRequest = new HttpOptions(); break; default: throw new IllegalArgumentException("Unsupported request method."); } httpRequest.setURI(URI.create(url + requestPath + queryPath)); addAccessTokenHeaderIfNeeded(httpRequest); if (contentType != null) { httpRequest.setHeader("Content-type", contentType.getMimeType()); } Map<String, String> headers = artifactoryRequest.getHeaders(); for (String key : headers.keySet()) { httpRequest.setHeader(key, headers.get(key)); } HttpResponse httpResponse = httpClient.execute(httpRequest); return new ArtifactoryResponseImpl(httpResponse); }
[ "@", "Override", "public", "ArtifactoryResponse", "restCall", "(", "ArtifactoryRequest", "artifactoryRequest", ")", "throws", "IOException", "{", "HttpRequestBase", "httpRequest", ";", "String", "requestPath", "=", "\"/\"", "+", "artifactoryRequest", ".", "getApiUrl", "(", ")", ";", "ContentType", "contentType", "=", "Util", ".", "getContentType", "(", "artifactoryRequest", ".", "getRequestType", "(", ")", ")", ";", "String", "queryPath", "=", "\"\"", ";", "if", "(", "!", "artifactoryRequest", ".", "getQueryParams", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "queryPath", "=", "Util", ".", "getQueryPath", "(", "\"?\"", ",", "artifactoryRequest", ".", "getQueryParams", "(", ")", ")", ";", "}", "switch", "(", "artifactoryRequest", ".", "getMethod", "(", ")", ")", "{", "case", "GET", ":", "httpRequest", "=", "new", "HttpGet", "(", ")", ";", "break", ";", "case", "POST", ":", "httpRequest", "=", "new", "HttpPost", "(", ")", ";", "setEntity", "(", "(", "HttpPost", ")", "httpRequest", ",", "artifactoryRequest", ".", "getBody", "(", ")", ",", "contentType", ")", ";", "break", ";", "case", "PUT", ":", "httpRequest", "=", "new", "HttpPut", "(", ")", ";", "setEntity", "(", "(", "HttpPut", ")", "httpRequest", ",", "artifactoryRequest", ".", "getBody", "(", ")", ",", "contentType", ")", ";", "break", ";", "case", "DELETE", ":", "httpRequest", "=", "new", "HttpDelete", "(", ")", ";", "break", ";", "case", "PATCH", ":", "httpRequest", "=", "new", "HttpPatch", "(", ")", ";", "setEntity", "(", "(", "HttpPatch", ")", "httpRequest", ",", "artifactoryRequest", ".", "getBody", "(", ")", ",", "contentType", ")", ";", "break", ";", "case", "OPTIONS", ":", "httpRequest", "=", "new", "HttpOptions", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", "\"Unsupported request method.\"", ")", ";", "}", "httpRequest", ".", "setURI", "(", "URI", ".", "create", "(", "url", "+", "requestPath", "+", "queryPath", ")", ")", ";", "addAccessTokenHeaderIfNeeded", "(", "httpRequest", ")", ";", "if", "(", "contentType", "!=", "null", ")", "{", "httpRequest", ".", "setHeader", "(", "\"Content-type\"", ",", "contentType", ".", "getMimeType", "(", ")", ")", ";", "}", "Map", "<", "String", ",", "String", ">", "headers", "=", "artifactoryRequest", ".", "getHeaders", "(", ")", ";", "for", "(", "String", "key", ":", "headers", ".", "keySet", "(", ")", ")", "{", "httpRequest", ".", "setHeader", "(", "key", ",", "headers", ".", "get", "(", "key", ")", ")", ";", "}", "HttpResponse", "httpResponse", "=", "httpClient", ".", "execute", "(", "httpRequest", ")", ";", "return", "new", "ArtifactoryResponseImpl", "(", "httpResponse", ")", ";", "}" ]
Create a REST call to artifactory with a generic request @param artifactoryRequest that should be sent to artifactory @return {@link ArtifactoryResponse} artifactory response as per to the request sent
[ "Create", "a", "REST", "call", "to", "artifactory", "with", "a", "generic", "request" ]
e7443f4ffa8bf7d3b161f9cdc59bfc3036e9b46e
https://github.com/jfrog/artifactory-client-java/blob/e7443f4ffa8bf7d3b161f9cdc59bfc3036e9b46e/services/src/main/groovy/org/jfrog/artifactory/client/impl/ArtifactoryImpl.java#L126-L188
163,433
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFDomTree.java
PDFDomTree.createDocument
protected void createDocument() throws ParserConfigurationException { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); DocumentType doctype = builder.getDOMImplementation().createDocumentType("html", "-//W3C//DTD XHTML 1.1//EN", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"); doc = builder.getDOMImplementation().createDocument("http://www.w3.org/1999/xhtml", "html", doctype); head = doc.createElement("head"); Element meta = doc.createElement("meta"); meta.setAttribute("http-equiv", "content-type"); meta.setAttribute("content", "text/html;charset=utf-8"); head.appendChild(meta); title = doc.createElement("title"); title.setTextContent("PDF Document"); head.appendChild(title); globalStyle = doc.createElement("style"); globalStyle.setAttribute("type", "text/css"); //globalStyle.setTextContent(createGlobalStyle()); head.appendChild(globalStyle); body = doc.createElement("body"); Element root = doc.getDocumentElement(); root.appendChild(head); root.appendChild(body); }
java
protected void createDocument() throws ParserConfigurationException { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); DocumentType doctype = builder.getDOMImplementation().createDocumentType("html", "-//W3C//DTD XHTML 1.1//EN", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"); doc = builder.getDOMImplementation().createDocument("http://www.w3.org/1999/xhtml", "html", doctype); head = doc.createElement("head"); Element meta = doc.createElement("meta"); meta.setAttribute("http-equiv", "content-type"); meta.setAttribute("content", "text/html;charset=utf-8"); head.appendChild(meta); title = doc.createElement("title"); title.setTextContent("PDF Document"); head.appendChild(title); globalStyle = doc.createElement("style"); globalStyle.setAttribute("type", "text/css"); //globalStyle.setTextContent(createGlobalStyle()); head.appendChild(globalStyle); body = doc.createElement("body"); Element root = doc.getDocumentElement(); root.appendChild(head); root.appendChild(body); }
[ "protected", "void", "createDocument", "(", ")", "throws", "ParserConfigurationException", "{", "DocumentBuilderFactory", "builderFactory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "DocumentBuilder", "builder", "=", "builderFactory", ".", "newDocumentBuilder", "(", ")", ";", "DocumentType", "doctype", "=", "builder", ".", "getDOMImplementation", "(", ")", ".", "createDocumentType", "(", "\"html\"", ",", "\"-//W3C//DTD XHTML 1.1//EN\"", ",", "\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"", ")", ";", "doc", "=", "builder", ".", "getDOMImplementation", "(", ")", ".", "createDocument", "(", "\"http://www.w3.org/1999/xhtml\"", ",", "\"html\"", ",", "doctype", ")", ";", "head", "=", "doc", ".", "createElement", "(", "\"head\"", ")", ";", "Element", "meta", "=", "doc", ".", "createElement", "(", "\"meta\"", ")", ";", "meta", ".", "setAttribute", "(", "\"http-equiv\"", ",", "\"content-type\"", ")", ";", "meta", ".", "setAttribute", "(", "\"content\"", ",", "\"text/html;charset=utf-8\"", ")", ";", "head", ".", "appendChild", "(", "meta", ")", ";", "title", "=", "doc", ".", "createElement", "(", "\"title\"", ")", ";", "title", ".", "setTextContent", "(", "\"PDF Document\"", ")", ";", "head", ".", "appendChild", "(", "title", ")", ";", "globalStyle", "=", "doc", ".", "createElement", "(", "\"style\"", ")", ";", "globalStyle", ".", "setAttribute", "(", "\"type\"", ",", "\"text/css\"", ")", ";", "//globalStyle.setTextContent(createGlobalStyle());", "head", ".", "appendChild", "(", "globalStyle", ")", ";", "body", "=", "doc", ".", "createElement", "(", "\"body\"", ")", ";", "Element", "root", "=", "doc", ".", "getDocumentElement", "(", ")", ";", "root", ".", "appendChild", "(", "head", ")", ";", "root", ".", "appendChild", "(", "body", ")", ";", "}" ]
Creates a new empty HTML document tree. @throws ParserConfigurationException
[ "Creates", "a", "new", "empty", "HTML", "document", "tree", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFDomTree.java#L121-L146
163,434
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFDomTree.java
PDFDomTree.writeText
@Override public void writeText(PDDocument doc, Writer outputStream) throws IOException { try { DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS"); LSSerializer writer = impl.createLSSerializer(); LSOutput output = impl.createLSOutput(); writer.getDomConfig().setParameter("format-pretty-print", true); output.setCharacterStream(outputStream); createDOM(doc); writer.write(getDocument(), output); } catch (ClassCastException e) { throw new IOException("Error: cannot initialize the DOM serializer", e); } catch (ClassNotFoundException e) { throw new IOException("Error: cannot initialize the DOM serializer", e); } catch (InstantiationException e) { throw new IOException("Error: cannot initialize the DOM serializer", e); } catch (IllegalAccessException e) { throw new IOException("Error: cannot initialize the DOM serializer", e); } }
java
@Override public void writeText(PDDocument doc, Writer outputStream) throws IOException { try { DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS"); LSSerializer writer = impl.createLSSerializer(); LSOutput output = impl.createLSOutput(); writer.getDomConfig().setParameter("format-pretty-print", true); output.setCharacterStream(outputStream); createDOM(doc); writer.write(getDocument(), output); } catch (ClassCastException e) { throw new IOException("Error: cannot initialize the DOM serializer", e); } catch (ClassNotFoundException e) { throw new IOException("Error: cannot initialize the DOM serializer", e); } catch (InstantiationException e) { throw new IOException("Error: cannot initialize the DOM serializer", e); } catch (IllegalAccessException e) { throw new IOException("Error: cannot initialize the DOM serializer", e); } }
[ "@", "Override", "public", "void", "writeText", "(", "PDDocument", "doc", ",", "Writer", "outputStream", ")", "throws", "IOException", "{", "try", "{", "DOMImplementationRegistry", "registry", "=", "DOMImplementationRegistry", ".", "newInstance", "(", ")", ";", "DOMImplementationLS", "impl", "=", "(", "DOMImplementationLS", ")", "registry", ".", "getDOMImplementation", "(", "\"LS\"", ")", ";", "LSSerializer", "writer", "=", "impl", ".", "createLSSerializer", "(", ")", ";", "LSOutput", "output", "=", "impl", ".", "createLSOutput", "(", ")", ";", "writer", ".", "getDomConfig", "(", ")", ".", "setParameter", "(", "\"format-pretty-print\"", ",", "true", ")", ";", "output", ".", "setCharacterStream", "(", "outputStream", ")", ";", "createDOM", "(", "doc", ")", ";", "writer", ".", "write", "(", "getDocument", "(", ")", ",", "output", ")", ";", "}", "catch", "(", "ClassCastException", "e", ")", "{", "throw", "new", "IOException", "(", "\"Error: cannot initialize the DOM serializer\"", ",", "e", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "IOException", "(", "\"Error: cannot initialize the DOM serializer\"", ",", "e", ")", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "throw", "new", "IOException", "(", "\"Error: cannot initialize the DOM serializer\"", ",", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "IOException", "(", "\"Error: cannot initialize the DOM serializer\"", ",", "e", ")", ";", "}", "}" ]
Parses a PDF document and serializes the resulting DOM tree to an output. This requires a DOM Level 3 capable implementation to be available.
[ "Parses", "a", "PDF", "document", "and", "serializes", "the", "resulting", "DOM", "tree", "to", "an", "output", ".", "This", "requires", "a", "DOM", "Level", "3", "capable", "implementation", "to", "be", "available", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFDomTree.java#L183-L205
163,435
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFDomTree.java
PDFDomTree.createDOM
public Document createDOM(PDDocument doc) throws IOException { /* We call the original PDFTextStripper.writeText but nothing should be printed actually because our processing methods produce no output. They create the DOM structures instead */ super.writeText(doc, new OutputStreamWriter(System.out)); return this.doc; }
java
public Document createDOM(PDDocument doc) throws IOException { /* We call the original PDFTextStripper.writeText but nothing should be printed actually because our processing methods produce no output. They create the DOM structures instead */ super.writeText(doc, new OutputStreamWriter(System.out)); return this.doc; }
[ "public", "Document", "createDOM", "(", "PDDocument", "doc", ")", "throws", "IOException", "{", "/* We call the original PDFTextStripper.writeText but nothing should\n be printed actually because our processing methods produce no output.\n They create the DOM structures instead */", "super", ".", "writeText", "(", "doc", ",", "new", "OutputStreamWriter", "(", "System", ".", "out", ")", ")", ";", "return", "this", ".", "doc", ";", "}" ]
Loads a PDF document and creates a DOM tree from it. @param doc the source document @return a DOM Document representing the DOM tree @throws IOException
[ "Loads", "a", "PDF", "document", "and", "creates", "a", "DOM", "tree", "from", "it", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFDomTree.java#L213-L220
163,436
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFDomTree.java
PDFDomTree.createPageElement
protected Element createPageElement() { String pstyle = ""; PDRectangle layout = getCurrentMediaBox(); if (layout != null) { /*System.out.println("x1 " + layout.getLowerLeftX()); System.out.println("y1 " + layout.getLowerLeftY()); System.out.println("x2 " + layout.getUpperRightX()); System.out.println("y2 " + layout.getUpperRightY()); System.out.println("rot " + pdpage.findRotation());*/ float w = layout.getWidth(); float h = layout.getHeight(); final int rot = pdpage.getRotation(); if (rot == 90 || rot == 270) { float x = w; w = h; h = x; } pstyle = "width:" + w + UNIT + ";" + "height:" + h + UNIT + ";"; pstyle += "overflow:hidden;"; } else log.warn("No media box found"); Element el = doc.createElement("div"); el.setAttribute("id", "page_" + (pagecnt++)); el.setAttribute("class", "page"); el.setAttribute("style", pstyle); return el; }
java
protected Element createPageElement() { String pstyle = ""; PDRectangle layout = getCurrentMediaBox(); if (layout != null) { /*System.out.println("x1 " + layout.getLowerLeftX()); System.out.println("y1 " + layout.getLowerLeftY()); System.out.println("x2 " + layout.getUpperRightX()); System.out.println("y2 " + layout.getUpperRightY()); System.out.println("rot " + pdpage.findRotation());*/ float w = layout.getWidth(); float h = layout.getHeight(); final int rot = pdpage.getRotation(); if (rot == 90 || rot == 270) { float x = w; w = h; h = x; } pstyle = "width:" + w + UNIT + ";" + "height:" + h + UNIT + ";"; pstyle += "overflow:hidden;"; } else log.warn("No media box found"); Element el = doc.createElement("div"); el.setAttribute("id", "page_" + (pagecnt++)); el.setAttribute("class", "page"); el.setAttribute("style", pstyle); return el; }
[ "protected", "Element", "createPageElement", "(", ")", "{", "String", "pstyle", "=", "\"\"", ";", "PDRectangle", "layout", "=", "getCurrentMediaBox", "(", ")", ";", "if", "(", "layout", "!=", "null", ")", "{", "/*System.out.println(\"x1 \" + layout.getLowerLeftX());\n System.out.println(\"y1 \" + layout.getLowerLeftY());\n System.out.println(\"x2 \" + layout.getUpperRightX());\n System.out.println(\"y2 \" + layout.getUpperRightY());\n System.out.println(\"rot \" + pdpage.findRotation());*/", "float", "w", "=", "layout", ".", "getWidth", "(", ")", ";", "float", "h", "=", "layout", ".", "getHeight", "(", ")", ";", "final", "int", "rot", "=", "pdpage", ".", "getRotation", "(", ")", ";", "if", "(", "rot", "==", "90", "||", "rot", "==", "270", ")", "{", "float", "x", "=", "w", ";", "w", "=", "h", ";", "h", "=", "x", ";", "}", "pstyle", "=", "\"width:\"", "+", "w", "+", "UNIT", "+", "\";\"", "+", "\"height:\"", "+", "h", "+", "UNIT", "+", "\";\"", ";", "pstyle", "+=", "\"overflow:hidden;\"", ";", "}", "else", "log", ".", "warn", "(", "\"No media box found\"", ")", ";", "Element", "el", "=", "doc", ".", "createElement", "(", "\"div\"", ")", ";", "el", ".", "setAttribute", "(", "\"id\"", ",", "\"page_\"", "+", "(", "pagecnt", "++", ")", ")", ";", "el", ".", "setAttribute", "(", "\"class\"", ",", "\"page\"", ")", ";", "el", ".", "setAttribute", "(", "\"style\"", ",", "pstyle", ")", ";", "return", "el", ";", "}" ]
Creates an element that represents a single page. @return the resulting DOM element
[ "Creates", "an", "element", "that", "represents", "a", "single", "page", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFDomTree.java#L267-L298
163,437
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFDomTree.java
PDFDomTree.createTextElement
protected Element createTextElement(float width) { Element el = doc.createElement("div"); el.setAttribute("id", "p" + (textcnt++)); el.setAttribute("class", "p"); String style = curstyle.toString(); style += "width:" + width + UNIT + ";"; el.setAttribute("style", style); return el; }
java
protected Element createTextElement(float width) { Element el = doc.createElement("div"); el.setAttribute("id", "p" + (textcnt++)); el.setAttribute("class", "p"); String style = curstyle.toString(); style += "width:" + width + UNIT + ";"; el.setAttribute("style", style); return el; }
[ "protected", "Element", "createTextElement", "(", "float", "width", ")", "{", "Element", "el", "=", "doc", ".", "createElement", "(", "\"div\"", ")", ";", "el", ".", "setAttribute", "(", "\"id\"", ",", "\"p\"", "+", "(", "textcnt", "++", ")", ")", ";", "el", ".", "setAttribute", "(", "\"class\"", ",", "\"p\"", ")", ";", "String", "style", "=", "curstyle", ".", "toString", "(", ")", ";", "style", "+=", "\"width:\"", "+", "width", "+", "UNIT", "+", "\";\"", ";", "el", ".", "setAttribute", "(", "\"style\"", ",", "style", ")", ";", "return", "el", ";", "}" ]
Creates an element that represents a single positioned box with no content. @return the resulting DOM element
[ "Creates", "an", "element", "that", "represents", "a", "single", "positioned", "box", "with", "no", "content", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFDomTree.java#L304-L313
163,438
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFDomTree.java
PDFDomTree.createTextElement
protected Element createTextElement(String data, float width) { Element el = createTextElement(width); Text text = doc.createTextNode(data); el.appendChild(text); return el; }
java
protected Element createTextElement(String data, float width) { Element el = createTextElement(width); Text text = doc.createTextNode(data); el.appendChild(text); return el; }
[ "protected", "Element", "createTextElement", "(", "String", "data", ",", "float", "width", ")", "{", "Element", "el", "=", "createTextElement", "(", "width", ")", ";", "Text", "text", "=", "doc", ".", "createTextNode", "(", "data", ")", ";", "el", ".", "appendChild", "(", "text", ")", ";", "return", "el", ";", "}" ]
Creates an element that represents a single positioned box containing the specified text string. @param data the text string to be contained in the created box. @return the resulting DOM element
[ "Creates", "an", "element", "that", "represents", "a", "single", "positioned", "box", "containing", "the", "specified", "text", "string", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFDomTree.java#L320-L326
163,439
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFDomTree.java
PDFDomTree.createRectangleElement
protected Element createRectangleElement(float x, float y, float width, float height, boolean stroke, boolean fill) { float lineWidth = transformWidth(getGraphicsState().getLineWidth()); float wcor = stroke ? lineWidth : 0.0f; float strokeOffset = wcor == 0 ? 0 : wcor / 2; width = width - wcor < 0 ? 1 : width - wcor; height = height - wcor < 0 ? 1 : height - wcor; StringBuilder pstyle = new StringBuilder(50); pstyle.append("left:").append(style.formatLength(x - strokeOffset)).append(';'); pstyle.append("top:").append(style.formatLength(y - strokeOffset)).append(';'); pstyle.append("width:").append(style.formatLength(width)).append(';'); pstyle.append("height:").append(style.formatLength(height)).append(';'); if (stroke) { String color = colorString(getGraphicsState().getStrokingColor()); pstyle.append("border:").append(style.formatLength(lineWidth)).append(" solid ").append(color).append(';'); } if (fill) { String fcolor = colorString(getGraphicsState().getNonStrokingColor()); pstyle.append("background-color:").append(fcolor).append(';'); } Element el = doc.createElement("div"); el.setAttribute("class", "r"); el.setAttribute("style", pstyle.toString()); el.appendChild(doc.createEntityReference("nbsp")); return el; }
java
protected Element createRectangleElement(float x, float y, float width, float height, boolean stroke, boolean fill) { float lineWidth = transformWidth(getGraphicsState().getLineWidth()); float wcor = stroke ? lineWidth : 0.0f; float strokeOffset = wcor == 0 ? 0 : wcor / 2; width = width - wcor < 0 ? 1 : width - wcor; height = height - wcor < 0 ? 1 : height - wcor; StringBuilder pstyle = new StringBuilder(50); pstyle.append("left:").append(style.formatLength(x - strokeOffset)).append(';'); pstyle.append("top:").append(style.formatLength(y - strokeOffset)).append(';'); pstyle.append("width:").append(style.formatLength(width)).append(';'); pstyle.append("height:").append(style.formatLength(height)).append(';'); if (stroke) { String color = colorString(getGraphicsState().getStrokingColor()); pstyle.append("border:").append(style.formatLength(lineWidth)).append(" solid ").append(color).append(';'); } if (fill) { String fcolor = colorString(getGraphicsState().getNonStrokingColor()); pstyle.append("background-color:").append(fcolor).append(';'); } Element el = doc.createElement("div"); el.setAttribute("class", "r"); el.setAttribute("style", pstyle.toString()); el.appendChild(doc.createEntityReference("nbsp")); return el; }
[ "protected", "Element", "createRectangleElement", "(", "float", "x", ",", "float", "y", ",", "float", "width", ",", "float", "height", ",", "boolean", "stroke", ",", "boolean", "fill", ")", "{", "float", "lineWidth", "=", "transformWidth", "(", "getGraphicsState", "(", ")", ".", "getLineWidth", "(", ")", ")", ";", "float", "wcor", "=", "stroke", "?", "lineWidth", ":", "0.0f", ";", "float", "strokeOffset", "=", "wcor", "==", "0", "?", "0", ":", "wcor", "/", "2", ";", "width", "=", "width", "-", "wcor", "<", "0", "?", "1", ":", "width", "-", "wcor", ";", "height", "=", "height", "-", "wcor", "<", "0", "?", "1", ":", "height", "-", "wcor", ";", "StringBuilder", "pstyle", "=", "new", "StringBuilder", "(", "50", ")", ";", "pstyle", ".", "append", "(", "\"left:\"", ")", ".", "append", "(", "style", ".", "formatLength", "(", "x", "-", "strokeOffset", ")", ")", ".", "append", "(", "'", "'", ")", ";", "pstyle", ".", "append", "(", "\"top:\"", ")", ".", "append", "(", "style", ".", "formatLength", "(", "y", "-", "strokeOffset", ")", ")", ".", "append", "(", "'", "'", ")", ";", "pstyle", ".", "append", "(", "\"width:\"", ")", ".", "append", "(", "style", ".", "formatLength", "(", "width", ")", ")", ".", "append", "(", "'", "'", ")", ";", "pstyle", ".", "append", "(", "\"height:\"", ")", ".", "append", "(", "style", ".", "formatLength", "(", "height", ")", ")", ".", "append", "(", "'", "'", ")", ";", "if", "(", "stroke", ")", "{", "String", "color", "=", "colorString", "(", "getGraphicsState", "(", ")", ".", "getStrokingColor", "(", ")", ")", ";", "pstyle", ".", "append", "(", "\"border:\"", ")", ".", "append", "(", "style", ".", "formatLength", "(", "lineWidth", ")", ")", ".", "append", "(", "\" solid \"", ")", ".", "append", "(", "color", ")", ".", "append", "(", "'", "'", ")", ";", "}", "if", "(", "fill", ")", "{", "String", "fcolor", "=", "colorString", "(", "getGraphicsState", "(", ")", ".", "getNonStrokingColor", "(", ")", ")", ";", "pstyle", ".", "append", "(", "\"background-color:\"", ")", ".", "append", "(", "fcolor", ")", ".", "append", "(", "'", "'", ")", ";", "}", "Element", "el", "=", "doc", ".", "createElement", "(", "\"div\"", ")", ";", "el", ".", "setAttribute", "(", "\"class\"", ",", "\"r\"", ")", ";", "el", ".", "setAttribute", "(", "\"style\"", ",", "pstyle", ".", "toString", "(", ")", ")", ";", "el", ".", "appendChild", "(", "doc", ".", "createEntityReference", "(", "\"nbsp\"", ")", ")", ";", "return", "el", ";", "}" ]
Creates an element that represents a rectangle drawn at the specified coordinates in the page. @param x the X coordinate of the rectangle @param y the Y coordinate of the rectangle @param width the width of the rectangle @param height the height of the rectangle @param stroke should there be a stroke around? @param fill should the rectangle be filled? @return the resulting DOM element
[ "Creates", "an", "element", "that", "represents", "a", "rectangle", "drawn", "at", "the", "specified", "coordinates", "in", "the", "page", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFDomTree.java#L338-L369
163,440
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFDomTree.java
PDFDomTree.createLineElement
protected Element createLineElement(float x1, float y1, float x2, float y2) { HtmlDivLine line = new HtmlDivLine(x1, y1, x2, y2); String color = colorString(getGraphicsState().getStrokingColor()); StringBuilder pstyle = new StringBuilder(50); pstyle.append("left:").append(style.formatLength(line.getLeft())).append(';'); pstyle.append("top:").append(style.formatLength(line.getTop())).append(';'); pstyle.append("width:").append(style.formatLength(line.getWidth())).append(';'); pstyle.append("height:").append(style.formatLength(line.getHeight())).append(';'); pstyle.append(line.getBorderSide()).append(':').append(style.formatLength(line.getLineStrokeWidth())).append(" solid ").append(color).append(';'); if (line.getAngleDegrees() != 0) pstyle.append("transform:").append("rotate(").append(line.getAngleDegrees()).append("deg);"); Element el = doc.createElement("div"); el.setAttribute("class", "r"); el.setAttribute("style", pstyle.toString()); el.appendChild(doc.createEntityReference("nbsp")); return el; }
java
protected Element createLineElement(float x1, float y1, float x2, float y2) { HtmlDivLine line = new HtmlDivLine(x1, y1, x2, y2); String color = colorString(getGraphicsState().getStrokingColor()); StringBuilder pstyle = new StringBuilder(50); pstyle.append("left:").append(style.formatLength(line.getLeft())).append(';'); pstyle.append("top:").append(style.formatLength(line.getTop())).append(';'); pstyle.append("width:").append(style.formatLength(line.getWidth())).append(';'); pstyle.append("height:").append(style.formatLength(line.getHeight())).append(';'); pstyle.append(line.getBorderSide()).append(':').append(style.formatLength(line.getLineStrokeWidth())).append(" solid ").append(color).append(';'); if (line.getAngleDegrees() != 0) pstyle.append("transform:").append("rotate(").append(line.getAngleDegrees()).append("deg);"); Element el = doc.createElement("div"); el.setAttribute("class", "r"); el.setAttribute("style", pstyle.toString()); el.appendChild(doc.createEntityReference("nbsp")); return el; }
[ "protected", "Element", "createLineElement", "(", "float", "x1", ",", "float", "y1", ",", "float", "x2", ",", "float", "y2", ")", "{", "HtmlDivLine", "line", "=", "new", "HtmlDivLine", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ")", ";", "String", "color", "=", "colorString", "(", "getGraphicsState", "(", ")", ".", "getStrokingColor", "(", ")", ")", ";", "StringBuilder", "pstyle", "=", "new", "StringBuilder", "(", "50", ")", ";", "pstyle", ".", "append", "(", "\"left:\"", ")", ".", "append", "(", "style", ".", "formatLength", "(", "line", ".", "getLeft", "(", ")", ")", ")", ".", "append", "(", "'", "'", ")", ";", "pstyle", ".", "append", "(", "\"top:\"", ")", ".", "append", "(", "style", ".", "formatLength", "(", "line", ".", "getTop", "(", ")", ")", ")", ".", "append", "(", "'", "'", ")", ";", "pstyle", ".", "append", "(", "\"width:\"", ")", ".", "append", "(", "style", ".", "formatLength", "(", "line", ".", "getWidth", "(", ")", ")", ")", ".", "append", "(", "'", "'", ")", ";", "pstyle", ".", "append", "(", "\"height:\"", ")", ".", "append", "(", "style", ".", "formatLength", "(", "line", ".", "getHeight", "(", ")", ")", ")", ".", "append", "(", "'", "'", ")", ";", "pstyle", ".", "append", "(", "line", ".", "getBorderSide", "(", ")", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "style", ".", "formatLength", "(", "line", ".", "getLineStrokeWidth", "(", ")", ")", ")", ".", "append", "(", "\" solid \"", ")", ".", "append", "(", "color", ")", ".", "append", "(", "'", "'", ")", ";", "if", "(", "line", ".", "getAngleDegrees", "(", ")", "!=", "0", ")", "pstyle", ".", "append", "(", "\"transform:\"", ")", ".", "append", "(", "\"rotate(\"", ")", ".", "append", "(", "line", ".", "getAngleDegrees", "(", ")", ")", ".", "append", "(", "\"deg);\"", ")", ";", "Element", "el", "=", "doc", ".", "createElement", "(", "\"div\"", ")", ";", "el", ".", "setAttribute", "(", "\"class\"", ",", "\"r\"", ")", ";", "el", ".", "setAttribute", "(", "\"style\"", ",", "pstyle", ".", "toString", "(", ")", ")", ";", "el", ".", "appendChild", "(", "doc", ".", "createEntityReference", "(", "\"nbsp\"", ")", ")", ";", "return", "el", ";", "}" ]
Create an element that represents a horizntal or vertical line. @param x1 @param y1 @param x2 @param y2 @return the created DOM element
[ "Create", "an", "element", "that", "represents", "a", "horizntal", "or", "vertical", "line", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFDomTree.java#L379-L398
163,441
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFDomTree.java
PDFDomTree.createImageElement
protected Element createImageElement(float x, float y, float width, float height, ImageResource resource) throws IOException { StringBuilder pstyle = new StringBuilder("position:absolute;"); pstyle.append("left:").append(x).append(UNIT).append(';'); pstyle.append("top:").append(y).append(UNIT).append(';'); pstyle.append("width:").append(width).append(UNIT).append(';'); pstyle.append("height:").append(height).append(UNIT).append(';'); //pstyle.append("border:1px solid red;"); Element el = doc.createElement("img"); el.setAttribute("style", pstyle.toString()); String imgSrc = config.getImageHandler().handleResource(resource); if (!disableImageData && !imgSrc.isEmpty()) el.setAttribute("src", imgSrc); else el.setAttribute("src", ""); return el; }
java
protected Element createImageElement(float x, float y, float width, float height, ImageResource resource) throws IOException { StringBuilder pstyle = new StringBuilder("position:absolute;"); pstyle.append("left:").append(x).append(UNIT).append(';'); pstyle.append("top:").append(y).append(UNIT).append(';'); pstyle.append("width:").append(width).append(UNIT).append(';'); pstyle.append("height:").append(height).append(UNIT).append(';'); //pstyle.append("border:1px solid red;"); Element el = doc.createElement("img"); el.setAttribute("style", pstyle.toString()); String imgSrc = config.getImageHandler().handleResource(resource); if (!disableImageData && !imgSrc.isEmpty()) el.setAttribute("src", imgSrc); else el.setAttribute("src", ""); return el; }
[ "protected", "Element", "createImageElement", "(", "float", "x", ",", "float", "y", ",", "float", "width", ",", "float", "height", ",", "ImageResource", "resource", ")", "throws", "IOException", "{", "StringBuilder", "pstyle", "=", "new", "StringBuilder", "(", "\"position:absolute;\"", ")", ";", "pstyle", ".", "append", "(", "\"left:\"", ")", ".", "append", "(", "x", ")", ".", "append", "(", "UNIT", ")", ".", "append", "(", "'", "'", ")", ";", "pstyle", ".", "append", "(", "\"top:\"", ")", ".", "append", "(", "y", ")", ".", "append", "(", "UNIT", ")", ".", "append", "(", "'", "'", ")", ";", "pstyle", ".", "append", "(", "\"width:\"", ")", ".", "append", "(", "width", ")", ".", "append", "(", "UNIT", ")", ".", "append", "(", "'", "'", ")", ";", "pstyle", ".", "append", "(", "\"height:\"", ")", ".", "append", "(", "height", ")", ".", "append", "(", "UNIT", ")", ".", "append", "(", "'", "'", ")", ";", "//pstyle.append(\"border:1px solid red;\");", "Element", "el", "=", "doc", ".", "createElement", "(", "\"img\"", ")", ";", "el", ".", "setAttribute", "(", "\"style\"", ",", "pstyle", ".", "toString", "(", ")", ")", ";", "String", "imgSrc", "=", "config", ".", "getImageHandler", "(", ")", ".", "handleResource", "(", "resource", ")", ";", "if", "(", "!", "disableImageData", "&&", "!", "imgSrc", ".", "isEmpty", "(", ")", ")", "el", ".", "setAttribute", "(", "\"src\"", ",", "imgSrc", ")", ";", "else", "el", ".", "setAttribute", "(", "\"src\"", ",", "\"\"", ")", ";", "return", "el", ";", "}" ]
Creates an element that represents an image drawn at the specified coordinates in the page. @param x the X coordinate of the image @param y the Y coordinate of the image @param width the width coordinate of the image @param height the height coordinate of the image @param type the image type: <code>"png"</code> or <code>"jpeg"</code> @param resource the image data depending on the specified type @return
[ "Creates", "an", "element", "that", "represents", "an", "image", "drawn", "at", "the", "specified", "coordinates", "in", "the", "page", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFDomTree.java#L419-L439
163,442
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFDomTree.java
PDFDomTree.createGlobalStyle
protected String createGlobalStyle() { StringBuilder ret = new StringBuilder(); ret.append(createFontFaces()); ret.append("\n"); ret.append(defaultStyle); return ret.toString(); }
java
protected String createGlobalStyle() { StringBuilder ret = new StringBuilder(); ret.append(createFontFaces()); ret.append("\n"); ret.append(defaultStyle); return ret.toString(); }
[ "protected", "String", "createGlobalStyle", "(", ")", "{", "StringBuilder", "ret", "=", "new", "StringBuilder", "(", ")", ";", "ret", ".", "append", "(", "createFontFaces", "(", ")", ")", ";", "ret", ".", "append", "(", "\"\\n\"", ")", ";", "ret", ".", "append", "(", "defaultStyle", ")", ";", "return", "ret", ".", "toString", "(", ")", ";", "}" ]
Generate the global CSS style for the whole document. @return the CSS code used in the generated document header
[ "Generate", "the", "global", "CSS", "style", "for", "the", "whole", "document", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFDomTree.java#L530-L537
163,443
radkovo/Pdf2Dom
src/main/java/org/fit/cssbox/pdf/PdfBrowserCanvas.java
PdfBrowserCanvas.createPdfLayout
public void createPdfLayout(Dimension dim) { if (pdfdocument != null) //processing a PDF document { try { if (createImage) img = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_RGB); Graphics2D ig = img.createGraphics(); log.info("Creating PDF boxes"); VisualContext ctx = new VisualContext(null, null); boxtree = new CSSBoxTree(ig, ctx, dim, baseurl); boxtree.setConfig(config); boxtree.processDocument(pdfdocument, startPage, endPage); viewport = boxtree.getViewport(); root = boxtree.getDocument().getDocumentElement(); log.info("We have " + boxtree.getLastId() + " boxes"); viewport.initSubtree(); log.info("Layout for "+dim.width+"px"); viewport.doLayout(dim.width, true, true); log.info("Resulting size: " + viewport.getWidth() + "x" + viewport.getHeight() + " (" + viewport + ")"); log.info("Updating viewport size"); viewport.updateBounds(dim); log.info("Resulting size: " + viewport.getWidth() + "x" + viewport.getHeight() + " (" + viewport + ")"); if (createImage && (viewport.getWidth() > dim.width || viewport.getHeight() > dim.height)) { img = new BufferedImage(Math.max(viewport.getWidth(), dim.width), Math.max(viewport.getHeight(), dim.height), BufferedImage.TYPE_INT_RGB); ig = img.createGraphics(); } log.info("Positioning for "+img.getWidth()+"x"+img.getHeight()+"px"); viewport.absolutePositions(); clearCanvas(); viewport.draw(new GraphicsRenderer(ig)); setPreferredSize(new Dimension(img.getWidth(), img.getHeight())); revalidate(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else if (root != null) //processing a DOM tree { super.createLayout(dim); } }
java
public void createPdfLayout(Dimension dim) { if (pdfdocument != null) //processing a PDF document { try { if (createImage) img = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_RGB); Graphics2D ig = img.createGraphics(); log.info("Creating PDF boxes"); VisualContext ctx = new VisualContext(null, null); boxtree = new CSSBoxTree(ig, ctx, dim, baseurl); boxtree.setConfig(config); boxtree.processDocument(pdfdocument, startPage, endPage); viewport = boxtree.getViewport(); root = boxtree.getDocument().getDocumentElement(); log.info("We have " + boxtree.getLastId() + " boxes"); viewport.initSubtree(); log.info("Layout for "+dim.width+"px"); viewport.doLayout(dim.width, true, true); log.info("Resulting size: " + viewport.getWidth() + "x" + viewport.getHeight() + " (" + viewport + ")"); log.info("Updating viewport size"); viewport.updateBounds(dim); log.info("Resulting size: " + viewport.getWidth() + "x" + viewport.getHeight() + " (" + viewport + ")"); if (createImage && (viewport.getWidth() > dim.width || viewport.getHeight() > dim.height)) { img = new BufferedImage(Math.max(viewport.getWidth(), dim.width), Math.max(viewport.getHeight(), dim.height), BufferedImage.TYPE_INT_RGB); ig = img.createGraphics(); } log.info("Positioning for "+img.getWidth()+"x"+img.getHeight()+"px"); viewport.absolutePositions(); clearCanvas(); viewport.draw(new GraphicsRenderer(ig)); setPreferredSize(new Dimension(img.getWidth(), img.getHeight())); revalidate(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else if (root != null) //processing a DOM tree { super.createLayout(dim); } }
[ "public", "void", "createPdfLayout", "(", "Dimension", "dim", ")", "{", "if", "(", "pdfdocument", "!=", "null", ")", "//processing a PDF document", "{", "try", "{", "if", "(", "createImage", ")", "img", "=", "new", "BufferedImage", "(", "dim", ".", "width", ",", "dim", ".", "height", ",", "BufferedImage", ".", "TYPE_INT_RGB", ")", ";", "Graphics2D", "ig", "=", "img", ".", "createGraphics", "(", ")", ";", "log", ".", "info", "(", "\"Creating PDF boxes\"", ")", ";", "VisualContext", "ctx", "=", "new", "VisualContext", "(", "null", ",", "null", ")", ";", "boxtree", "=", "new", "CSSBoxTree", "(", "ig", ",", "ctx", ",", "dim", ",", "baseurl", ")", ";", "boxtree", ".", "setConfig", "(", "config", ")", ";", "boxtree", ".", "processDocument", "(", "pdfdocument", ",", "startPage", ",", "endPage", ")", ";", "viewport", "=", "boxtree", ".", "getViewport", "(", ")", ";", "root", "=", "boxtree", ".", "getDocument", "(", ")", ".", "getDocumentElement", "(", ")", ";", "log", ".", "info", "(", "\"We have \"", "+", "boxtree", ".", "getLastId", "(", ")", "+", "\" boxes\"", ")", ";", "viewport", ".", "initSubtree", "(", ")", ";", "log", ".", "info", "(", "\"Layout for \"", "+", "dim", ".", "width", "+", "\"px\"", ")", ";", "viewport", ".", "doLayout", "(", "dim", ".", "width", ",", "true", ",", "true", ")", ";", "log", ".", "info", "(", "\"Resulting size: \"", "+", "viewport", ".", "getWidth", "(", ")", "+", "\"x\"", "+", "viewport", ".", "getHeight", "(", ")", "+", "\" (\"", "+", "viewport", "+", "\")\"", ")", ";", "log", ".", "info", "(", "\"Updating viewport size\"", ")", ";", "viewport", ".", "updateBounds", "(", "dim", ")", ";", "log", ".", "info", "(", "\"Resulting size: \"", "+", "viewport", ".", "getWidth", "(", ")", "+", "\"x\"", "+", "viewport", ".", "getHeight", "(", ")", "+", "\" (\"", "+", "viewport", "+", "\")\"", ")", ";", "if", "(", "createImage", "&&", "(", "viewport", ".", "getWidth", "(", ")", ">", "dim", ".", "width", "||", "viewport", ".", "getHeight", "(", ")", ">", "dim", ".", "height", ")", ")", "{", "img", "=", "new", "BufferedImage", "(", "Math", ".", "max", "(", "viewport", ".", "getWidth", "(", ")", ",", "dim", ".", "width", ")", ",", "Math", ".", "max", "(", "viewport", ".", "getHeight", "(", ")", ",", "dim", ".", "height", ")", ",", "BufferedImage", ".", "TYPE_INT_RGB", ")", ";", "ig", "=", "img", ".", "createGraphics", "(", ")", ";", "}", "log", ".", "info", "(", "\"Positioning for \"", "+", "img", ".", "getWidth", "(", ")", "+", "\"x\"", "+", "img", ".", "getHeight", "(", ")", "+", "\"px\"", ")", ";", "viewport", ".", "absolutePositions", "(", ")", ";", "clearCanvas", "(", ")", ";", "viewport", ".", "draw", "(", "new", "GraphicsRenderer", "(", "ig", ")", ")", ";", "setPreferredSize", "(", "new", "Dimension", "(", "img", ".", "getWidth", "(", ")", ",", "img", ".", "getHeight", "(", ")", ")", ")", ";", "revalidate", "(", ")", ";", "}", "catch", "(", "ParserConfigurationException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "else", "if", "(", "root", "!=", "null", ")", "//processing a DOM tree", "{", "super", ".", "createLayout", "(", "dim", ")", ";", "}", "}" ]
Creates the box tree for the PDF file. @param dim
[ "Creates", "the", "box", "tree", "for", "the", "PDF", "file", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/cssbox/pdf/PdfBrowserCanvas.java#L154-L207
163,444
radkovo/Pdf2Dom
src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java
CSSBoxTree.createBlock
protected BlockBox createBlock(BlockBox parent, Element n, boolean replaced) { BlockBox root; if (replaced) { BlockReplacedBox rbox = new BlockReplacedBox((Element) n, (Graphics2D) parent.getGraphics().create(), parent.getVisualContext().create()); rbox.setViewport(viewport); rbox.setContentObj(new ReplacedImage(rbox, rbox.getVisualContext(), baseurl, n.getAttribute("src"))); root = rbox; } else { root = new BlockBox((Element) n, (Graphics2D) parent.getGraphics().create(), parent.getVisualContext().create()); root.setViewport(viewport); } root.setBase(baseurl); root.setParent(parent); root.setContainingBlockBox(parent); root.setClipBlock(viewport); root.setOrder(next_order++); return root; }
java
protected BlockBox createBlock(BlockBox parent, Element n, boolean replaced) { BlockBox root; if (replaced) { BlockReplacedBox rbox = new BlockReplacedBox((Element) n, (Graphics2D) parent.getGraphics().create(), parent.getVisualContext().create()); rbox.setViewport(viewport); rbox.setContentObj(new ReplacedImage(rbox, rbox.getVisualContext(), baseurl, n.getAttribute("src"))); root = rbox; } else { root = new BlockBox((Element) n, (Graphics2D) parent.getGraphics().create(), parent.getVisualContext().create()); root.setViewport(viewport); } root.setBase(baseurl); root.setParent(parent); root.setContainingBlockBox(parent); root.setClipBlock(viewport); root.setOrder(next_order++); return root; }
[ "protected", "BlockBox", "createBlock", "(", "BlockBox", "parent", ",", "Element", "n", ",", "boolean", "replaced", ")", "{", "BlockBox", "root", ";", "if", "(", "replaced", ")", "{", "BlockReplacedBox", "rbox", "=", "new", "BlockReplacedBox", "(", "(", "Element", ")", "n", ",", "(", "Graphics2D", ")", "parent", ".", "getGraphics", "(", ")", ".", "create", "(", ")", ",", "parent", ".", "getVisualContext", "(", ")", ".", "create", "(", ")", ")", ";", "rbox", ".", "setViewport", "(", "viewport", ")", ";", "rbox", ".", "setContentObj", "(", "new", "ReplacedImage", "(", "rbox", ",", "rbox", ".", "getVisualContext", "(", ")", ",", "baseurl", ",", "n", ".", "getAttribute", "(", "\"src\"", ")", ")", ")", ";", "root", "=", "rbox", ";", "}", "else", "{", "root", "=", "new", "BlockBox", "(", "(", "Element", ")", "n", ",", "(", "Graphics2D", ")", "parent", ".", "getGraphics", "(", ")", ".", "create", "(", ")", ",", "parent", ".", "getVisualContext", "(", ")", ".", "create", "(", ")", ")", ";", "root", ".", "setViewport", "(", "viewport", ")", ";", "}", "root", ".", "setBase", "(", "baseurl", ")", ";", "root", ".", "setParent", "(", "parent", ")", ";", "root", ".", "setContainingBlockBox", "(", "parent", ")", ";", "root", ".", "setClipBlock", "(", "viewport", ")", ";", "root", ".", "setOrder", "(", "next_order", "++", ")", ";", "return", "root", ";", "}" ]
Creates a new block box from the given element with the given parent. No style is assigned to the resulting box. @param parent The parent box in the tree of boxes. @param n The element that this box belongs to. @param replaced When set to <code>true</code>, a replaced block box will be created. Otherwise, a normal non-replaced block will be created. @return The new block box.
[ "Creates", "a", "new", "block", "box", "from", "the", "given", "element", "with", "the", "given", "parent", ".", "No", "style", "is", "assigned", "to", "the", "resulting", "box", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java#L286-L307
163,445
radkovo/Pdf2Dom
src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java
CSSBoxTree.createTextBox
protected TextBox createTextBox(BlockBox contblock, Text n) { TextBox text = new TextBox(n, (Graphics2D) contblock.getGraphics().create(), contblock.getVisualContext().create()); text.setOrder(next_order++); text.setContainingBlockBox(contblock); text.setClipBlock(contblock); text.setViewport(viewport); text.setBase(baseurl); return text; }
java
protected TextBox createTextBox(BlockBox contblock, Text n) { TextBox text = new TextBox(n, (Graphics2D) contblock.getGraphics().create(), contblock.getVisualContext().create()); text.setOrder(next_order++); text.setContainingBlockBox(contblock); text.setClipBlock(contblock); text.setViewport(viewport); text.setBase(baseurl); return text; }
[ "protected", "TextBox", "createTextBox", "(", "BlockBox", "contblock", ",", "Text", "n", ")", "{", "TextBox", "text", "=", "new", "TextBox", "(", "n", ",", "(", "Graphics2D", ")", "contblock", ".", "getGraphics", "(", ")", ".", "create", "(", ")", ",", "contblock", ".", "getVisualContext", "(", ")", ".", "create", "(", ")", ")", ";", "text", ".", "setOrder", "(", "next_order", "++", ")", ";", "text", ".", "setContainingBlockBox", "(", "contblock", ")", ";", "text", ".", "setClipBlock", "(", "contblock", ")", ";", "text", ".", "setViewport", "(", "viewport", ")", ";", "text", ".", "setBase", "(", "baseurl", ")", ";", "return", "text", ";", "}" ]
Creates a text box with the given parent and text node assigned. @param contblock The parent node (and the containing block in the same time) @param n The corresponding text node in the DOM tree. @return The new text box.
[ "Creates", "a", "text", "box", "with", "the", "given", "parent", "and", "text", "node", "assigned", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java#L315-L324
163,446
radkovo/Pdf2Dom
src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java
CSSBoxTree.createBlockStyle
protected NodeData createBlockStyle() { NodeData ret = CSSFactory.createNodeData(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("display", tf.createIdent("block"))); return ret; }
java
protected NodeData createBlockStyle() { NodeData ret = CSSFactory.createNodeData(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("display", tf.createIdent("block"))); return ret; }
[ "protected", "NodeData", "createBlockStyle", "(", ")", "{", "NodeData", "ret", "=", "CSSFactory", ".", "createNodeData", "(", ")", ";", "TermFactory", "tf", "=", "CSSFactory", ".", "getTermFactory", "(", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"display\"", ",", "tf", ".", "createIdent", "(", "\"block\"", ")", ")", ")", ";", "return", "ret", ";", "}" ]
Creates an empty block style definition. @return
[ "Creates", "an", "empty", "block", "style", "definition", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java#L400-L406
163,447
radkovo/Pdf2Dom
src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java
CSSBoxTree.createBodyStyle
protected NodeData createBodyStyle() { NodeData ret = createBlockStyle(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("background-color", tf.createColor(255, 255, 255))); return ret; }
java
protected NodeData createBodyStyle() { NodeData ret = createBlockStyle(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("background-color", tf.createColor(255, 255, 255))); return ret; }
[ "protected", "NodeData", "createBodyStyle", "(", ")", "{", "NodeData", "ret", "=", "createBlockStyle", "(", ")", ";", "TermFactory", "tf", "=", "CSSFactory", ".", "getTermFactory", "(", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"background-color\"", ",", "tf", ".", "createColor", "(", "255", ",", "255", ",", "255", ")", ")", ")", ";", "return", "ret", ";", "}" ]
Creates a style definition used for the body element. @return The body style definition.
[ "Creates", "a", "style", "definition", "used", "for", "the", "body", "element", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java#L412-L418
163,448
radkovo/Pdf2Dom
src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java
CSSBoxTree.createPageStyle
protected NodeData createPageStyle() { NodeData ret = createBlockStyle(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("position", tf.createIdent("relative"))); ret.push(createDeclaration("border-width", tf.createLength(1f, Unit.px))); ret.push(createDeclaration("border-style", tf.createIdent("solid"))); ret.push(createDeclaration("border-color", tf.createColor(0, 0, 255))); ret.push(createDeclaration("margin", tf.createLength(0.5f, Unit.em))); PDRectangle layout = getCurrentMediaBox(); if (layout != null) { float w = layout.getWidth(); float h = layout.getHeight(); final int rot = pdpage.getRotation(); if (rot == 90 || rot == 270) { float x = w; w = h; h = x; } ret.push(createDeclaration("width", tf.createLength(w, unit))); ret.push(createDeclaration("height", tf.createLength(h, unit))); } else log.warn("No media box found"); return ret; }
java
protected NodeData createPageStyle() { NodeData ret = createBlockStyle(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("position", tf.createIdent("relative"))); ret.push(createDeclaration("border-width", tf.createLength(1f, Unit.px))); ret.push(createDeclaration("border-style", tf.createIdent("solid"))); ret.push(createDeclaration("border-color", tf.createColor(0, 0, 255))); ret.push(createDeclaration("margin", tf.createLength(0.5f, Unit.em))); PDRectangle layout = getCurrentMediaBox(); if (layout != null) { float w = layout.getWidth(); float h = layout.getHeight(); final int rot = pdpage.getRotation(); if (rot == 90 || rot == 270) { float x = w; w = h; h = x; } ret.push(createDeclaration("width", tf.createLength(w, unit))); ret.push(createDeclaration("height", tf.createLength(h, unit))); } else log.warn("No media box found"); return ret; }
[ "protected", "NodeData", "createPageStyle", "(", ")", "{", "NodeData", "ret", "=", "createBlockStyle", "(", ")", ";", "TermFactory", "tf", "=", "CSSFactory", ".", "getTermFactory", "(", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"position\"", ",", "tf", ".", "createIdent", "(", "\"relative\"", ")", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"border-width\"", ",", "tf", ".", "createLength", "(", "1f", ",", "Unit", ".", "px", ")", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"border-style\"", ",", "tf", ".", "createIdent", "(", "\"solid\"", ")", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"border-color\"", ",", "tf", ".", "createColor", "(", "0", ",", "0", ",", "255", ")", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"margin\"", ",", "tf", ".", "createLength", "(", "0.5f", ",", "Unit", ".", "em", ")", ")", ")", ";", "PDRectangle", "layout", "=", "getCurrentMediaBox", "(", ")", ";", "if", "(", "layout", "!=", "null", ")", "{", "float", "w", "=", "layout", ".", "getWidth", "(", ")", ";", "float", "h", "=", "layout", ".", "getHeight", "(", ")", ";", "final", "int", "rot", "=", "pdpage", ".", "getRotation", "(", ")", ";", "if", "(", "rot", "==", "90", "||", "rot", "==", "270", ")", "{", "float", "x", "=", "w", ";", "w", "=", "h", ";", "h", "=", "x", ";", "}", "ret", ".", "push", "(", "createDeclaration", "(", "\"width\"", ",", "tf", ".", "createLength", "(", "w", ",", "unit", ")", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"height\"", ",", "tf", ".", "createLength", "(", "h", ",", "unit", ")", ")", ")", ";", "}", "else", "log", ".", "warn", "(", "\"No media box found\"", ")", ";", "return", "ret", ";", "}" ]
Creates a style definition used for pages. @return The page style definition.
[ "Creates", "a", "style", "definition", "used", "for", "pages", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java#L424-L452
163,449
radkovo/Pdf2Dom
src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java
CSSBoxTree.createRectangleStyle
protected NodeData createRectangleStyle(float x, float y, float width, float height, boolean stroke, boolean fill) { float lineWidth = transformLength((float) getGraphicsState().getLineWidth()); float lw = (lineWidth < 1f) ? 1f : lineWidth; float wcor = stroke ? lw : 0.0f; NodeData ret = CSSFactory.createNodeData(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("position", tf.createIdent("absolute"))); ret.push(createDeclaration("left", tf.createLength(x, unit))); ret.push(createDeclaration("top", tf.createLength(y, unit))); ret.push(createDeclaration("width", tf.createLength(width - wcor, unit))); ret.push(createDeclaration("height", tf.createLength(height - wcor, unit))); if (stroke) { ret.push(createDeclaration("border-width", tf.createLength(lw, unit))); ret.push(createDeclaration("border-style", tf.createIdent("solid"))); String color = colorString(getGraphicsState().getStrokingColor()); ret.push(createDeclaration("border-color", tf.createColor(color))); } if (fill) { String color = colorString(getGraphicsState().getNonStrokingColor()); if (color != null) ret.push(createDeclaration("background-color", tf.createColor(color))); } return ret; }
java
protected NodeData createRectangleStyle(float x, float y, float width, float height, boolean stroke, boolean fill) { float lineWidth = transformLength((float) getGraphicsState().getLineWidth()); float lw = (lineWidth < 1f) ? 1f : lineWidth; float wcor = stroke ? lw : 0.0f; NodeData ret = CSSFactory.createNodeData(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("position", tf.createIdent("absolute"))); ret.push(createDeclaration("left", tf.createLength(x, unit))); ret.push(createDeclaration("top", tf.createLength(y, unit))); ret.push(createDeclaration("width", tf.createLength(width - wcor, unit))); ret.push(createDeclaration("height", tf.createLength(height - wcor, unit))); if (stroke) { ret.push(createDeclaration("border-width", tf.createLength(lw, unit))); ret.push(createDeclaration("border-style", tf.createIdent("solid"))); String color = colorString(getGraphicsState().getStrokingColor()); ret.push(createDeclaration("border-color", tf.createColor(color))); } if (fill) { String color = colorString(getGraphicsState().getNonStrokingColor()); if (color != null) ret.push(createDeclaration("background-color", tf.createColor(color))); } return ret; }
[ "protected", "NodeData", "createRectangleStyle", "(", "float", "x", ",", "float", "y", ",", "float", "width", ",", "float", "height", ",", "boolean", "stroke", ",", "boolean", "fill", ")", "{", "float", "lineWidth", "=", "transformLength", "(", "(", "float", ")", "getGraphicsState", "(", ")", ".", "getLineWidth", "(", ")", ")", ";", "float", "lw", "=", "(", "lineWidth", "<", "1f", ")", "?", "1f", ":", "lineWidth", ";", "float", "wcor", "=", "stroke", "?", "lw", ":", "0.0f", ";", "NodeData", "ret", "=", "CSSFactory", ".", "createNodeData", "(", ")", ";", "TermFactory", "tf", "=", "CSSFactory", ".", "getTermFactory", "(", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"position\"", ",", "tf", ".", "createIdent", "(", "\"absolute\"", ")", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"left\"", ",", "tf", ".", "createLength", "(", "x", ",", "unit", ")", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"top\"", ",", "tf", ".", "createLength", "(", "y", ",", "unit", ")", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"width\"", ",", "tf", ".", "createLength", "(", "width", "-", "wcor", ",", "unit", ")", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"height\"", ",", "tf", ".", "createLength", "(", "height", "-", "wcor", ",", "unit", ")", ")", ")", ";", "if", "(", "stroke", ")", "{", "ret", ".", "push", "(", "createDeclaration", "(", "\"border-width\"", ",", "tf", ".", "createLength", "(", "lw", ",", "unit", ")", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"border-style\"", ",", "tf", ".", "createIdent", "(", "\"solid\"", ")", ")", ")", ";", "String", "color", "=", "colorString", "(", "getGraphicsState", "(", ")", ".", "getStrokingColor", "(", ")", ")", ";", "ret", ".", "push", "(", "createDeclaration", "(", "\"border-color\"", ",", "tf", ".", "createColor", "(", "color", ")", ")", ")", ";", "}", "if", "(", "fill", ")", "{", "String", "color", "=", "colorString", "(", "getGraphicsState", "(", ")", ".", "getNonStrokingColor", "(", ")", ")", ";", "if", "(", "color", "!=", "null", ")", "ret", ".", "push", "(", "createDeclaration", "(", "\"background-color\"", ",", "tf", ".", "createColor", "(", "color", ")", ")", ")", ";", "}", "return", "ret", ";", "}" ]
Creates the style definition used for a rectangle element based on the given properties of the rectangle @param x The X coordinate of the rectangle. @param y The Y coordinate of the rectangle. @param width The width of the rectangle. @param height The height of the rectangle. @param stroke Should there be a stroke around? @param fill Should the rectangle be filled? @return The resulting element style definition.
[ "Creates", "the", "style", "definition", "used", "for", "a", "rectangle", "element", "based", "on", "the", "given", "properties", "of", "the", "rectangle" ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java#L464-L494
163,450
radkovo/Pdf2Dom
src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java
CSSBoxTree.createDeclaration
protected Declaration createDeclaration(String property, Term<?> term) { Declaration d = CSSFactory.getRuleFactory().createDeclaration(); d.unlock(); d.setProperty(property); d.add(term); return d; }
java
protected Declaration createDeclaration(String property, Term<?> term) { Declaration d = CSSFactory.getRuleFactory().createDeclaration(); d.unlock(); d.setProperty(property); d.add(term); return d; }
[ "protected", "Declaration", "createDeclaration", "(", "String", "property", ",", "Term", "<", "?", ">", "term", ")", "{", "Declaration", "d", "=", "CSSFactory", ".", "getRuleFactory", "(", ")", ".", "createDeclaration", "(", ")", ";", "d", ".", "unlock", "(", ")", ";", "d", ".", "setProperty", "(", "property", ")", ";", "d", ".", "add", "(", "term", ")", ";", "return", "d", ";", "}" ]
Creates a single property declaration. @param property Property name. @param term Property value. @return The resulting declaration.
[ "Creates", "a", "single", "property", "declaration", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java#L531-L538
163,451
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.init
private void init() { style = new BoxStyle(UNIT); textLine = new StringBuilder(); textMetrics = null; graphicsPath = new Vector<PathSegment>(); startPage = 0; endPage = Integer.MAX_VALUE; fontTable = new FontTable(); }
java
private void init() { style = new BoxStyle(UNIT); textLine = new StringBuilder(); textMetrics = null; graphicsPath = new Vector<PathSegment>(); startPage = 0; endPage = Integer.MAX_VALUE; fontTable = new FontTable(); }
[ "private", "void", "init", "(", ")", "{", "style", "=", "new", "BoxStyle", "(", "UNIT", ")", ";", "textLine", "=", "new", "StringBuilder", "(", ")", ";", "textMetrics", "=", "null", ";", "graphicsPath", "=", "new", "Vector", "<", "PathSegment", ">", "(", ")", ";", "startPage", "=", "0", ";", "endPage", "=", "Integer", ".", "MAX_VALUE", ";", "fontTable", "=", "new", "FontTable", "(", ")", ";", "}" ]
Internal initialization. @throws ParserConfigurationException
[ "Internal", "initialization", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L189-L198
163,452
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.updateFontTable
protected void updateFontTable() { PDResources resources = pdpage.getResources(); if (resources != null) { try { processFontResources(resources, fontTable); } catch (IOException e) { log.error("Error processing font resources: " + "Exception: {} {}", e.getMessage(), e.getClass()); } } }
java
protected void updateFontTable() { PDResources resources = pdpage.getResources(); if (resources != null) { try { processFontResources(resources, fontTable); } catch (IOException e) { log.error("Error processing font resources: " + "Exception: {} {}", e.getMessage(), e.getClass()); } } }
[ "protected", "void", "updateFontTable", "(", ")", "{", "PDResources", "resources", "=", "pdpage", ".", "getResources", "(", ")", ";", "if", "(", "resources", "!=", "null", ")", "{", "try", "{", "processFontResources", "(", "resources", ",", "fontTable", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"Error processing font resources: \"", "+", "\"Exception: {} {}\"", ",", "e", ".", "getMessage", "(", ")", ",", "e", ".", "getClass", "(", ")", ")", ";", "}", "}", "}" ]
Updates the font table by adding new fonts used at the current page.
[ "Updates", "the", "font", "table", "by", "adding", "new", "fonts", "used", "at", "the", "current", "page", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L354-L367
163,453
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.finishBox
protected void finishBox() { if (textLine.length() > 0) { String s; if (isReversed(Character.getDirectionality(textLine.charAt(0)))) s = textLine.reverse().toString(); else s = textLine.toString(); curstyle.setLeft(textMetrics.getX()); curstyle.setTop(textMetrics.getTop()); curstyle.setLineHeight(textMetrics.getHeight()); renderText(s, textMetrics); textLine = new StringBuilder(); textMetrics = null; } }
java
protected void finishBox() { if (textLine.length() > 0) { String s; if (isReversed(Character.getDirectionality(textLine.charAt(0)))) s = textLine.reverse().toString(); else s = textLine.toString(); curstyle.setLeft(textMetrics.getX()); curstyle.setTop(textMetrics.getTop()); curstyle.setLineHeight(textMetrics.getHeight()); renderText(s, textMetrics); textLine = new StringBuilder(); textMetrics = null; } }
[ "protected", "void", "finishBox", "(", ")", "{", "if", "(", "textLine", ".", "length", "(", ")", ">", "0", ")", "{", "String", "s", ";", "if", "(", "isReversed", "(", "Character", ".", "getDirectionality", "(", "textLine", ".", "charAt", "(", "0", ")", ")", ")", ")", "s", "=", "textLine", ".", "reverse", "(", ")", ".", "toString", "(", ")", ";", "else", "s", "=", "textLine", ".", "toString", "(", ")", ";", "curstyle", ".", "setLeft", "(", "textMetrics", ".", "getX", "(", ")", ")", ";", "curstyle", ".", "setTop", "(", "textMetrics", ".", "getTop", "(", ")", ")", ";", "curstyle", ".", "setLineHeight", "(", "textMetrics", ".", "getHeight", "(", ")", ")", ";", "renderText", "(", "s", ",", "textMetrics", ")", ";", "textLine", "=", "new", "StringBuilder", "(", ")", ";", "textMetrics", "=", "null", ";", "}", "}" ]
Finishes the current box - empties the text line buffer and creates a DOM element from it.
[ "Finishes", "the", "current", "box", "-", "empties", "the", "text", "line", "buffer", "and", "creates", "a", "DOM", "element", "from", "it", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L662-L680
163,454
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.updateStyle
protected void updateStyle(BoxStyle bstyle, TextPosition text) { String font = text.getFont().getName(); String family = null; String weight = null; String fstyle = null; bstyle.setFontSize(text.getFontSizeInPt()); bstyle.setLineHeight(text.getHeight()); if (font != null) { //font style and weight for (int i = 0; i < pdFontType.length; i++) { if (font.toLowerCase().lastIndexOf(pdFontType[i]) >= 0) { weight = cssFontWeight[i]; fstyle = cssFontStyle[i]; break; } } if (weight != null) bstyle.setFontWeight(weight); else bstyle.setFontWeight(cssFontWeight[0]); if (fstyle != null) bstyle.setFontStyle(fstyle); else bstyle.setFontStyle(cssFontStyle[0]); //font family //If it's a known common font don't embed in html output to save space String knownFontFamily = findKnownFontFamily(font); if (!knownFontFamily.equals("")) family = knownFontFamily; else { family = fontTable.getUsedName(text.getFont()); if (family == null) family = font; } if (family != null) bstyle.setFontFamily(family); } updateStyleForRenderingMode(); }
java
protected void updateStyle(BoxStyle bstyle, TextPosition text) { String font = text.getFont().getName(); String family = null; String weight = null; String fstyle = null; bstyle.setFontSize(text.getFontSizeInPt()); bstyle.setLineHeight(text.getHeight()); if (font != null) { //font style and weight for (int i = 0; i < pdFontType.length; i++) { if (font.toLowerCase().lastIndexOf(pdFontType[i]) >= 0) { weight = cssFontWeight[i]; fstyle = cssFontStyle[i]; break; } } if (weight != null) bstyle.setFontWeight(weight); else bstyle.setFontWeight(cssFontWeight[0]); if (fstyle != null) bstyle.setFontStyle(fstyle); else bstyle.setFontStyle(cssFontStyle[0]); //font family //If it's a known common font don't embed in html output to save space String knownFontFamily = findKnownFontFamily(font); if (!knownFontFamily.equals("")) family = knownFontFamily; else { family = fontTable.getUsedName(text.getFont()); if (family == null) family = font; } if (family != null) bstyle.setFontFamily(family); } updateStyleForRenderingMode(); }
[ "protected", "void", "updateStyle", "(", "BoxStyle", "bstyle", ",", "TextPosition", "text", ")", "{", "String", "font", "=", "text", ".", "getFont", "(", ")", ".", "getName", "(", ")", ";", "String", "family", "=", "null", ";", "String", "weight", "=", "null", ";", "String", "fstyle", "=", "null", ";", "bstyle", ".", "setFontSize", "(", "text", ".", "getFontSizeInPt", "(", ")", ")", ";", "bstyle", ".", "setLineHeight", "(", "text", ".", "getHeight", "(", ")", ")", ";", "if", "(", "font", "!=", "null", ")", "{", "//font style and weight", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pdFontType", ".", "length", ";", "i", "++", ")", "{", "if", "(", "font", ".", "toLowerCase", "(", ")", ".", "lastIndexOf", "(", "pdFontType", "[", "i", "]", ")", ">=", "0", ")", "{", "weight", "=", "cssFontWeight", "[", "i", "]", ";", "fstyle", "=", "cssFontStyle", "[", "i", "]", ";", "break", ";", "}", "}", "if", "(", "weight", "!=", "null", ")", "bstyle", ".", "setFontWeight", "(", "weight", ")", ";", "else", "bstyle", ".", "setFontWeight", "(", "cssFontWeight", "[", "0", "]", ")", ";", "if", "(", "fstyle", "!=", "null", ")", "bstyle", ".", "setFontStyle", "(", "fstyle", ")", ";", "else", "bstyle", ".", "setFontStyle", "(", "cssFontStyle", "[", "0", "]", ")", ";", "//font family", "//If it's a known common font don't embed in html output to save space", "String", "knownFontFamily", "=", "findKnownFontFamily", "(", "font", ")", ";", "if", "(", "!", "knownFontFamily", ".", "equals", "(", "\"\"", ")", ")", "family", "=", "knownFontFamily", ";", "else", "{", "family", "=", "fontTable", ".", "getUsedName", "(", "text", ".", "getFont", "(", ")", ")", ";", "if", "(", "family", "==", "null", ")", "family", "=", "font", ";", "}", "if", "(", "family", "!=", "null", ")", "bstyle", ".", "setFontFamily", "(", "family", ")", ";", "}", "updateStyleForRenderingMode", "(", ")", ";", "}" ]
Updates the text style according to a new text position @param bstyle the style to be updated @param text the text position
[ "Updates", "the", "text", "style", "according", "to", "a", "new", "text", "position" ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L707-L755
163,455
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.transformLength
protected float transformLength(float w) { Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); Matrix m = new Matrix(); m.setValue(2, 0, w); return m.multiply(ctm).getTranslateX(); }
java
protected float transformLength(float w) { Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); Matrix m = new Matrix(); m.setValue(2, 0, w); return m.multiply(ctm).getTranslateX(); }
[ "protected", "float", "transformLength", "(", "float", "w", ")", "{", "Matrix", "ctm", "=", "getGraphicsState", "(", ")", ".", "getCurrentTransformationMatrix", "(", ")", ";", "Matrix", "m", "=", "new", "Matrix", "(", ")", ";", "m", ".", "setValue", "(", "2", ",", "0", ",", "w", ")", ";", "return", "m", ".", "multiply", "(", "ctm", ")", ".", "getTranslateX", "(", ")", ";", "}" ]
Transforms a length according to the current transformation matrix.
[ "Transforms", "a", "length", "according", "to", "the", "current", "transformation", "matrix", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L809-L815
163,456
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.transformPosition
protected float[] transformPosition(float x, float y) { Point2D.Float point = super.transformedPoint(x, y); AffineTransform pageTransform = createCurrentPageTransformation(); Point2D.Float transformedPoint = (Point2D.Float) pageTransform.transform(point, null); return new float[]{(float) transformedPoint.getX(), (float) transformedPoint.getY()}; }
java
protected float[] transformPosition(float x, float y) { Point2D.Float point = super.transformedPoint(x, y); AffineTransform pageTransform = createCurrentPageTransformation(); Point2D.Float transformedPoint = (Point2D.Float) pageTransform.transform(point, null); return new float[]{(float) transformedPoint.getX(), (float) transformedPoint.getY()}; }
[ "protected", "float", "[", "]", "transformPosition", "(", "float", "x", ",", "float", "y", ")", "{", "Point2D", ".", "Float", "point", "=", "super", ".", "transformedPoint", "(", "x", ",", "y", ")", ";", "AffineTransform", "pageTransform", "=", "createCurrentPageTransformation", "(", ")", ";", "Point2D", ".", "Float", "transformedPoint", "=", "(", "Point2D", ".", "Float", ")", "pageTransform", ".", "transform", "(", "point", ",", "null", ")", ";", "return", "new", "float", "[", "]", "{", "(", "float", ")", "transformedPoint", ".", "getX", "(", ")", ",", "(", "float", ")", "transformedPoint", ".", "getY", "(", ")", "}", ";", "}" ]
Transforms a position according to the current transformation matrix and current page transformation. @param x @param y @return
[ "Transforms", "a", "position", "according", "to", "the", "current", "transformation", "matrix", "and", "current", "page", "transformation", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L823-L830
163,457
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.stringValue
protected String stringValue(COSBase value) { if (value instanceof COSString) return ((COSString) value).getString(); else if (value instanceof COSNumber) return String.valueOf(((COSNumber) value).floatValue()); else return ""; }
java
protected String stringValue(COSBase value) { if (value instanceof COSString) return ((COSString) value).getString(); else if (value instanceof COSNumber) return String.valueOf(((COSNumber) value).floatValue()); else return ""; }
[ "protected", "String", "stringValue", "(", "COSBase", "value", ")", "{", "if", "(", "value", "instanceof", "COSString", ")", "return", "(", "(", "COSString", ")", "value", ")", ".", "getString", "(", ")", ";", "else", "if", "(", "value", "instanceof", "COSNumber", ")", "return", "String", ".", "valueOf", "(", "(", "(", "COSNumber", ")", "value", ")", ".", "floatValue", "(", ")", ")", ";", "else", "return", "\"\"", ";", "}" ]
Obtains a string from a PDF value @param value the PDF value of the String, Integer or Float type @return the corresponging string value
[ "Obtains", "a", "string", "from", "a", "PDF", "value" ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L899-L907
163,458
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.colorString
protected String colorString(PDColor pdcolor) { String color = null; try { float[] rgb = pdcolor.getColorSpace().toRGB(pdcolor.getComponents()); color = colorString(rgb[0], rgb[1], rgb[2]); } catch (IOException e) { log.error("colorString: IOException: {}", e.getMessage()); } catch (UnsupportedOperationException e) { log.error("colorString: UnsupportedOperationException: {}", e.getMessage()); } return color; }
java
protected String colorString(PDColor pdcolor) { String color = null; try { float[] rgb = pdcolor.getColorSpace().toRGB(pdcolor.getComponents()); color = colorString(rgb[0], rgb[1], rgb[2]); } catch (IOException e) { log.error("colorString: IOException: {}", e.getMessage()); } catch (UnsupportedOperationException e) { log.error("colorString: UnsupportedOperationException: {}", e.getMessage()); } return color; }
[ "protected", "String", "colorString", "(", "PDColor", "pdcolor", ")", "{", "String", "color", "=", "null", ";", "try", "{", "float", "[", "]", "rgb", "=", "pdcolor", ".", "getColorSpace", "(", ")", ".", "toRGB", "(", "pdcolor", ".", "getComponents", "(", ")", ")", ";", "color", "=", "colorString", "(", "rgb", "[", "0", "]", ",", "rgb", "[", "1", "]", ",", "rgb", "[", "2", "]", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"colorString: IOException: {}\"", ",", "e", ".", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "UnsupportedOperationException", "e", ")", "{", "log", ".", "error", "(", "\"colorString: UnsupportedOperationException: {}\"", ",", "e", ".", "getMessage", "(", ")", ")", ";", "}", "return", "color", ";", "}" ]
Creates a CSS rgb specification from a PDF color @param pdcolor @return the rgb() string
[ "Creates", "a", "CSS", "rgb", "specification", "from", "a", "PDF", "color" ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L938-L951
163,459
mapbox/mapbox-events-android
libcore/src/main/java/com/mapbox/android/core/FileUtils.java
FileUtils.listAllFiles
@NonNull public static File[] listAllFiles(File directory) { if (directory == null) { return new File[0]; } File[] files = directory.listFiles(); return files != null ? files : new File[0]; }
java
@NonNull public static File[] listAllFiles(File directory) { if (directory == null) { return new File[0]; } File[] files = directory.listFiles(); return files != null ? files : new File[0]; }
[ "@", "NonNull", "public", "static", "File", "[", "]", "listAllFiles", "(", "File", "directory", ")", "{", "if", "(", "directory", "==", "null", ")", "{", "return", "new", "File", "[", "0", "]", ";", "}", "File", "[", "]", "files", "=", "directory", ".", "listFiles", "(", ")", ";", "return", "files", "!=", "null", "?", "files", ":", "new", "File", "[", "0", "]", ";", "}" ]
Return list of all files in the directory. @param directory target directory on file system @return list of files in the directory or empty list if directory is empty.
[ "Return", "list", "of", "all", "files", "in", "the", "directory", "." ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libcore/src/main/java/com/mapbox/android/core/FileUtils.java#L111-L118
163,460
mapbox/mapbox-events-android
liblocation/src/main/java/com/mapbox/android/core/location/Utils.java
Utils.isOnClasspath
static boolean isOnClasspath(String className) { boolean isOnClassPath = true; try { Class.forName(className); } catch (ClassNotFoundException exception) { isOnClassPath = false; } return isOnClassPath; }
java
static boolean isOnClasspath(String className) { boolean isOnClassPath = true; try { Class.forName(className); } catch (ClassNotFoundException exception) { isOnClassPath = false; } return isOnClassPath; }
[ "static", "boolean", "isOnClasspath", "(", "String", "className", ")", "{", "boolean", "isOnClassPath", "=", "true", ";", "try", "{", "Class", ".", "forName", "(", "className", ")", ";", "}", "catch", "(", "ClassNotFoundException", "exception", ")", "{", "isOnClassPath", "=", "false", ";", "}", "return", "isOnClassPath", ";", "}" ]
Checks if class is on class path @param className of the class to check. @return true if class in on class path, false otherwise.
[ "Checks", "if", "class", "is", "on", "class", "path" ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/liblocation/src/main/java/com/mapbox/android/core/location/Utils.java#L34-L42
163,461
mapbox/mapbox-events-android
liblocation/src/main/java/com/mapbox/android/core/location/LocationEngineResult.java
LocationEngineResult.extractResult
@Nullable public static LocationEngineResult extractResult(Intent intent) { LocationEngineResult result = null; if (isOnClasspath(GOOGLE_PLAY_LOCATION_RESULT)) { result = extractGooglePlayResult(intent); } return result == null ? extractAndroidResult(intent) : result; }
java
@Nullable public static LocationEngineResult extractResult(Intent intent) { LocationEngineResult result = null; if (isOnClasspath(GOOGLE_PLAY_LOCATION_RESULT)) { result = extractGooglePlayResult(intent); } return result == null ? extractAndroidResult(intent) : result; }
[ "@", "Nullable", "public", "static", "LocationEngineResult", "extractResult", "(", "Intent", "intent", ")", "{", "LocationEngineResult", "result", "=", "null", ";", "if", "(", "isOnClasspath", "(", "GOOGLE_PLAY_LOCATION_RESULT", ")", ")", "{", "result", "=", "extractGooglePlayResult", "(", "intent", ")", ";", "}", "return", "result", "==", "null", "?", "extractAndroidResult", "(", "intent", ")", ":", "result", ";", "}" ]
Extracts location result from intent object @param intent valid intent object @return location result. @since 1.1.0
[ "Extracts", "location", "result", "from", "intent", "object" ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/liblocation/src/main/java/com/mapbox/android/core/location/LocationEngineResult.java#L86-L93
163,462
mapbox/mapbox-events-android
liblocation/src/main/java/com/mapbox/android/core/permissions/PermissionsManager.java
PermissionsManager.onRequestPermissionsResult
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case REQUEST_PERMISSIONS_CODE: if (listener != null) { boolean granted = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED; listener.onPermissionResult(granted); } break; default: // Ignored } }
java
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case REQUEST_PERMISSIONS_CODE: if (listener != null) { boolean granted = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED; listener.onPermissionResult(granted); } break; default: // Ignored } }
[ "public", "void", "onRequestPermissionsResult", "(", "int", "requestCode", ",", "String", "[", "]", "permissions", ",", "int", "[", "]", "grantResults", ")", "{", "switch", "(", "requestCode", ")", "{", "case", "REQUEST_PERMISSIONS_CODE", ":", "if", "(", "listener", "!=", "null", ")", "{", "boolean", "granted", "=", "grantResults", ".", "length", ">", "0", "&&", "grantResults", "[", "0", "]", "==", "PackageManager", ".", "PERMISSION_GRANTED", ";", "listener", ".", "onPermissionResult", "(", "granted", ")", ";", "}", "break", ";", "default", ":", "// Ignored", "}", "}" ]
You should call this method from your activity onRequestPermissionsResult. @param requestCode The request code passed in requestPermissions(android.app.Activity, String[], int) @param permissions The requested permissions. Never null. @param grantResults The grant results for the corresponding permissions which is either PERMISSION_GRANTED or PERMISSION_DENIED. Never null.
[ "You", "should", "call", "this", "method", "from", "your", "activity", "onRequestPermissionsResult", "." ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/liblocation/src/main/java/com/mapbox/android/core/permissions/PermissionsManager.java#L95-L106
163,463
mapbox/mapbox-events-android
libtelemetry/src/main/java/com/mapbox/android/telemetry/TelemetryUtils.java
TelemetryUtils.retrieveVendorId
public static String retrieveVendorId() { if (MapboxTelemetry.applicationContext == null) { return updateVendorId(); } SharedPreferences sharedPreferences = obtainSharedPreferences(MapboxTelemetry.applicationContext); String mapboxVendorId = sharedPreferences.getString(MAPBOX_SHARED_PREFERENCE_KEY_VENDOR_ID, ""); if (TelemetryUtils.isEmpty(mapboxVendorId)) { mapboxVendorId = TelemetryUtils.updateVendorId(); } return mapboxVendorId; }
java
public static String retrieveVendorId() { if (MapboxTelemetry.applicationContext == null) { return updateVendorId(); } SharedPreferences sharedPreferences = obtainSharedPreferences(MapboxTelemetry.applicationContext); String mapboxVendorId = sharedPreferences.getString(MAPBOX_SHARED_PREFERENCE_KEY_VENDOR_ID, ""); if (TelemetryUtils.isEmpty(mapboxVendorId)) { mapboxVendorId = TelemetryUtils.updateVendorId(); } return mapboxVendorId; }
[ "public", "static", "String", "retrieveVendorId", "(", ")", "{", "if", "(", "MapboxTelemetry", ".", "applicationContext", "==", "null", ")", "{", "return", "updateVendorId", "(", ")", ";", "}", "SharedPreferences", "sharedPreferences", "=", "obtainSharedPreferences", "(", "MapboxTelemetry", ".", "applicationContext", ")", ";", "String", "mapboxVendorId", "=", "sharedPreferences", ".", "getString", "(", "MAPBOX_SHARED_PREFERENCE_KEY_VENDOR_ID", ",", "\"\"", ")", ";", "if", "(", "TelemetryUtils", ".", "isEmpty", "(", "mapboxVendorId", ")", ")", "{", "mapboxVendorId", "=", "TelemetryUtils", ".", "updateVendorId", "(", ")", ";", "}", "return", "mapboxVendorId", ";", "}" ]
Do not call this method outside of activity!!!
[ "Do", "not", "call", "this", "method", "outside", "of", "activity!!!" ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libtelemetry/src/main/java/com/mapbox/android/telemetry/TelemetryUtils.java#L174-L185
163,464
mapbox/mapbox-events-android
libcore/src/main/java/com/mapbox/android/core/connectivity/ConnectivityReceiver.java
ConnectivityReceiver.getSystemConnectivity
private static boolean getSystemConnectivity(Context context) { try { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) { return false; } NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork.isConnectedOrConnecting(); } catch (Exception exception) { return false; } }
java
private static boolean getSystemConnectivity(Context context) { try { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) { return false; } NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork.isConnectedOrConnecting(); } catch (Exception exception) { return false; } }
[ "private", "static", "boolean", "getSystemConnectivity", "(", "Context", "context", ")", "{", "try", "{", "ConnectivityManager", "cm", "=", "(", "ConnectivityManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "CONNECTIVITY_SERVICE", ")", ";", "if", "(", "cm", "==", "null", ")", "{", "return", "false", ";", "}", "NetworkInfo", "activeNetwork", "=", "cm", ".", "getActiveNetworkInfo", "(", ")", ";", "return", "activeNetwork", ".", "isConnectedOrConnecting", "(", ")", ";", "}", "catch", "(", "Exception", "exception", ")", "{", "return", "false", ";", "}", "}" ]
Get the connectivity state as reported by the Android system @param context Android context @return the connectivity state as reported by the Android system
[ "Get", "the", "connectivity", "state", "as", "reported", "by", "the", "Android", "system" ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libcore/src/main/java/com/mapbox/android/core/connectivity/ConnectivityReceiver.java#L51-L63
163,465
mapbox/mapbox-events-android
libcore/src/main/java/com/mapbox/android/core/crashreporter/CrashReportBuilder.java
CrashReportBuilder.fromJson
public static CrashReport fromJson(String json) throws IllegalArgumentException { try { return new CrashReport(json); } catch (JSONException je) { throw new IllegalArgumentException(je.toString()); } }
java
public static CrashReport fromJson(String json) throws IllegalArgumentException { try { return new CrashReport(json); } catch (JSONException je) { throw new IllegalArgumentException(je.toString()); } }
[ "public", "static", "CrashReport", "fromJson", "(", "String", "json", ")", "throws", "IllegalArgumentException", "{", "try", "{", "return", "new", "CrashReport", "(", "json", ")", ";", "}", "catch", "(", "JSONException", "je", ")", "{", "throw", "new", "IllegalArgumentException", "(", "je", ".", "toString", "(", ")", ")", ";", "}", "}" ]
Exports json encoded content to CrashReport object @param json valid json body. @return new instance of CrashReport
[ "Exports", "json", "encoded", "content", "to", "CrashReport", "object" ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libcore/src/main/java/com/mapbox/android/core/crashreporter/CrashReportBuilder.java#L41-L47
163,466
mapbox/mapbox-events-android
libtelemetry/src/full/java/com/mapbox/android/telemetry/location/LocationCollectionClient.java
LocationCollectionClient.uninstall
static boolean uninstall() { boolean uninstalled = false; synchronized (lock) { if (locationCollectionClient != null) { locationCollectionClient.locationEngineController.onDestroy(); locationCollectionClient.settingsChangeHandlerThread.quit(); locationCollectionClient.sharedPreferences.unregisterOnSharedPreferenceChangeListener(locationCollectionClient); locationCollectionClient = null; uninstalled = true; } } return uninstalled; }
java
static boolean uninstall() { boolean uninstalled = false; synchronized (lock) { if (locationCollectionClient != null) { locationCollectionClient.locationEngineController.onDestroy(); locationCollectionClient.settingsChangeHandlerThread.quit(); locationCollectionClient.sharedPreferences.unregisterOnSharedPreferenceChangeListener(locationCollectionClient); locationCollectionClient = null; uninstalled = true; } } return uninstalled; }
[ "static", "boolean", "uninstall", "(", ")", "{", "boolean", "uninstalled", "=", "false", ";", "synchronized", "(", "lock", ")", "{", "if", "(", "locationCollectionClient", "!=", "null", ")", "{", "locationCollectionClient", ".", "locationEngineController", ".", "onDestroy", "(", ")", ";", "locationCollectionClient", ".", "settingsChangeHandlerThread", ".", "quit", "(", ")", ";", "locationCollectionClient", ".", "sharedPreferences", ".", "unregisterOnSharedPreferenceChangeListener", "(", "locationCollectionClient", ")", ";", "locationCollectionClient", "=", "null", ";", "uninstalled", "=", "true", ";", "}", "}", "return", "uninstalled", ";", "}" ]
Uninstall current location collection client. @return true if uninstall was successful
[ "Uninstall", "current", "location", "collection", "client", "." ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libtelemetry/src/full/java/com/mapbox/android/telemetry/location/LocationCollectionClient.java#L112-L124
163,467
google/openrtb-doubleclick
doubleclick-core/src/main/java/com/google/doubleclick/util/GeoTarget.java
GeoTarget.getCanonAncestor
@Nullable public GeoTarget getCanonAncestor(GeoTarget.Type type) { for (GeoTarget target = this; target != null; target = target.canonParent()) { if (target.key.type == type) { return target; } } return null; }
java
@Nullable public GeoTarget getCanonAncestor(GeoTarget.Type type) { for (GeoTarget target = this; target != null; target = target.canonParent()) { if (target.key.type == type) { return target; } } return null; }
[ "@", "Nullable", "public", "GeoTarget", "getCanonAncestor", "(", "GeoTarget", ".", "Type", "type", ")", "{", "for", "(", "GeoTarget", "target", "=", "this", ";", "target", "!=", "null", ";", "target", "=", "target", ".", "canonParent", "(", ")", ")", "{", "if", "(", "target", ".", "key", ".", "type", "==", "type", ")", "{", "return", "target", ";", "}", "}", "return", "null", ";", "}" ]
Finds an ancestor of a specific type, if possible. <p>Example: (New York city target, {@link Type#COUNTRY}) returns (US country target)
[ "Finds", "an", "ancestor", "of", "a", "specific", "type", "if", "possible", "." ]
2dbbbb54fd7079f107a3dfdd748d2e44e18605c3
https://github.com/google/openrtb-doubleclick/blob/2dbbbb54fd7079f107a3dfdd748d2e44e18605c3/doubleclick-core/src/main/java/com/google/doubleclick/util/GeoTarget.java#L146-L154
163,468
google/openrtb-doubleclick
doubleclick-core/src/main/java/com/google/doubleclick/crypto/DoubleClickCrypto.java
DoubleClickCrypto.encrypt
public byte[] encrypt(byte[] plainData) { checkArgument(plainData.length >= OVERHEAD_SIZE, "Invalid plainData, %s bytes", plainData.length); // workBytes := initVector || payload || zeros:4 byte[] workBytes = plainData.clone(); ByteBuffer workBuffer = ByteBuffer.wrap(workBytes); boolean success = false; try { // workBytes := initVector || payload || I(signature) int signature = hmacSignature(workBytes); workBuffer.putInt(workBytes.length - SIGNATURE_SIZE, signature); // workBytes := initVector || E(payload) || I(signature) xorPayloadToHmacPad(workBytes); if (logger.isDebugEnabled()) { logger.debug(dump("Encrypted", plainData, workBytes)); } success = true; return workBytes; } finally { if (!success && logger.isDebugEnabled()) { logger.debug(dump("Encrypted (failed)", plainData, workBytes)); } } }
java
public byte[] encrypt(byte[] plainData) { checkArgument(plainData.length >= OVERHEAD_SIZE, "Invalid plainData, %s bytes", plainData.length); // workBytes := initVector || payload || zeros:4 byte[] workBytes = plainData.clone(); ByteBuffer workBuffer = ByteBuffer.wrap(workBytes); boolean success = false; try { // workBytes := initVector || payload || I(signature) int signature = hmacSignature(workBytes); workBuffer.putInt(workBytes.length - SIGNATURE_SIZE, signature); // workBytes := initVector || E(payload) || I(signature) xorPayloadToHmacPad(workBytes); if (logger.isDebugEnabled()) { logger.debug(dump("Encrypted", plainData, workBytes)); } success = true; return workBytes; } finally { if (!success && logger.isDebugEnabled()) { logger.debug(dump("Encrypted (failed)", plainData, workBytes)); } } }
[ "public", "byte", "[", "]", "encrypt", "(", "byte", "[", "]", "plainData", ")", "{", "checkArgument", "(", "plainData", ".", "length", ">=", "OVERHEAD_SIZE", ",", "\"Invalid plainData, %s bytes\"", ",", "plainData", ".", "length", ")", ";", "// workBytes := initVector || payload || zeros:4", "byte", "[", "]", "workBytes", "=", "plainData", ".", "clone", "(", ")", ";", "ByteBuffer", "workBuffer", "=", "ByteBuffer", ".", "wrap", "(", "workBytes", ")", ";", "boolean", "success", "=", "false", ";", "try", "{", "// workBytes := initVector || payload || I(signature)", "int", "signature", "=", "hmacSignature", "(", "workBytes", ")", ";", "workBuffer", ".", "putInt", "(", "workBytes", ".", "length", "-", "SIGNATURE_SIZE", ",", "signature", ")", ";", "// workBytes := initVector || E(payload) || I(signature)", "xorPayloadToHmacPad", "(", "workBytes", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "dump", "(", "\"Encrypted\"", ",", "plainData", ",", "workBytes", ")", ")", ";", "}", "success", "=", "true", ";", "return", "workBytes", ";", "}", "finally", "{", "if", "(", "!", "success", "&&", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "dump", "(", "\"Encrypted (failed)\"", ",", "plainData", ",", "workBytes", ")", ")", ";", "}", "}", "}" ]
Encrypts data. @param plainData {@code initVector || payload || zeros:4} @return {@code initVector || E(payload) || I(signature)}
[ "Encrypts", "data", "." ]
2dbbbb54fd7079f107a3dfdd748d2e44e18605c3
https://github.com/google/openrtb-doubleclick/blob/2dbbbb54fd7079f107a3dfdd748d2e44e18605c3/doubleclick-core/src/main/java/com/google/doubleclick/crypto/DoubleClickCrypto.java#L159-L186
163,469
box/box-java-sdk
src/main/java/com/box/sdk/BoxConfig.java
BoxConfig.readFrom
public static BoxConfig readFrom(Reader reader) throws IOException { JsonObject config = JsonObject.readFrom(reader); JsonObject settings = (JsonObject) config.get("boxAppSettings"); String clientId = settings.get("clientID").asString(); String clientSecret = settings.get("clientSecret").asString(); JsonObject appAuth = (JsonObject) settings.get("appAuth"); String publicKeyId = appAuth.get("publicKeyID").asString(); String privateKey = appAuth.get("privateKey").asString(); String passphrase = appAuth.get("passphrase").asString(); String enterpriseId = config.get("enterpriseID").asString(); return new BoxConfig(clientId, clientSecret, enterpriseId, publicKeyId, privateKey, passphrase); }
java
public static BoxConfig readFrom(Reader reader) throws IOException { JsonObject config = JsonObject.readFrom(reader); JsonObject settings = (JsonObject) config.get("boxAppSettings"); String clientId = settings.get("clientID").asString(); String clientSecret = settings.get("clientSecret").asString(); JsonObject appAuth = (JsonObject) settings.get("appAuth"); String publicKeyId = appAuth.get("publicKeyID").asString(); String privateKey = appAuth.get("privateKey").asString(); String passphrase = appAuth.get("passphrase").asString(); String enterpriseId = config.get("enterpriseID").asString(); return new BoxConfig(clientId, clientSecret, enterpriseId, publicKeyId, privateKey, passphrase); }
[ "public", "static", "BoxConfig", "readFrom", "(", "Reader", "reader", ")", "throws", "IOException", "{", "JsonObject", "config", "=", "JsonObject", ".", "readFrom", "(", "reader", ")", ";", "JsonObject", "settings", "=", "(", "JsonObject", ")", "config", ".", "get", "(", "\"boxAppSettings\"", ")", ";", "String", "clientId", "=", "settings", ".", "get", "(", "\"clientID\"", ")", ".", "asString", "(", ")", ";", "String", "clientSecret", "=", "settings", ".", "get", "(", "\"clientSecret\"", ")", ".", "asString", "(", ")", ";", "JsonObject", "appAuth", "=", "(", "JsonObject", ")", "settings", ".", "get", "(", "\"appAuth\"", ")", ";", "String", "publicKeyId", "=", "appAuth", ".", "get", "(", "\"publicKeyID\"", ")", ".", "asString", "(", ")", ";", "String", "privateKey", "=", "appAuth", ".", "get", "(", "\"privateKey\"", ")", ".", "asString", "(", ")", ";", "String", "passphrase", "=", "appAuth", ".", "get", "(", "\"passphrase\"", ")", ".", "asString", "(", ")", ";", "String", "enterpriseId", "=", "config", ".", "get", "(", "\"enterpriseID\"", ")", ".", "asString", "(", ")", ";", "return", "new", "BoxConfig", "(", "clientId", ",", "clientSecret", ",", "enterpriseId", ",", "publicKeyId", ",", "privateKey", ",", "passphrase", ")", ";", "}" ]
Reads OAuth 2.0 with JWT app configurations from the reader. The file should be in JSON format. @param reader a reader object which points to a JSON formatted configuration file @return a new Instance of BoxConfig @throws IOException when unable to access the mapping file's content of the reader
[ "Reads", "OAuth", "2", ".", "0", "with", "JWT", "app", "configurations", "from", "the", "reader", ".", "The", "file", "should", "be", "in", "JSON", "format", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxConfig.java#L98-L109
163,470
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaborationWhitelist.java
BoxCollaborationWhitelist.create
public static BoxCollaborationWhitelist.Info create(final BoxAPIConnection api, String domain, WhitelistDirection direction) { URL url = COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST); JsonObject requestJSON = new JsonObject() .add("domain", domain) .add("direction", direction.toString()); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaborationWhitelist domainWhitelist = new BoxCollaborationWhitelist(api, responseJSON.get("id").asString()); return domainWhitelist.new Info(responseJSON); }
java
public static BoxCollaborationWhitelist.Info create(final BoxAPIConnection api, String domain, WhitelistDirection direction) { URL url = COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST); JsonObject requestJSON = new JsonObject() .add("domain", domain) .add("direction", direction.toString()); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaborationWhitelist domainWhitelist = new BoxCollaborationWhitelist(api, responseJSON.get("id").asString()); return domainWhitelist.new Info(responseJSON); }
[ "public", "static", "BoxCollaborationWhitelist", ".", "Info", "create", "(", "final", "BoxAPIConnection", "api", ",", "String", "domain", ",", "WhitelistDirection", "direction", ")", "{", "URL", "url", "=", "COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "api", ",", "url", ",", "HttpMethod", ".", "POST", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"domain\"", ",", "domain", ")", ".", "add", "(", "\"direction\"", ",", "direction", ".", "toString", "(", ")", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxCollaborationWhitelist", "domainWhitelist", "=", "new", "BoxCollaborationWhitelist", "(", "api", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "domainWhitelist", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Creates a new Collaboration Whitelist for a domain. @param api the API connection to be used by the resource. @param domain the domain to be added to a collaboration whitelist for a Box Enterprise. @param direction an enum representing the direction of the collaboration whitelist. Can be set to inbound, outbound, or both. @return information about the collaboration whitelist created.
[ "Creates", "a", "new", "Collaboration", "Whitelist", "for", "a", "domain", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaborationWhitelist.java#L58-L74
163,471
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaborationWhitelist.java
BoxCollaborationWhitelist.delete
public void delete() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, HttpMethod.DELETE); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void delete() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, HttpMethod.DELETE); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "delete", "(", ")", "{", "BoxAPIConnection", "api", "=", "this", ".", "getAPI", "(", ")", ";", "URL", "url", "=", "COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "api", ",", "url", ",", "HttpMethod", ".", "DELETE", ")", ";", "BoxAPIResponse", "response", "=", "request", ".", "send", "(", ")", ";", "response", ".", "disconnect", "(", ")", ";", "}" ]
Deletes this collaboration whitelist.
[ "Deletes", "this", "collaboration", "whitelist", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaborationWhitelist.java#L129-L136
163,472
box/box-java-sdk
src/main/java/com/box/sdk/internal/utils/CollectionUtils.java
CollectionUtils.map
public static <T_Result, T_Source> List<T_Result> map(Collection<T_Source> source, Mapper<T_Result, T_Source> mapper) { List<T_Result> result = new LinkedList<T_Result>(); for (T_Source element : source) { result.add(mapper.map(element)); } return result; }
java
public static <T_Result, T_Source> List<T_Result> map(Collection<T_Source> source, Mapper<T_Result, T_Source> mapper) { List<T_Result> result = new LinkedList<T_Result>(); for (T_Source element : source) { result.add(mapper.map(element)); } return result; }
[ "public", "static", "<", "T_Result", ",", "T_Source", ">", "List", "<", "T_Result", ">", "map", "(", "Collection", "<", "T_Source", ">", "source", ",", "Mapper", "<", "T_Result", ",", "T_Source", ">", "mapper", ")", "{", "List", "<", "T_Result", ">", "result", "=", "new", "LinkedList", "<", "T_Result", ">", "(", ")", ";", "for", "(", "T_Source", "element", ":", "source", ")", "{", "result", ".", "add", "(", "mapper", ".", "map", "(", "element", ")", ")", ";", "}", "return", "result", ";", "}" ]
Re-maps a provided collection. @param <T_Result> type of result @param <T_Source> type of source @param source for mapping @param mapper element mapper @return mapped source
[ "Re", "-", "maps", "a", "provided", "collection", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/internal/utils/CollectionUtils.java#L31-L38
163,473
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.createFolder
public BoxFolder.Info createFolder(String name) { JsonObject parent = new JsonObject(); parent.add("id", this.getID()); JsonObject newFolder = new JsonObject(); newFolder.add("name", name); newFolder.add("parent", parent); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), CREATE_FOLDER_URL.build(this.getAPI().getBaseURL()), "POST"); request.setBody(newFolder.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFolder createdFolder = new BoxFolder(this.getAPI(), responseJSON.get("id").asString()); return createdFolder.new Info(responseJSON); }
java
public BoxFolder.Info createFolder(String name) { JsonObject parent = new JsonObject(); parent.add("id", this.getID()); JsonObject newFolder = new JsonObject(); newFolder.add("name", name); newFolder.add("parent", parent); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), CREATE_FOLDER_URL.build(this.getAPI().getBaseURL()), "POST"); request.setBody(newFolder.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFolder createdFolder = new BoxFolder(this.getAPI(), responseJSON.get("id").asString()); return createdFolder.new Info(responseJSON); }
[ "public", "BoxFolder", ".", "Info", "createFolder", "(", "String", "name", ")", "{", "JsonObject", "parent", "=", "new", "JsonObject", "(", ")", ";", "parent", ".", "add", "(", "\"id\"", ",", "this", ".", "getID", "(", ")", ")", ";", "JsonObject", "newFolder", "=", "new", "JsonObject", "(", ")", ";", "newFolder", ".", "add", "(", "\"name\"", ",", "name", ")", ";", "newFolder", ".", "add", "(", "\"parent\"", ",", "parent", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "this", ".", "getAPI", "(", ")", ",", "CREATE_FOLDER_URL", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ")", ",", "\"POST\"", ")", ";", "request", ".", "setBody", "(", "newFolder", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxFolder", "createdFolder", "=", "new", "BoxFolder", "(", "this", ".", "getAPI", "(", ")", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "createdFolder", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Creates a new child folder inside this folder. @param name the new folder's name. @return the created folder's info.
[ "Creates", "a", "new", "child", "folder", "inside", "this", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L348-L364
163,474
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.rename
public void rename(String newName) { URL url = FOLDER_INFO_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT"); JsonObject updateInfo = new JsonObject(); updateInfo.add("name", newName); request.setBody(updateInfo.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); response.getJSON(); }
java
public void rename(String newName) { URL url = FOLDER_INFO_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT"); JsonObject updateInfo = new JsonObject(); updateInfo.add("name", newName); request.setBody(updateInfo.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); response.getJSON(); }
[ "public", "void", "rename", "(", "String", "newName", ")", "{", "URL", "url", "=", "FOLDER_INFO_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"PUT\"", ")", ";", "JsonObject", "updateInfo", "=", "new", "JsonObject", "(", ")", ";", "updateInfo", ".", "add", "(", "\"name\"", ",", "newName", ")", ";", "request", ".", "setBody", "(", "updateInfo", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "response", ".", "getJSON", "(", ")", ";", "}" ]
Renames this folder. @param newName the new name of the folder.
[ "Renames", "this", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L409-L419
163,475
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.uploadFile
public BoxFile.Info uploadFile(InputStream fileContent, String name, long fileSize, ProgressListener listener) { FileUploadParams uploadInfo = new FileUploadParams() .setContent(fileContent) .setName(name) .setSize(fileSize) .setProgressListener(listener); return this.uploadFile(uploadInfo); }
java
public BoxFile.Info uploadFile(InputStream fileContent, String name, long fileSize, ProgressListener listener) { FileUploadParams uploadInfo = new FileUploadParams() .setContent(fileContent) .setName(name) .setSize(fileSize) .setProgressListener(listener); return this.uploadFile(uploadInfo); }
[ "public", "BoxFile", ".", "Info", "uploadFile", "(", "InputStream", "fileContent", ",", "String", "name", ",", "long", "fileSize", ",", "ProgressListener", "listener", ")", "{", "FileUploadParams", "uploadInfo", "=", "new", "FileUploadParams", "(", ")", ".", "setContent", "(", "fileContent", ")", ".", "setName", "(", "name", ")", ".", "setSize", "(", "fileSize", ")", ".", "setProgressListener", "(", "listener", ")", ";", "return", "this", ".", "uploadFile", "(", "uploadInfo", ")", ";", "}" ]
Uploads a new file to this folder while reporting the progress to a ProgressListener. @param fileContent a stream containing the contents of the file to upload. @param name the name to give the uploaded file. @param fileSize the size of the file used for determining the progress of the upload. @param listener a listener for monitoring the upload's progress. @return the uploaded file's info.
[ "Uploads", "a", "new", "file", "to", "this", "folder", "while", "reporting", "the", "progress", "to", "a", "ProgressListener", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L482-L489
163,476
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.uploadFile
public BoxFile.Info uploadFile(FileUploadParams uploadParams) { URL uploadURL = UPLOAD_FILE_URL.build(this.getAPI().getBaseUploadURL()); BoxMultipartRequest request = new BoxMultipartRequest(getAPI(), uploadURL); JsonObject fieldJSON = new JsonObject(); JsonObject parentIdJSON = new JsonObject(); parentIdJSON.add("id", getID()); fieldJSON.add("name", uploadParams.getName()); fieldJSON.add("parent", parentIdJSON); if (uploadParams.getCreated() != null) { fieldJSON.add("content_created_at", BoxDateFormat.format(uploadParams.getCreated())); } if (uploadParams.getModified() != null) { fieldJSON.add("content_modified_at", BoxDateFormat.format(uploadParams.getModified())); } if (uploadParams.getSHA1() != null && !uploadParams.getSHA1().isEmpty()) { request.setContentSHA1(uploadParams.getSHA1()); } if (uploadParams.getDescription() != null) { fieldJSON.add("description", uploadParams.getDescription()); } request.putField("attributes", fieldJSON.toString()); if (uploadParams.getSize() > 0) { request.setFile(uploadParams.getContent(), uploadParams.getName(), uploadParams.getSize()); } else if (uploadParams.getContent() != null) { request.setFile(uploadParams.getContent(), uploadParams.getName()); } else { request.setUploadFileCallback(uploadParams.getUploadFileCallback(), uploadParams.getName()); } BoxJSONResponse response; if (uploadParams.getProgressListener() == null) { response = (BoxJSONResponse) request.send(); } else { response = (BoxJSONResponse) request.send(uploadParams.getProgressListener()); } JsonObject collection = JsonObject.readFrom(response.getJSON()); JsonArray entries = collection.get("entries").asArray(); JsonObject fileInfoJSON = entries.get(0).asObject(); String uploadedFileID = fileInfoJSON.get("id").asString(); BoxFile uploadedFile = new BoxFile(getAPI(), uploadedFileID); return uploadedFile.new Info(fileInfoJSON); }
java
public BoxFile.Info uploadFile(FileUploadParams uploadParams) { URL uploadURL = UPLOAD_FILE_URL.build(this.getAPI().getBaseUploadURL()); BoxMultipartRequest request = new BoxMultipartRequest(getAPI(), uploadURL); JsonObject fieldJSON = new JsonObject(); JsonObject parentIdJSON = new JsonObject(); parentIdJSON.add("id", getID()); fieldJSON.add("name", uploadParams.getName()); fieldJSON.add("parent", parentIdJSON); if (uploadParams.getCreated() != null) { fieldJSON.add("content_created_at", BoxDateFormat.format(uploadParams.getCreated())); } if (uploadParams.getModified() != null) { fieldJSON.add("content_modified_at", BoxDateFormat.format(uploadParams.getModified())); } if (uploadParams.getSHA1() != null && !uploadParams.getSHA1().isEmpty()) { request.setContentSHA1(uploadParams.getSHA1()); } if (uploadParams.getDescription() != null) { fieldJSON.add("description", uploadParams.getDescription()); } request.putField("attributes", fieldJSON.toString()); if (uploadParams.getSize() > 0) { request.setFile(uploadParams.getContent(), uploadParams.getName(), uploadParams.getSize()); } else if (uploadParams.getContent() != null) { request.setFile(uploadParams.getContent(), uploadParams.getName()); } else { request.setUploadFileCallback(uploadParams.getUploadFileCallback(), uploadParams.getName()); } BoxJSONResponse response; if (uploadParams.getProgressListener() == null) { response = (BoxJSONResponse) request.send(); } else { response = (BoxJSONResponse) request.send(uploadParams.getProgressListener()); } JsonObject collection = JsonObject.readFrom(response.getJSON()); JsonArray entries = collection.get("entries").asArray(); JsonObject fileInfoJSON = entries.get(0).asObject(); String uploadedFileID = fileInfoJSON.get("id").asString(); BoxFile uploadedFile = new BoxFile(getAPI(), uploadedFileID); return uploadedFile.new Info(fileInfoJSON); }
[ "public", "BoxFile", ".", "Info", "uploadFile", "(", "FileUploadParams", "uploadParams", ")", "{", "URL", "uploadURL", "=", "UPLOAD_FILE_URL", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseUploadURL", "(", ")", ")", ";", "BoxMultipartRequest", "request", "=", "new", "BoxMultipartRequest", "(", "getAPI", "(", ")", ",", "uploadURL", ")", ";", "JsonObject", "fieldJSON", "=", "new", "JsonObject", "(", ")", ";", "JsonObject", "parentIdJSON", "=", "new", "JsonObject", "(", ")", ";", "parentIdJSON", ".", "add", "(", "\"id\"", ",", "getID", "(", ")", ")", ";", "fieldJSON", ".", "add", "(", "\"name\"", ",", "uploadParams", ".", "getName", "(", ")", ")", ";", "fieldJSON", ".", "add", "(", "\"parent\"", ",", "parentIdJSON", ")", ";", "if", "(", "uploadParams", ".", "getCreated", "(", ")", "!=", "null", ")", "{", "fieldJSON", ".", "add", "(", "\"content_created_at\"", ",", "BoxDateFormat", ".", "format", "(", "uploadParams", ".", "getCreated", "(", ")", ")", ")", ";", "}", "if", "(", "uploadParams", ".", "getModified", "(", ")", "!=", "null", ")", "{", "fieldJSON", ".", "add", "(", "\"content_modified_at\"", ",", "BoxDateFormat", ".", "format", "(", "uploadParams", ".", "getModified", "(", ")", ")", ")", ";", "}", "if", "(", "uploadParams", ".", "getSHA1", "(", ")", "!=", "null", "&&", "!", "uploadParams", ".", "getSHA1", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "request", ".", "setContentSHA1", "(", "uploadParams", ".", "getSHA1", "(", ")", ")", ";", "}", "if", "(", "uploadParams", ".", "getDescription", "(", ")", "!=", "null", ")", "{", "fieldJSON", ".", "add", "(", "\"description\"", ",", "uploadParams", ".", "getDescription", "(", ")", ")", ";", "}", "request", ".", "putField", "(", "\"attributes\"", ",", "fieldJSON", ".", "toString", "(", ")", ")", ";", "if", "(", "uploadParams", ".", "getSize", "(", ")", ">", "0", ")", "{", "request", ".", "setFile", "(", "uploadParams", ".", "getContent", "(", ")", ",", "uploadParams", ".", "getName", "(", ")", ",", "uploadParams", ".", "getSize", "(", ")", ")", ";", "}", "else", "if", "(", "uploadParams", ".", "getContent", "(", ")", "!=", "null", ")", "{", "request", ".", "setFile", "(", "uploadParams", ".", "getContent", "(", ")", ",", "uploadParams", ".", "getName", "(", ")", ")", ";", "}", "else", "{", "request", ".", "setUploadFileCallback", "(", "uploadParams", ".", "getUploadFileCallback", "(", ")", ",", "uploadParams", ".", "getName", "(", ")", ")", ";", "}", "BoxJSONResponse", "response", ";", "if", "(", "uploadParams", ".", "getProgressListener", "(", ")", "==", "null", ")", "{", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "}", "else", "{", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", "uploadParams", ".", "getProgressListener", "(", ")", ")", ";", "}", "JsonObject", "collection", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "JsonArray", "entries", "=", "collection", ".", "get", "(", "\"entries\"", ")", ".", "asArray", "(", ")", ";", "JsonObject", "fileInfoJSON", "=", "entries", ".", "get", "(", "0", ")", ".", "asObject", "(", ")", ";", "String", "uploadedFileID", "=", "fileInfoJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ";", "BoxFile", "uploadedFile", "=", "new", "BoxFile", "(", "getAPI", "(", ")", ",", "uploadedFileID", ")", ";", "return", "uploadedFile", ".", "new", "Info", "(", "fileInfoJSON", ")", ";", "}" ]
Uploads a new file to this folder with custom upload parameters. @param uploadParams the custom upload parameters. @return the uploaded file's info.
[ "Uploads", "a", "new", "file", "to", "this", "folder", "with", "custom", "upload", "parameters", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L513-L562
163,477
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.getChildren
public Iterable<BoxItem.Info> getChildren(final String... fields) { return new Iterable<BoxItem.Info>() { @Override public Iterator<BoxItem.Info> iterator() { String queryString = new QueryStringBuilder().appendParam("fields", fields).toString(); URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), queryString, getID()); return new BoxItemIterator(getAPI(), url); } }; }
java
public Iterable<BoxItem.Info> getChildren(final String... fields) { return new Iterable<BoxItem.Info>() { @Override public Iterator<BoxItem.Info> iterator() { String queryString = new QueryStringBuilder().appendParam("fields", fields).toString(); URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), queryString, getID()); return new BoxItemIterator(getAPI(), url); } }; }
[ "public", "Iterable", "<", "BoxItem", ".", "Info", ">", "getChildren", "(", "final", "String", "...", "fields", ")", "{", "return", "new", "Iterable", "<", "BoxItem", ".", "Info", ">", "(", ")", "{", "@", "Override", "public", "Iterator", "<", "BoxItem", ".", "Info", ">", "iterator", "(", ")", "{", "String", "queryString", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ".", "toString", "(", ")", ";", "URL", "url", "=", "GET_ITEMS_URL", ".", "buildWithQuery", "(", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "queryString", ",", "getID", "(", ")", ")", ";", "return", "new", "BoxItemIterator", "(", "getAPI", "(", ")", ",", "url", ")", ";", "}", "}", ";", "}" ]
Returns an iterable containing the items in this folder and specifies which child fields to retrieve from the API. @param fields the fields to retrieve. @return an iterable containing the items in this folder.
[ "Returns", "an", "iterable", "containing", "the", "items", "in", "this", "folder", "and", "specifies", "which", "child", "fields", "to", "retrieve", "from", "the", "API", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L646-L655
163,478
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.getChildren
public Iterable<BoxItem.Info> getChildren(String sort, SortDirection direction, final String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("sort", sort) .appendParam("direction", direction.toString()); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } final String query = builder.toString(); return new Iterable<BoxItem.Info>() { @Override public Iterator<BoxItem.Info> iterator() { URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), query, getID()); return new BoxItemIterator(getAPI(), url); } }; }
java
public Iterable<BoxItem.Info> getChildren(String sort, SortDirection direction, final String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("sort", sort) .appendParam("direction", direction.toString()); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } final String query = builder.toString(); return new Iterable<BoxItem.Info>() { @Override public Iterator<BoxItem.Info> iterator() { URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), query, getID()); return new BoxItemIterator(getAPI(), url); } }; }
[ "public", "Iterable", "<", "BoxItem", ".", "Info", ">", "getChildren", "(", "String", "sort", ",", "SortDirection", "direction", ",", "final", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendParam", "(", "\"sort\"", ",", "sort", ")", ".", "appendParam", "(", "\"direction\"", ",", "direction", ".", "toString", "(", ")", ")", ";", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "builder", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ".", "toString", "(", ")", ";", "}", "final", "String", "query", "=", "builder", ".", "toString", "(", ")", ";", "return", "new", "Iterable", "<", "BoxItem", ".", "Info", ">", "(", ")", "{", "@", "Override", "public", "Iterator", "<", "BoxItem", ".", "Info", ">", "iterator", "(", ")", "{", "URL", "url", "=", "GET_ITEMS_URL", ".", "buildWithQuery", "(", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "query", ",", "getID", "(", ")", ")", ";", "return", "new", "BoxItemIterator", "(", "getAPI", "(", ")", ",", "url", ")", ";", "}", "}", ";", "}" ]
Returns an iterable containing the items in this folder sorted by name and direction. @param sort the field to sort by, can be set as `name`, `id`, and `date`. @param direction the direction to display the item results. @param fields the fields to retrieve. @return an iterable containing the items in this folder.
[ "Returns", "an", "iterable", "containing", "the", "items", "in", "this", "folder", "sorted", "by", "name", "and", "direction", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L664-L680
163,479
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.getChildrenRange
public PartialCollection<BoxItem.Info> getChildrenRange(long offset, long limit, String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("limit", limit) .appendParam("offset", offset); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), builder.toString(), getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); String totalCountString = responseJSON.get("total_count").toString(); long fullSize = Double.valueOf(totalCountString).longValue(); PartialCollection<BoxItem.Info> children = new PartialCollection<BoxItem.Info>(offset, limit, fullSize); JsonArray jsonArray = responseJSON.get("entries").asArray(); for (JsonValue value : jsonArray) { JsonObject jsonObject = value.asObject(); BoxItem.Info parsedItemInfo = (BoxItem.Info) BoxResource.parseInfo(this.getAPI(), jsonObject); if (parsedItemInfo != null) { children.add(parsedItemInfo); } } return children; }
java
public PartialCollection<BoxItem.Info> getChildrenRange(long offset, long limit, String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("limit", limit) .appendParam("offset", offset); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), builder.toString(), getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); String totalCountString = responseJSON.get("total_count").toString(); long fullSize = Double.valueOf(totalCountString).longValue(); PartialCollection<BoxItem.Info> children = new PartialCollection<BoxItem.Info>(offset, limit, fullSize); JsonArray jsonArray = responseJSON.get("entries").asArray(); for (JsonValue value : jsonArray) { JsonObject jsonObject = value.asObject(); BoxItem.Info parsedItemInfo = (BoxItem.Info) BoxResource.parseInfo(this.getAPI(), jsonObject); if (parsedItemInfo != null) { children.add(parsedItemInfo); } } return children; }
[ "public", "PartialCollection", "<", "BoxItem", ".", "Info", ">", "getChildrenRange", "(", "long", "offset", ",", "long", "limit", ",", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendParam", "(", "\"limit\"", ",", "limit", ")", ".", "appendParam", "(", "\"offset\"", ",", "offset", ")", ";", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "builder", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ".", "toString", "(", ")", ";", "}", "URL", "url", "=", "GET_ITEMS_URL", ".", "buildWithQuery", "(", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "builder", ".", "toString", "(", ")", ",", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "String", "totalCountString", "=", "responseJSON", ".", "get", "(", "\"total_count\"", ")", ".", "toString", "(", ")", ";", "long", "fullSize", "=", "Double", ".", "valueOf", "(", "totalCountString", ")", ".", "longValue", "(", ")", ";", "PartialCollection", "<", "BoxItem", ".", "Info", ">", "children", "=", "new", "PartialCollection", "<", "BoxItem", ".", "Info", ">", "(", "offset", ",", "limit", ",", "fullSize", ")", ";", "JsonArray", "jsonArray", "=", "responseJSON", ".", "get", "(", "\"entries\"", ")", ".", "asArray", "(", ")", ";", "for", "(", "JsonValue", "value", ":", "jsonArray", ")", "{", "JsonObject", "jsonObject", "=", "value", ".", "asObject", "(", ")", ";", "BoxItem", ".", "Info", "parsedItemInfo", "=", "(", "BoxItem", ".", "Info", ")", "BoxResource", ".", "parseInfo", "(", "this", ".", "getAPI", "(", ")", ",", "jsonObject", ")", ";", "if", "(", "parsedItemInfo", "!=", "null", ")", "{", "children", ".", "add", "(", "parsedItemInfo", ")", ";", "}", "}", "return", "children", ";", "}" ]
Retrieves a specific range of child items in this folder. @param offset the index of the first child item to retrieve. @param limit the maximum number of children to retrieve after the offset. @param fields the fields to retrieve. @return a partial collection containing the specified range of child items.
[ "Retrieves", "a", "specific", "range", "of", "child", "items", "in", "this", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L690-L716
163,480
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.iterator
@Override public Iterator<BoxItem.Info> iterator() { URL url = GET_ITEMS_URL.build(this.getAPI().getBaseURL(), BoxFolder.this.getID()); return new BoxItemIterator(BoxFolder.this.getAPI(), url); }
java
@Override public Iterator<BoxItem.Info> iterator() { URL url = GET_ITEMS_URL.build(this.getAPI().getBaseURL(), BoxFolder.this.getID()); return new BoxItemIterator(BoxFolder.this.getAPI(), url); }
[ "@", "Override", "public", "Iterator", "<", "BoxItem", ".", "Info", ">", "iterator", "(", ")", "{", "URL", "url", "=", "GET_ITEMS_URL", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "BoxFolder", ".", "this", ".", "getID", "(", ")", ")", ";", "return", "new", "BoxItemIterator", "(", "BoxFolder", ".", "this", ".", "getAPI", "(", ")", ",", "url", ")", ";", "}" ]
Returns an iterator over the items in this folder. @return an iterator over the items in this folder.
[ "Returns", "an", "iterator", "over", "the", "items", "in", "this", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L723-L727
163,481
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.createMetadata
public Metadata createMetadata(String templateName, Metadata metadata) { String scope = Metadata.scopeBasedOnType(templateName); return this.createMetadata(templateName, scope, metadata); }
java
public Metadata createMetadata(String templateName, Metadata metadata) { String scope = Metadata.scopeBasedOnType(templateName); return this.createMetadata(templateName, scope, metadata); }
[ "public", "Metadata", "createMetadata", "(", "String", "templateName", ",", "Metadata", "metadata", ")", "{", "String", "scope", "=", "Metadata", ".", "scopeBasedOnType", "(", "templateName", ")", ";", "return", "this", ".", "createMetadata", "(", "templateName", ",", "scope", ",", "metadata", ")", ";", "}" ]
Creates metadata on this folder using a specified template. @param templateName the name of the metadata template. @param metadata the new metadata values. @return the metadata returned from the server.
[ "Creates", "metadata", "on", "this", "folder", "using", "a", "specified", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L837-L840
163,482
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.createMetadata
public Metadata createMetadata(String templateName, String scope, Metadata metadata) { URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, templateName); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "POST"); request.addHeader("Content-Type", "application/json"); request.setBody(metadata.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Metadata(JsonObject.readFrom(response.getJSON())); }
java
public Metadata createMetadata(String templateName, String scope, Metadata metadata) { URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, templateName); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "POST"); request.addHeader("Content-Type", "application/json"); request.setBody(metadata.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Metadata(JsonObject.readFrom(response.getJSON())); }
[ "public", "Metadata", "createMetadata", "(", "String", "templateName", ",", "String", "scope", ",", "Metadata", "metadata", ")", "{", "URL", "url", "=", "METADATA_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ",", "scope", ",", "templateName", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "addHeader", "(", "\"Content-Type\"", ",", "\"application/json\"", ")", ";", "request", ".", "setBody", "(", "metadata", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "return", "new", "Metadata", "(", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ")", ";", "}" ]
Creates metadata on this folder using a specified scope and template. @param templateName the name of the metadata template. @param scope the scope of the template (usually "global" or "enterprise"). @param metadata the new metadata values. @return the metadata returned from the server.
[ "Creates", "metadata", "on", "this", "folder", "using", "a", "specified", "scope", "and", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L850-L857
163,483
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.setMetadata
public Metadata setMetadata(String templateName, String scope, Metadata metadata) { Metadata metadataValue = null; try { metadataValue = this.createMetadata(templateName, scope, metadata); } catch (BoxAPIException e) { if (e.getResponseCode() == 409) { Metadata metadataToUpdate = new Metadata(scope, templateName); for (JsonValue value : metadata.getOperations()) { if (value.asObject().get("value").isNumber()) { metadataToUpdate.add(value.asObject().get("path").asString(), value.asObject().get("value").asFloat()); } else if (value.asObject().get("value").isString()) { metadataToUpdate.add(value.asObject().get("path").asString(), value.asObject().get("value").asString()); } else if (value.asObject().get("value").isArray()) { ArrayList<String> list = new ArrayList<String>(); for (JsonValue jsonValue : value.asObject().get("value").asArray()) { list.add(jsonValue.asString()); } metadataToUpdate.add(value.asObject().get("path").asString(), list); } } metadataValue = this.updateMetadata(metadataToUpdate); } } return metadataValue; }
java
public Metadata setMetadata(String templateName, String scope, Metadata metadata) { Metadata metadataValue = null; try { metadataValue = this.createMetadata(templateName, scope, metadata); } catch (BoxAPIException e) { if (e.getResponseCode() == 409) { Metadata metadataToUpdate = new Metadata(scope, templateName); for (JsonValue value : metadata.getOperations()) { if (value.asObject().get("value").isNumber()) { metadataToUpdate.add(value.asObject().get("path").asString(), value.asObject().get("value").asFloat()); } else if (value.asObject().get("value").isString()) { metadataToUpdate.add(value.asObject().get("path").asString(), value.asObject().get("value").asString()); } else if (value.asObject().get("value").isArray()) { ArrayList<String> list = new ArrayList<String>(); for (JsonValue jsonValue : value.asObject().get("value").asArray()) { list.add(jsonValue.asString()); } metadataToUpdate.add(value.asObject().get("path").asString(), list); } } metadataValue = this.updateMetadata(metadataToUpdate); } } return metadataValue; }
[ "public", "Metadata", "setMetadata", "(", "String", "templateName", ",", "String", "scope", ",", "Metadata", "metadata", ")", "{", "Metadata", "metadataValue", "=", "null", ";", "try", "{", "metadataValue", "=", "this", ".", "createMetadata", "(", "templateName", ",", "scope", ",", "metadata", ")", ";", "}", "catch", "(", "BoxAPIException", "e", ")", "{", "if", "(", "e", ".", "getResponseCode", "(", ")", "==", "409", ")", "{", "Metadata", "metadataToUpdate", "=", "new", "Metadata", "(", "scope", ",", "templateName", ")", ";", "for", "(", "JsonValue", "value", ":", "metadata", ".", "getOperations", "(", ")", ")", "{", "if", "(", "value", ".", "asObject", "(", ")", ".", "get", "(", "\"value\"", ")", ".", "isNumber", "(", ")", ")", "{", "metadataToUpdate", ".", "add", "(", "value", ".", "asObject", "(", ")", ".", "get", "(", "\"path\"", ")", ".", "asString", "(", ")", ",", "value", ".", "asObject", "(", ")", ".", "get", "(", "\"value\"", ")", ".", "asFloat", "(", ")", ")", ";", "}", "else", "if", "(", "value", ".", "asObject", "(", ")", ".", "get", "(", "\"value\"", ")", ".", "isString", "(", ")", ")", "{", "metadataToUpdate", ".", "add", "(", "value", ".", "asObject", "(", ")", ".", "get", "(", "\"path\"", ")", ".", "asString", "(", ")", ",", "value", ".", "asObject", "(", ")", ".", "get", "(", "\"value\"", ")", ".", "asString", "(", ")", ")", ";", "}", "else", "if", "(", "value", ".", "asObject", "(", ")", ".", "get", "(", "\"value\"", ")", ".", "isArray", "(", ")", ")", "{", "ArrayList", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "JsonValue", "jsonValue", ":", "value", ".", "asObject", "(", ")", ".", "get", "(", "\"value\"", ")", ".", "asArray", "(", ")", ")", "{", "list", ".", "add", "(", "jsonValue", ".", "asString", "(", ")", ")", ";", "}", "metadataToUpdate", ".", "add", "(", "value", ".", "asObject", "(", ")", ".", "get", "(", "\"path\"", ")", ".", "asString", "(", ")", ",", "list", ")", ";", "}", "}", "metadataValue", "=", "this", ".", "updateMetadata", "(", "metadataToUpdate", ")", ";", "}", "}", "return", "metadataValue", ";", "}" ]
Sets the provided metadata on the folder, overwriting any existing metadata keys already present. @param templateName the name of the metadata template. @param scope the scope of the template (usually "global" or "enterprise"). @param metadata the new metadata values. @return the metadata returned from the server.
[ "Sets", "the", "provided", "metadata", "on", "the", "folder", "overwriting", "any", "existing", "metadata", "keys", "already", "present", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L867-L895
163,484
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.getMetadata
public Metadata getMetadata(String templateName) { String scope = Metadata.scopeBasedOnType(templateName); return this.getMetadata(templateName, scope); }
java
public Metadata getMetadata(String templateName) { String scope = Metadata.scopeBasedOnType(templateName); return this.getMetadata(templateName, scope); }
[ "public", "Metadata", "getMetadata", "(", "String", "templateName", ")", "{", "String", "scope", "=", "Metadata", ".", "scopeBasedOnType", "(", "templateName", ")", ";", "return", "this", ".", "getMetadata", "(", "templateName", ",", "scope", ")", ";", "}" ]
Gets the metadata on this folder associated with a specified template. @param templateName the metadata template type name. @return the metadata returned from the server.
[ "Gets", "the", "metadata", "on", "this", "folder", "associated", "with", "a", "specified", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L912-L915
163,485
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.deleteMetadata
public void deleteMetadata(String templateName) { String scope = Metadata.scopeBasedOnType(templateName); this.deleteMetadata(templateName, scope); }
java
public void deleteMetadata(String templateName) { String scope = Metadata.scopeBasedOnType(templateName); this.deleteMetadata(templateName, scope); }
[ "public", "void", "deleteMetadata", "(", "String", "templateName", ")", "{", "String", "scope", "=", "Metadata", ".", "scopeBasedOnType", "(", "templateName", ")", ";", "this", ".", "deleteMetadata", "(", "templateName", ",", "scope", ")", ";", "}" ]
Deletes the metadata on this folder associated with a specified template. @param templateName the metadata template type name.
[ "Deletes", "the", "metadata", "on", "this", "folder", "associated", "with", "a", "specified", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L959-L962
163,486
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.deleteMetadata
public void deleteMetadata(String templateName, String scope) { URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, templateName); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void deleteMetadata(String templateName, String scope) { URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, templateName); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "deleteMetadata", "(", "String", "templateName", ",", "String", "scope", ")", "{", "URL", "url", "=", "METADATA_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ",", "scope", ",", "templateName", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"DELETE\"", ")", ";", "BoxAPIResponse", "response", "=", "request", ".", "send", "(", ")", ";", "response", ".", "disconnect", "(", ")", ";", "}" ]
Deletes the metadata on this folder associated with a specified scope and template. @param templateName the metadata template type name. @param scope the scope of the template (usually "global" or "enterprise").
[ "Deletes", "the", "metadata", "on", "this", "folder", "associated", "with", "a", "specified", "scope", "and", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L970-L975
163,487
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.addClassification
public String addClassification(String classificationType) { Metadata metadata = new Metadata().add(Metadata.CLASSIFICATION_KEY, classificationType); Metadata classification = this.createMetadata(Metadata.CLASSIFICATION_TEMPLATE_KEY, "enterprise", metadata); return classification.getString(Metadata.CLASSIFICATION_KEY); }
java
public String addClassification(String classificationType) { Metadata metadata = new Metadata().add(Metadata.CLASSIFICATION_KEY, classificationType); Metadata classification = this.createMetadata(Metadata.CLASSIFICATION_TEMPLATE_KEY, "enterprise", metadata); return classification.getString(Metadata.CLASSIFICATION_KEY); }
[ "public", "String", "addClassification", "(", "String", "classificationType", ")", "{", "Metadata", "metadata", "=", "new", "Metadata", "(", ")", ".", "add", "(", "Metadata", ".", "CLASSIFICATION_KEY", ",", "classificationType", ")", ";", "Metadata", "classification", "=", "this", ".", "createMetadata", "(", "Metadata", ".", "CLASSIFICATION_TEMPLATE_KEY", ",", "\"enterprise\"", ",", "metadata", ")", ";", "return", "classification", ".", "getString", "(", "Metadata", ".", "CLASSIFICATION_KEY", ")", ";", "}" ]
Adds a metadata classification to the specified file. @param classificationType the metadata classification type. @return the metadata classification type added to the file.
[ "Adds", "a", "metadata", "classification", "to", "the", "specified", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L983-L989
163,488
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.uploadLargeFile
public BoxFile.Info uploadLargeFile(InputStream inputStream, String fileName, long fileSize) throws InterruptedException, IOException { URL url = UPLOAD_SESSION_URL_TEMPLATE.build(this.getAPI().getBaseUploadURL()); return new LargeFileUpload(). upload(this.getAPI(), this.getID(), inputStream, url, fileName, fileSize); }
java
public BoxFile.Info uploadLargeFile(InputStream inputStream, String fileName, long fileSize) throws InterruptedException, IOException { URL url = UPLOAD_SESSION_URL_TEMPLATE.build(this.getAPI().getBaseUploadURL()); return new LargeFileUpload(). upload(this.getAPI(), this.getID(), inputStream, url, fileName, fileSize); }
[ "public", "BoxFile", ".", "Info", "uploadLargeFile", "(", "InputStream", "inputStream", ",", "String", "fileName", ",", "long", "fileSize", ")", "throws", "InterruptedException", ",", "IOException", "{", "URL", "url", "=", "UPLOAD_SESSION_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseUploadURL", "(", ")", ")", ";", "return", "new", "LargeFileUpload", "(", ")", ".", "upload", "(", "this", ".", "getAPI", "(", ")", ",", "this", ".", "getID", "(", ")", ",", "inputStream", ",", "url", ",", "fileName", ",", "fileSize", ")", ";", "}" ]
Creates a new file. @param inputStream the stream instance that contains the data. @param fileName the name of the file to be created. @param fileSize the size of the file that will be uploaded. @return the created file instance. @throws InterruptedException when a thread execution is interrupted. @throws IOException when reading a stream throws exception.
[ "Creates", "a", "new", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L1085-L1090
163,489
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.getMetadataCascadePolicies
public Iterable<BoxMetadataCascadePolicy.Info> getMetadataCascadePolicies(String... fields) { Iterable<BoxMetadataCascadePolicy.Info> cascadePoliciesInfo = BoxMetadataCascadePolicy.getAll(this.getAPI(), this.getID(), fields); return cascadePoliciesInfo; }
java
public Iterable<BoxMetadataCascadePolicy.Info> getMetadataCascadePolicies(String... fields) { Iterable<BoxMetadataCascadePolicy.Info> cascadePoliciesInfo = BoxMetadataCascadePolicy.getAll(this.getAPI(), this.getID(), fields); return cascadePoliciesInfo; }
[ "public", "Iterable", "<", "BoxMetadataCascadePolicy", ".", "Info", ">", "getMetadataCascadePolicies", "(", "String", "...", "fields", ")", "{", "Iterable", "<", "BoxMetadataCascadePolicy", ".", "Info", ">", "cascadePoliciesInfo", "=", "BoxMetadataCascadePolicy", ".", "getAll", "(", "this", ".", "getAPI", "(", ")", ",", "this", ".", "getID", "(", ")", ",", "fields", ")", ";", "return", "cascadePoliciesInfo", ";", "}" ]
Retrieves all Metadata Cascade Policies on a folder. @param fields optional fields to retrieve for cascade policies. @return the Iterable of Box Metadata Cascade Policies in your enterprise.
[ "Retrieves", "all", "Metadata", "Cascade", "Policies", "on", "a", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L1131-L1136
163,490
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.createIndefinitePolicy
public static BoxRetentionPolicy.Info createIndefinitePolicy(BoxAPIConnection api, String name) { return createRetentionPolicy(api, name, TYPE_INDEFINITE, 0, ACTION_REMOVE_RETENTION); }
java
public static BoxRetentionPolicy.Info createIndefinitePolicy(BoxAPIConnection api, String name) { return createRetentionPolicy(api, name, TYPE_INDEFINITE, 0, ACTION_REMOVE_RETENTION); }
[ "public", "static", "BoxRetentionPolicy", ".", "Info", "createIndefinitePolicy", "(", "BoxAPIConnection", "api", ",", "String", "name", ")", "{", "return", "createRetentionPolicy", "(", "api", ",", "name", ",", "TYPE_INDEFINITE", ",", "0", ",", "ACTION_REMOVE_RETENTION", ")", ";", "}" ]
Used to create a new indefinite retention policy. @param api the API connection to be used by the created user. @param name the name of the retention policy. @return the created retention policy's info.
[ "Used", "to", "create", "a", "new", "indefinite", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L93-L95
163,491
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.createFinitePolicy
public static BoxRetentionPolicy.Info createFinitePolicy(BoxAPIConnection api, String name, int length, String action, RetentionPolicyParams optionalParams) { return createRetentionPolicy(api, name, TYPE_FINITE, length, action, optionalParams); }
java
public static BoxRetentionPolicy.Info createFinitePolicy(BoxAPIConnection api, String name, int length, String action, RetentionPolicyParams optionalParams) { return createRetentionPolicy(api, name, TYPE_FINITE, length, action, optionalParams); }
[ "public", "static", "BoxRetentionPolicy", ".", "Info", "createFinitePolicy", "(", "BoxAPIConnection", "api", ",", "String", "name", ",", "int", "length", ",", "String", "action", ",", "RetentionPolicyParams", "optionalParams", ")", "{", "return", "createRetentionPolicy", "(", "api", ",", "name", ",", "TYPE_FINITE", ",", "length", ",", "action", ",", "optionalParams", ")", ";", "}" ]
Used to create a new finite retention policy with optional parameters. @param api the API connection to be used by the created user. @param name the name of the retention policy. @param length the duration in days that the retention policy will be active for after being assigned to content. @param action the disposition action can be "permanently_delete" or "remove_retention". @param optionalParams the optional parameters. @return the created retention policy's info.
[ "Used", "to", "create", "a", "new", "finite", "retention", "policy", "with", "optional", "parameters", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L131-L134
163,492
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.createRetentionPolicy
private static BoxRetentionPolicy.Info createRetentionPolicy(BoxAPIConnection api, String name, String type, int length, String action) { return createRetentionPolicy(api, name, type, length, action, null); }
java
private static BoxRetentionPolicy.Info createRetentionPolicy(BoxAPIConnection api, String name, String type, int length, String action) { return createRetentionPolicy(api, name, type, length, action, null); }
[ "private", "static", "BoxRetentionPolicy", ".", "Info", "createRetentionPolicy", "(", "BoxAPIConnection", "api", ",", "String", "name", ",", "String", "type", ",", "int", "length", ",", "String", "action", ")", "{", "return", "createRetentionPolicy", "(", "api", ",", "name", ",", "type", ",", "length", ",", "action", ",", "null", ")", ";", "}" ]
Used to create a new retention policy. @param api the API connection to be used by the created user. @param name the name of the retention policy. @param type the type of the retention policy. Can be "finite" or "indefinite". @param length the duration in days that the retention policy will be active for after being assigned to content. @param action the disposition action can be "permanently_delete" or "remove_retention". @return the created retention policy's info.
[ "Used", "to", "create", "a", "new", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L145-L148
163,493
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.createRetentionPolicy
private static BoxRetentionPolicy.Info createRetentionPolicy(BoxAPIConnection api, String name, String type, int length, String action, RetentionPolicyParams optionalParams) { URL url = RETENTION_POLICIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_name", name) .add("policy_type", type) .add("disposition_action", action); if (!type.equals(TYPE_INDEFINITE)) { requestJSON.add("retention_length", length); } if (optionalParams != null) { requestJSON.add("can_owner_extend_retention", optionalParams.getCanOwnerExtendRetention()); requestJSON.add("are_owners_notified", optionalParams.getAreOwnersNotified()); List<BoxUser.Info> customNotificationRecipients = optionalParams.getCustomNotificationRecipients(); if (customNotificationRecipients.size() > 0) { JsonArray users = new JsonArray(); for (BoxUser.Info user : customNotificationRecipients) { JsonObject userJSON = new JsonObject() .add("type", "user") .add("id", user.getID()); users.add(userJSON); } requestJSON.add("custom_notification_recipients", users); } } request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxRetentionPolicy createdPolicy = new BoxRetentionPolicy(api, responseJSON.get("id").asString()); return createdPolicy.new Info(responseJSON); }
java
private static BoxRetentionPolicy.Info createRetentionPolicy(BoxAPIConnection api, String name, String type, int length, String action, RetentionPolicyParams optionalParams) { URL url = RETENTION_POLICIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_name", name) .add("policy_type", type) .add("disposition_action", action); if (!type.equals(TYPE_INDEFINITE)) { requestJSON.add("retention_length", length); } if (optionalParams != null) { requestJSON.add("can_owner_extend_retention", optionalParams.getCanOwnerExtendRetention()); requestJSON.add("are_owners_notified", optionalParams.getAreOwnersNotified()); List<BoxUser.Info> customNotificationRecipients = optionalParams.getCustomNotificationRecipients(); if (customNotificationRecipients.size() > 0) { JsonArray users = new JsonArray(); for (BoxUser.Info user : customNotificationRecipients) { JsonObject userJSON = new JsonObject() .add("type", "user") .add("id", user.getID()); users.add(userJSON); } requestJSON.add("custom_notification_recipients", users); } } request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxRetentionPolicy createdPolicy = new BoxRetentionPolicy(api, responseJSON.get("id").asString()); return createdPolicy.new Info(responseJSON); }
[ "private", "static", "BoxRetentionPolicy", ".", "Info", "createRetentionPolicy", "(", "BoxAPIConnection", "api", ",", "String", "name", ",", "String", "type", ",", "int", "length", ",", "String", "action", ",", "RetentionPolicyParams", "optionalParams", ")", "{", "URL", "url", "=", "RETENTION_POLICIES_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "api", ",", "url", ",", "\"POST\"", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"policy_name\"", ",", "name", ")", ".", "add", "(", "\"policy_type\"", ",", "type", ")", ".", "add", "(", "\"disposition_action\"", ",", "action", ")", ";", "if", "(", "!", "type", ".", "equals", "(", "TYPE_INDEFINITE", ")", ")", "{", "requestJSON", ".", "add", "(", "\"retention_length\"", ",", "length", ")", ";", "}", "if", "(", "optionalParams", "!=", "null", ")", "{", "requestJSON", ".", "add", "(", "\"can_owner_extend_retention\"", ",", "optionalParams", ".", "getCanOwnerExtendRetention", "(", ")", ")", ";", "requestJSON", ".", "add", "(", "\"are_owners_notified\"", ",", "optionalParams", ".", "getAreOwnersNotified", "(", ")", ")", ";", "List", "<", "BoxUser", ".", "Info", ">", "customNotificationRecipients", "=", "optionalParams", ".", "getCustomNotificationRecipients", "(", ")", ";", "if", "(", "customNotificationRecipients", ".", "size", "(", ")", ">", "0", ")", "{", "JsonArray", "users", "=", "new", "JsonArray", "(", ")", ";", "for", "(", "BoxUser", ".", "Info", "user", ":", "customNotificationRecipients", ")", "{", "JsonObject", "userJSON", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"type\"", ",", "\"user\"", ")", ".", "add", "(", "\"id\"", ",", "user", ".", "getID", "(", ")", ")", ";", "users", ".", "add", "(", "userJSON", ")", ";", "}", "requestJSON", ".", "add", "(", "\"custom_notification_recipients\"", ",", "users", ")", ";", "}", "}", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxRetentionPolicy", "createdPolicy", "=", "new", "BoxRetentionPolicy", "(", "api", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "createdPolicy", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Used to create a new retention policy with optional parameters. @param api the API connection to be used by the created user. @param name the name of the retention policy. @param type the type of the retention policy. Can be "finite" or "indefinite". @param length the duration in days that the retention policy will be active for after being assigned to content. @param action the disposition action can be "permanently_delete" or "remove_retention". @param optionalParams the optional parameters. @return the created retention policy's info.
[ "Used", "to", "create", "a", "new", "retention", "policy", "with", "optional", "parameters", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L160-L193
163,494
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getFolderAssignments
public Iterable<BoxRetentionPolicyAssignment.Info> getFolderAssignments(int limit, String ... fields) { return this.getAssignments(BoxRetentionPolicyAssignment.TYPE_FOLDER, limit, fields); }
java
public Iterable<BoxRetentionPolicyAssignment.Info> getFolderAssignments(int limit, String ... fields) { return this.getAssignments(BoxRetentionPolicyAssignment.TYPE_FOLDER, limit, fields); }
[ "public", "Iterable", "<", "BoxRetentionPolicyAssignment", ".", "Info", ">", "getFolderAssignments", "(", "int", "limit", ",", "String", "...", "fields", ")", "{", "return", "this", ".", "getAssignments", "(", "BoxRetentionPolicyAssignment", ".", "TYPE_FOLDER", ",", "limit", ",", "fields", ")", ";", "}" ]
Returns iterable with all folder assignments of this retention policy. @param limit the limit of entries per response. The default value is 100. @param fields the fields to retrieve. @return an iterable containing all folder assignments.
[ "Returns", "iterable", "with", "all", "folder", "assignments", "of", "this", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L210-L212
163,495
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getEnterpriseAssignments
public Iterable<BoxRetentionPolicyAssignment.Info> getEnterpriseAssignments(int limit, String ... fields) { return this.getAssignments(BoxRetentionPolicyAssignment.TYPE_ENTERPRISE, limit, fields); }
java
public Iterable<BoxRetentionPolicyAssignment.Info> getEnterpriseAssignments(int limit, String ... fields) { return this.getAssignments(BoxRetentionPolicyAssignment.TYPE_ENTERPRISE, limit, fields); }
[ "public", "Iterable", "<", "BoxRetentionPolicyAssignment", ".", "Info", ">", "getEnterpriseAssignments", "(", "int", "limit", ",", "String", "...", "fields", ")", "{", "return", "this", ".", "getAssignments", "(", "BoxRetentionPolicyAssignment", ".", "TYPE_ENTERPRISE", ",", "limit", ",", "fields", ")", ";", "}" ]
Returns iterable with all enterprise assignments of this retention policy. @param limit the limit of entries per response. The default value is 100. @param fields the fields to retrieve. @return an iterable containing all enterprise assignments.
[ "Returns", "iterable", "with", "all", "enterprise", "assignments", "of", "this", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L229-L231
163,496
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getAllAssignments
public Iterable<BoxRetentionPolicyAssignment.Info> getAllAssignments(int limit, String ... fields) { return this.getAssignments(null, limit, fields); }
java
public Iterable<BoxRetentionPolicyAssignment.Info> getAllAssignments(int limit, String ... fields) { return this.getAssignments(null, limit, fields); }
[ "public", "Iterable", "<", "BoxRetentionPolicyAssignment", ".", "Info", ">", "getAllAssignments", "(", "int", "limit", ",", "String", "...", "fields", ")", "{", "return", "this", ".", "getAssignments", "(", "null", ",", "limit", ",", "fields", ")", ";", "}" ]
Returns iterable with all assignments of this retention policy. @param limit the limit of entries per response. The default value is 100. @param fields the fields to retrieve. @return an iterable containing all assignments.
[ "Returns", "iterable", "with", "all", "assignments", "of", "this", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L248-L250
163,497
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getAssignments
private Iterable<BoxRetentionPolicyAssignment.Info> getAssignments(String type, int limit, String ... fields) { QueryStringBuilder queryString = new QueryStringBuilder(); if (type != null) { queryString.appendParam("type", type); } if (fields.length > 0) { queryString.appendParam("fields", fields); } URL url = ASSIGNMENTS_URL_TEMPLATE.buildWithQuery(getAPI().getBaseURL(), queryString.toString(), getID()); return new BoxResourceIterable<BoxRetentionPolicyAssignment.Info>(getAPI(), url, limit) { @Override protected BoxRetentionPolicyAssignment.Info factory(JsonObject jsonObject) { BoxRetentionPolicyAssignment assignment = new BoxRetentionPolicyAssignment(getAPI(), jsonObject.get("id").asString()); return assignment.new Info(jsonObject); } }; }
java
private Iterable<BoxRetentionPolicyAssignment.Info> getAssignments(String type, int limit, String ... fields) { QueryStringBuilder queryString = new QueryStringBuilder(); if (type != null) { queryString.appendParam("type", type); } if (fields.length > 0) { queryString.appendParam("fields", fields); } URL url = ASSIGNMENTS_URL_TEMPLATE.buildWithQuery(getAPI().getBaseURL(), queryString.toString(), getID()); return new BoxResourceIterable<BoxRetentionPolicyAssignment.Info>(getAPI(), url, limit) { @Override protected BoxRetentionPolicyAssignment.Info factory(JsonObject jsonObject) { BoxRetentionPolicyAssignment assignment = new BoxRetentionPolicyAssignment(getAPI(), jsonObject.get("id").asString()); return assignment.new Info(jsonObject); } }; }
[ "private", "Iterable", "<", "BoxRetentionPolicyAssignment", ".", "Info", ">", "getAssignments", "(", "String", "type", ",", "int", "limit", ",", "String", "...", "fields", ")", "{", "QueryStringBuilder", "queryString", "=", "new", "QueryStringBuilder", "(", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "queryString", ".", "appendParam", "(", "\"type\"", ",", "type", ")", ";", "}", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "queryString", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ";", "}", "URL", "url", "=", "ASSIGNMENTS_URL_TEMPLATE", ".", "buildWithQuery", "(", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "queryString", ".", "toString", "(", ")", ",", "getID", "(", ")", ")", ";", "return", "new", "BoxResourceIterable", "<", "BoxRetentionPolicyAssignment", ".", "Info", ">", "(", "getAPI", "(", ")", ",", "url", ",", "limit", ")", "{", "@", "Override", "protected", "BoxRetentionPolicyAssignment", ".", "Info", "factory", "(", "JsonObject", "jsonObject", ")", "{", "BoxRetentionPolicyAssignment", "assignment", "=", "new", "BoxRetentionPolicyAssignment", "(", "getAPI", "(", ")", ",", "jsonObject", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "assignment", ".", "new", "Info", "(", "jsonObject", ")", ";", "}", "}", ";", "}" ]
Returns iterable with all assignments of given type of this retention policy. @param type the type of the retention policy assignment to retrieve. Can either be "folder" or "enterprise". @param limit the limit of entries per response. The default value is 100. @param fields the fields to retrieve. @return an iterable containing all assignments of given type.
[ "Returns", "iterable", "with", "all", "assignments", "of", "given", "type", "of", "this", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L259-L278
163,498
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.assignTo
public BoxRetentionPolicyAssignment.Info assignTo(BoxFolder folder) { return BoxRetentionPolicyAssignment.createAssignmentToFolder(this.getAPI(), this.getID(), folder.getID()); }
java
public BoxRetentionPolicyAssignment.Info assignTo(BoxFolder folder) { return BoxRetentionPolicyAssignment.createAssignmentToFolder(this.getAPI(), this.getID(), folder.getID()); }
[ "public", "BoxRetentionPolicyAssignment", ".", "Info", "assignTo", "(", "BoxFolder", "folder", ")", "{", "return", "BoxRetentionPolicyAssignment", ".", "createAssignmentToFolder", "(", "this", ".", "getAPI", "(", ")", ",", "this", ".", "getID", "(", ")", ",", "folder", ".", "getID", "(", ")", ")", ";", "}" ]
Assigns this retention policy to folder. @param folder the folder to assign policy to. @return info about created assignment.
[ "Assigns", "this", "retention", "policy", "to", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L285-L287
163,499
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.assignToMetadataTemplate
public BoxRetentionPolicyAssignment.Info assignToMetadataTemplate(String templateID, MetadataFieldFilter... fieldFilters) { return BoxRetentionPolicyAssignment.createAssignmentToMetadata(this.getAPI(), this.getID(), templateID, fieldFilters); }
java
public BoxRetentionPolicyAssignment.Info assignToMetadataTemplate(String templateID, MetadataFieldFilter... fieldFilters) { return BoxRetentionPolicyAssignment.createAssignmentToMetadata(this.getAPI(), this.getID(), templateID, fieldFilters); }
[ "public", "BoxRetentionPolicyAssignment", ".", "Info", "assignToMetadataTemplate", "(", "String", "templateID", ",", "MetadataFieldFilter", "...", "fieldFilters", ")", "{", "return", "BoxRetentionPolicyAssignment", ".", "createAssignmentToMetadata", "(", "this", ".", "getAPI", "(", ")", ",", "this", ".", "getID", "(", ")", ",", "templateID", ",", "fieldFilters", ")", ";", "}" ]
Assigns this retention policy to a metadata template, optionally with certain field values. @param templateID the ID of the metadata template to apply to. @param fieldFilters optional field value filters. @return info about the created assignment.
[ "Assigns", "this", "retention", "policy", "to", "a", "metadata", "template", "optionally", "with", "certain", "field", "values", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L303-L307