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
3,100
rythmengine/rythmengine
src/main/java/org/rythmengine/internal/Token.java
Token.stripOuterBrackets
private static String stripOuterBrackets(String s) { try { if (S.isEmpty(s)) return s; if (R_.search(s)) { // strip out the outer brackets s = R_.stringMatched(); s = s.substring(1); s = s.substring(0, s.length() - 1); } } catch (RuntimeException re) { // this unfortunately happens - so at least make it debuggable throw re; } return s; }
java
private static String stripOuterBrackets(String s) { try { if (S.isEmpty(s)) return s; if (R_.search(s)) { // strip out the outer brackets s = R_.stringMatched(); s = s.substring(1); s = s.substring(0, s.length() - 1); } } catch (RuntimeException re) { // this unfortunately happens - so at least make it debuggable throw re; } return s; }
[ "private", "static", "String", "stripOuterBrackets", "(", "String", "s", ")", "{", "try", "{", "if", "(", "S", ".", "isEmpty", "(", "s", ")", ")", "return", "s", ";", "if", "(", "R_", ".", "search", "(", "s", ")", ")", "{", "// strip out the outer brackets", "s", "=", "R_", ".", "stringMatched", "(", ")", ";", "s", "=", "s", ".", "substring", "(", "1", ")", ";", "s", "=", "s", ".", "substring", "(", "0", ",", "s", ".", "length", "(", ")", "-", "1", ")", ";", "}", "}", "catch", "(", "RuntimeException", "re", ")", "{", "// this unfortunately happens - so at least make it debuggable", "throw", "re", ";", "}", "return", "s", ";", "}" ]
strip the outer brackets of the given string s @param s @return - the stripped string
[ "strip", "the", "outer", "brackets", "of", "the", "given", "string", "s" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/internal/Token.java#L210-L226
3,101
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/stp/services/desktop/ScopeDesktopWindowManager.java
ScopeDesktopWindowManager.getQuickWidget
public QuickWidget getQuickWidget(QuickWidgetType type, int windowId, QuickWidgetSearchType property, String value, String parentName) { if (windowId < 0) { windowId = getActiveQuickWindowId(); } List<QuickWidget> widgets = getQuickWidgetList(windowId); for (QuickWidget widget : widgets) { if (widget.getType() == type) { if (property.equals(QuickWidgetSearchType.NAME)) { if ((parentName.length() == 0 || widget.getParentName().equals(parentName)) && widget.getName().equals(value)) { return widget; } } else if (property.equals(QuickWidgetSearchType.TEXT)) { if ((parentName.length() == 0 || widget.getParentName().equals(parentName)) && WatirUtils.textMatchesWithANY(widget.getText(), value)) { return widget; } } } } return null; }
java
public QuickWidget getQuickWidget(QuickWidgetType type, int windowId, QuickWidgetSearchType property, String value, String parentName) { if (windowId < 0) { windowId = getActiveQuickWindowId(); } List<QuickWidget> widgets = getQuickWidgetList(windowId); for (QuickWidget widget : widgets) { if (widget.getType() == type) { if (property.equals(QuickWidgetSearchType.NAME)) { if ((parentName.length() == 0 || widget.getParentName().equals(parentName)) && widget.getName().equals(value)) { return widget; } } else if (property.equals(QuickWidgetSearchType.TEXT)) { if ((parentName.length() == 0 || widget.getParentName().equals(parentName)) && WatirUtils.textMatchesWithANY(widget.getText(), value)) { return widget; } } } } return null; }
[ "public", "QuickWidget", "getQuickWidget", "(", "QuickWidgetType", "type", ",", "int", "windowId", ",", "QuickWidgetSearchType", "property", ",", "String", "value", ",", "String", "parentName", ")", "{", "if", "(", "windowId", "<", "0", ")", "{", "windowId", "=", "getActiveQuickWindowId", "(", ")", ";", "}", "List", "<", "QuickWidget", ">", "widgets", "=", "getQuickWidgetList", "(", "windowId", ")", ";", "for", "(", "QuickWidget", "widget", ":", "widgets", ")", "{", "if", "(", "widget", ".", "getType", "(", ")", "==", "type", ")", "{", "if", "(", "property", ".", "equals", "(", "QuickWidgetSearchType", ".", "NAME", ")", ")", "{", "if", "(", "(", "parentName", ".", "length", "(", ")", "==", "0", "||", "widget", ".", "getParentName", "(", ")", ".", "equals", "(", "parentName", ")", ")", "&&", "widget", ".", "getName", "(", ")", ".", "equals", "(", "value", ")", ")", "{", "return", "widget", ";", "}", "}", "else", "if", "(", "property", ".", "equals", "(", "QuickWidgetSearchType", ".", "TEXT", ")", ")", "{", "if", "(", "(", "parentName", ".", "length", "(", ")", "==", "0", "||", "widget", ".", "getParentName", "(", ")", ".", "equals", "(", "parentName", ")", ")", "&&", "WatirUtils", ".", "textMatchesWithANY", "(", "widget", ".", "getText", "(", ")", ",", "value", ")", ")", "{", "return", "widget", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
parentName is set to name, pos or text depending on widget.getParentType
[ "parentName", "is", "set", "to", "name", "pos", "or", "text", "depending", "on", "widget", ".", "getParentType" ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/stp/services/desktop/ScopeDesktopWindowManager.java#L171-L197
3,102
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/stp/services/desktop/ScopeDesktopWindowManager.java
ScopeDesktopWindowManager.getQuickMenuItemByAction
public QuickMenuItem getQuickMenuItemByAction(String action) { List<QuickMenuItem> itemList = getQuickMenuItemList(); for (QuickMenuItem item : itemList) { if (item.getActionName().equals(action)) { return item; } } return null; }
java
public QuickMenuItem getQuickMenuItemByAction(String action) { List<QuickMenuItem> itemList = getQuickMenuItemList(); for (QuickMenuItem item : itemList) { if (item.getActionName().equals(action)) { return item; } } return null; }
[ "public", "QuickMenuItem", "getQuickMenuItemByAction", "(", "String", "action", ")", "{", "List", "<", "QuickMenuItem", ">", "itemList", "=", "getQuickMenuItemList", "(", ")", ";", "for", "(", "QuickMenuItem", "item", ":", "itemList", ")", "{", "if", "(", "item", ".", "getActionName", "(", ")", ".", "equals", "(", "action", ")", ")", "{", "return", "item", ";", "}", "}", "return", "null", ";", "}" ]
and unique within a single menu given either shortcutletter or pos
[ "and", "unique", "within", "a", "single", "menu", "given", "either", "shortcutletter", "or", "pos" ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/stp/services/desktop/ScopeDesktopWindowManager.java#L325-L335
3,103
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/ScopeServices.java
ScopeServices.init
public void init() { waitForHandshake(); availableServices = buildAvailableServices(getHostInfo()); connect(); // We always need a debugger, and it should never be included in the set of required services if (OperaDefaults.ENABLE_DEBUGGER && !(requiredServices.contains(ScopeService.ECMASCRIPT) || requiredServices.contains(ScopeService.ECMASCRIPT_DEBUGGER))) { if (availableServices.containsKey(ScopeService.ECMASCRIPT)) { requiredServices.add(ScopeService.ECMASCRIPT); } else { requiredServices.add(ScopeService.ECMASCRIPT_DEBUGGER); } } else { debugger = new MockEcmascriptDebugger(); } services = createServices(requiredServices); enableServices(services.values()); initializeServices(services.values()); }
java
public void init() { waitForHandshake(); availableServices = buildAvailableServices(getHostInfo()); connect(); // We always need a debugger, and it should never be included in the set of required services if (OperaDefaults.ENABLE_DEBUGGER && !(requiredServices.contains(ScopeService.ECMASCRIPT) || requiredServices.contains(ScopeService.ECMASCRIPT_DEBUGGER))) { if (availableServices.containsKey(ScopeService.ECMASCRIPT)) { requiredServices.add(ScopeService.ECMASCRIPT); } else { requiredServices.add(ScopeService.ECMASCRIPT_DEBUGGER); } } else { debugger = new MockEcmascriptDebugger(); } services = createServices(requiredServices); enableServices(services.values()); initializeServices(services.values()); }
[ "public", "void", "init", "(", ")", "{", "waitForHandshake", "(", ")", ";", "availableServices", "=", "buildAvailableServices", "(", "getHostInfo", "(", ")", ")", ";", "connect", "(", ")", ";", "// We always need a debugger, and it should never be included in the set of required services", "if", "(", "OperaDefaults", ".", "ENABLE_DEBUGGER", "&&", "!", "(", "requiredServices", ".", "contains", "(", "ScopeService", ".", "ECMASCRIPT", ")", "||", "requiredServices", ".", "contains", "(", "ScopeService", ".", "ECMASCRIPT_DEBUGGER", ")", ")", ")", "{", "if", "(", "availableServices", ".", "containsKey", "(", "ScopeService", ".", "ECMASCRIPT", ")", ")", "{", "requiredServices", ".", "add", "(", "ScopeService", ".", "ECMASCRIPT", ")", ";", "}", "else", "{", "requiredServices", ".", "add", "(", "ScopeService", ".", "ECMASCRIPT_DEBUGGER", ")", ";", "}", "}", "else", "{", "debugger", "=", "new", "MockEcmascriptDebugger", "(", ")", ";", "}", "services", "=", "createServices", "(", "requiredServices", ")", ";", "enableServices", "(", "services", ".", "values", "(", ")", ")", ";", "initializeServices", "(", "services", ".", "values", "(", ")", ")", ";", "}" ]
Gets the supported services from Opera and calls methods to enable the ones we requested.
[ "Gets", "the", "supported", "services", "from", "Opera", "and", "calls", "methods", "to", "enable", "the", "ones", "we", "requested", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/ScopeServices.java#L119-L142
3,104
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/ScopeServices.java
ScopeServices.createServices
private Map<ScopeService, Service> createServices(final Set<ScopeService> services) { Map<ScopeService, Service> actualServices = Maps.newTreeMap(); for (ScopeService requiredService : services) { if (availableServices.containsKey(requiredService)) { for (ScopeService availableService : availableServices.keySet()) { if (availableService == requiredService) { actualServices.put(requiredService, requiredService.newInstance(this)); } } } } return actualServices; }
java
private Map<ScopeService, Service> createServices(final Set<ScopeService> services) { Map<ScopeService, Service> actualServices = Maps.newTreeMap(); for (ScopeService requiredService : services) { if (availableServices.containsKey(requiredService)) { for (ScopeService availableService : availableServices.keySet()) { if (availableService == requiredService) { actualServices.put(requiredService, requiredService.newInstance(this)); } } } } return actualServices; }
[ "private", "Map", "<", "ScopeService", ",", "Service", ">", "createServices", "(", "final", "Set", "<", "ScopeService", ">", "services", ")", "{", "Map", "<", "ScopeService", ",", "Service", ">", "actualServices", "=", "Maps", ".", "newTreeMap", "(", ")", ";", "for", "(", "ScopeService", "requiredService", ":", "services", ")", "{", "if", "(", "availableServices", ".", "containsKey", "(", "requiredService", ")", ")", "{", "for", "(", "ScopeService", "availableService", ":", "availableServices", ".", "keySet", "(", ")", ")", "{", "if", "(", "availableService", "==", "requiredService", ")", "{", "actualServices", ".", "put", "(", "requiredService", ",", "requiredService", ".", "newInstance", "(", "this", ")", ")", ";", "}", "}", "}", "}", "return", "actualServices", ";", "}" ]
Build and construct the given services. @param services a map of required services and their minimum version @return list of services actually created
[ "Build", "and", "construct", "the", "given", "services", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/ScopeServices.java#L163-L177
3,105
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/ScopeServices.java
ScopeServices.getHostInfo
private HostInfo getHostInfo() { Response response = executeMessage(ScopeMessage.HOST_INFO, null); try { return HostInfo.parseFrom(response.getPayload()); } catch (InvalidProtocolBufferException e) { throw new CommunicationException("Error while parsing host info", e); } }
java
private HostInfo getHostInfo() { Response response = executeMessage(ScopeMessage.HOST_INFO, null); try { return HostInfo.parseFrom(response.getPayload()); } catch (InvalidProtocolBufferException e) { throw new CommunicationException("Error while parsing host info", e); } }
[ "private", "HostInfo", "getHostInfo", "(", ")", "{", "Response", "response", "=", "executeMessage", "(", "ScopeMessage", ".", "HOST_INFO", ",", "null", ")", ";", "try", "{", "return", "HostInfo", ".", "parseFrom", "(", "response", ".", "getPayload", "(", ")", ")", ";", "}", "catch", "(", "InvalidProtocolBufferException", "e", ")", "{", "throw", "new", "CommunicationException", "(", "\"Error while parsing host info\"", ",", "e", ")", ";", "}", "}" ]
Gets information on available services and their versions from Opera. This includes the STP version, core version, platform, operating system, user agent string and a list of available services. @return information about the connected browser's debug capabilities
[ "Gets", "information", "on", "available", "services", "and", "their", "versions", "from", "Opera", ".", "This", "includes", "the", "STP", "version", "core", "version", "platform", "operating", "system", "user", "agent", "string", "and", "a", "list", "of", "available", "services", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/ScopeServices.java#L223-L231
3,106
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/ScopeServices.java
ScopeServices.connect
private void connect() { ClientInfo.Builder info = ClientInfo.newBuilder().setFormat("protobuf"); executeMessage(ScopeMessage.CONNECT, info); }
java
private void connect() { ClientInfo.Builder info = ClientInfo.newBuilder().setFormat("protobuf"); executeMessage(ScopeMessage.CONNECT, info); }
[ "private", "void", "connect", "(", ")", "{", "ClientInfo", ".", "Builder", "info", "=", "ClientInfo", ".", "newBuilder", "(", ")", ".", "setFormat", "(", "\"protobuf\"", ")", ";", "executeMessage", "(", "ScopeMessage", ".", "CONNECT", ",", "info", ")", ";", "}" ]
Connects and resets any settings and services that the client used earlier.
[ "Connects", "and", "resets", "any", "settings", "and", "services", "that", "the", "client", "used", "earlier", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/ScopeServices.java#L236-L239
3,107
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/ScopeServices.java
ScopeServices.waitForOperaIdle
public void waitForOperaIdle(long timeout) { logger.finest("idle: Waiting for (timeout = " + timeout + ")"); waitState.waitForOperaIdle(timeout); logger.finest("idle: Finished waiting"); }
java
public void waitForOperaIdle(long timeout) { logger.finest("idle: Waiting for (timeout = " + timeout + ")"); waitState.waitForOperaIdle(timeout); logger.finest("idle: Finished waiting"); }
[ "public", "void", "waitForOperaIdle", "(", "long", "timeout", ")", "{", "logger", ".", "finest", "(", "\"idle: Waiting for (timeout = \"", "+", "timeout", "+", "\")\"", ")", ";", "waitState", ".", "waitForOperaIdle", "(", "timeout", ")", ";", "logger", ".", "finest", "(", "\"idle: Finished waiting\"", ")", ";", "}" ]
Waits for an OperaIdle event before continuing. If captureOperaIdle() has been called since the last call of waitForOperaIdle(), and one or more OperaIdle events have occurred then this function will return immediately. After calling this function the capturing of OperaIdle events is disabled until the next call of captureOperaIdle() @param timeout Time in milliseconds to wait before aborting
[ "Waits", "for", "an", "OperaIdle", "event", "before", "continuing", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/ScopeServices.java#L441-L445
3,108
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/ScopeServices.java
ScopeServices.executeMessage
public Response executeMessage(Message message, Builder<?> builder) { return executeMessage(message, builder, OperaIntervals.RESPONSE_TIMEOUT.getMs()); }
java
public Response executeMessage(Message message, Builder<?> builder) { return executeMessage(message, builder, OperaIntervals.RESPONSE_TIMEOUT.getMs()); }
[ "public", "Response", "executeMessage", "(", "Message", "message", ",", "Builder", "<", "?", ">", "builder", ")", "{", "return", "executeMessage", "(", "message", ",", "builder", ",", "OperaIntervals", ".", "RESPONSE_TIMEOUT", ".", "getMs", "(", ")", ")", ";", "}" ]
Sends a message and wait for the response.
[ "Sends", "a", "message", "and", "wait", "for", "the", "response", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/ScopeServices.java#L581-L584
3,109
operasoftware/operaprestodriver
src/com/opera/core/systems/runner/launcher/OperaLauncherProtocol.java
OperaLauncherProtocol.sendRequest
public ResponseEncapsulation sendRequest(MessageType type, byte[] body) throws IOException { sendRequestHeader(type, (body != null) ? body.length : 0); if (body != null) { os.write(body); } return recvMessage(); }
java
public ResponseEncapsulation sendRequest(MessageType type, byte[] body) throws IOException { sendRequestHeader(type, (body != null) ? body.length : 0); if (body != null) { os.write(body); } return recvMessage(); }
[ "public", "ResponseEncapsulation", "sendRequest", "(", "MessageType", "type", ",", "byte", "[", "]", "body", ")", "throws", "IOException", "{", "sendRequestHeader", "(", "type", ",", "(", "body", "!=", "null", ")", "?", "body", ".", "length", ":", "0", ")", ";", "if", "(", "body", "!=", "null", ")", "{", "os", ".", "write", "(", "body", ")", ";", "}", "return", "recvMessage", "(", ")", ";", "}" ]
Send a request and receive a result. @param type the request type to be sent @param body the serialized request payload @return the response @throws IOException if socket read error or protocol parse error
[ "Send", "a", "request", "and", "receive", "a", "result", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/runner/launcher/OperaLauncherProtocol.java#L148-L154
3,110
operasoftware/operaprestodriver
src/com/opera/core/systems/runner/launcher/OperaLauncherProtocol.java
OperaLauncherProtocol.sendRequestWithoutResponse
public void sendRequestWithoutResponse(MessageType type, byte[] body) throws IOException { sendRequestHeader(type, (body != null) ? body.length : 0); if (body != null) { os.write(body); } }
java
public void sendRequestWithoutResponse(MessageType type, byte[] body) throws IOException { sendRequestHeader(type, (body != null) ? body.length : 0); if (body != null) { os.write(body); } }
[ "public", "void", "sendRequestWithoutResponse", "(", "MessageType", "type", ",", "byte", "[", "]", "body", ")", "throws", "IOException", "{", "sendRequestHeader", "(", "type", ",", "(", "body", "!=", "null", ")", "?", "body", ".", "length", ":", "0", ")", ";", "if", "(", "body", "!=", "null", ")", "{", "os", ".", "write", "(", "body", ")", ";", "}", "}" ]
Send a request without a response. Used for shutdown. @param type the request type to be sent @param body the serialized request payload @throws IOException if socket read error or protocol parse error
[ "Send", "a", "request", "without", "a", "response", ".", "Used", "for", "shutdown", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/runner/launcher/OperaLauncherProtocol.java#L163-L168
3,111
operasoftware/operaprestodriver
src/com/opera/core/systems/runner/launcher/OperaLauncherProtocol.java
OperaLauncherProtocol.recvMessage
private ResponseEncapsulation recvMessage() throws IOException { GeneratedMessage msg = null; byte[] headers = new byte[8]; recv(headers, headers.length); if (headers[0] != 'L' || headers[1] != '1') { throw new IOException("Wrong launcher protocol header"); } ByteBuffer buf = ByteBuffer.allocate(4); buf.order(ByteOrder.BIG_ENDIAN); buf.put(headers, 4, 4); buf.flip(); int size = buf.getInt(); logger.finest("RECV: type=" + ((int) headers[3]) + ", command=" + ((int) headers[2]) + ", size=" + size); byte[] data = new byte[size]; recv(data, size); boolean success = (headers[3] == (byte) 1); MessageType type = MessageType.get(headers[2]); if (type == null) { throw new IOException("Unable to determine message type"); } if ((headers[3] != (byte) 1) && (headers[3] != (byte) 2)) { throw new IOException("Unable to determine success or error"); } switch (type) { case MSG_HELLO: { LauncherHandshakeResponse.Builder response = LauncherHandshakeResponse.newBuilder(); buildMessage(response, data); msg = response.build(); break; } case MSG_START: case MSG_STATUS: case MSG_STOP: { LauncherStatusResponse.Builder response = LauncherStatusResponse.newBuilder(); buildMessage(response, data); msg = response.build(); break; } case MSG_SCREENSHOT: { LauncherScreenshotResponse.Builder response = LauncherScreenshotResponse.newBuilder(); buildMessage(response, data); msg = response.build(); break; } } return new ResponseEncapsulation(success, msg); }
java
private ResponseEncapsulation recvMessage() throws IOException { GeneratedMessage msg = null; byte[] headers = new byte[8]; recv(headers, headers.length); if (headers[0] != 'L' || headers[1] != '1') { throw new IOException("Wrong launcher protocol header"); } ByteBuffer buf = ByteBuffer.allocate(4); buf.order(ByteOrder.BIG_ENDIAN); buf.put(headers, 4, 4); buf.flip(); int size = buf.getInt(); logger.finest("RECV: type=" + ((int) headers[3]) + ", command=" + ((int) headers[2]) + ", size=" + size); byte[] data = new byte[size]; recv(data, size); boolean success = (headers[3] == (byte) 1); MessageType type = MessageType.get(headers[2]); if (type == null) { throw new IOException("Unable to determine message type"); } if ((headers[3] != (byte) 1) && (headers[3] != (byte) 2)) { throw new IOException("Unable to determine success or error"); } switch (type) { case MSG_HELLO: { LauncherHandshakeResponse.Builder response = LauncherHandshakeResponse.newBuilder(); buildMessage(response, data); msg = response.build(); break; } case MSG_START: case MSG_STATUS: case MSG_STOP: { LauncherStatusResponse.Builder response = LauncherStatusResponse.newBuilder(); buildMessage(response, data); msg = response.build(); break; } case MSG_SCREENSHOT: { LauncherScreenshotResponse.Builder response = LauncherScreenshotResponse.newBuilder(); buildMessage(response, data); msg = response.build(); break; } } return new ResponseEncapsulation(success, msg); }
[ "private", "ResponseEncapsulation", "recvMessage", "(", ")", "throws", "IOException", "{", "GeneratedMessage", "msg", "=", "null", ";", "byte", "[", "]", "headers", "=", "new", "byte", "[", "8", "]", ";", "recv", "(", "headers", ",", "headers", ".", "length", ")", ";", "if", "(", "headers", "[", "0", "]", "!=", "'", "'", "||", "headers", "[", "1", "]", "!=", "'", "'", ")", "{", "throw", "new", "IOException", "(", "\"Wrong launcher protocol header\"", ")", ";", "}", "ByteBuffer", "buf", "=", "ByteBuffer", ".", "allocate", "(", "4", ")", ";", "buf", ".", "order", "(", "ByteOrder", ".", "BIG_ENDIAN", ")", ";", "buf", ".", "put", "(", "headers", ",", "4", ",", "4", ")", ";", "buf", ".", "flip", "(", ")", ";", "int", "size", "=", "buf", ".", "getInt", "(", ")", ";", "logger", ".", "finest", "(", "\"RECV: type=\"", "+", "(", "(", "int", ")", "headers", "[", "3", "]", ")", "+", "\", command=\"", "+", "(", "(", "int", ")", "headers", "[", "2", "]", ")", "+", "\", size=\"", "+", "size", ")", ";", "byte", "[", "]", "data", "=", "new", "byte", "[", "size", "]", ";", "recv", "(", "data", ",", "size", ")", ";", "boolean", "success", "=", "(", "headers", "[", "3", "]", "==", "(", "byte", ")", "1", ")", ";", "MessageType", "type", "=", "MessageType", ".", "get", "(", "headers", "[", "2", "]", ")", ";", "if", "(", "type", "==", "null", ")", "{", "throw", "new", "IOException", "(", "\"Unable to determine message type\"", ")", ";", "}", "if", "(", "(", "headers", "[", "3", "]", "!=", "(", "byte", ")", "1", ")", "&&", "(", "headers", "[", "3", "]", "!=", "(", "byte", ")", "2", ")", ")", "{", "throw", "new", "IOException", "(", "\"Unable to determine success or error\"", ")", ";", "}", "switch", "(", "type", ")", "{", "case", "MSG_HELLO", ":", "{", "LauncherHandshakeResponse", ".", "Builder", "response", "=", "LauncherHandshakeResponse", ".", "newBuilder", "(", ")", ";", "buildMessage", "(", "response", ",", "data", ")", ";", "msg", "=", "response", ".", "build", "(", ")", ";", "break", ";", "}", "case", "MSG_START", ":", "case", "MSG_STATUS", ":", "case", "MSG_STOP", ":", "{", "LauncherStatusResponse", ".", "Builder", "response", "=", "LauncherStatusResponse", ".", "newBuilder", "(", ")", ";", "buildMessage", "(", "response", ",", "data", ")", ";", "msg", "=", "response", ".", "build", "(", ")", ";", "break", ";", "}", "case", "MSG_SCREENSHOT", ":", "{", "LauncherScreenshotResponse", ".", "Builder", "response", "=", "LauncherScreenshotResponse", ".", "newBuilder", "(", ")", ";", "buildMessage", "(", "response", ",", "data", ")", ";", "msg", "=", "response", ".", "build", "(", ")", ";", "break", ";", "}", "}", "return", "new", "ResponseEncapsulation", "(", "success", ",", "msg", ")", ";", "}" ]
Receive a message response. @return Response body and request status code @throws IOException if socket read error or protocol parse error
[ "Receive", "a", "message", "response", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/runner/launcher/OperaLauncherProtocol.java#L196-L256
3,112
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaWebElement.java
OperaWebElement.callMethod
public final String callMethod(String method) { parent.assertConnected(); return debugger.callFunctionOnObject(method, objectId); }
java
public final String callMethod(String method) { parent.assertConnected(); return debugger.callFunctionOnObject(method, objectId); }
[ "public", "final", "String", "callMethod", "(", "String", "method", ")", "{", "parent", ".", "assertConnected", "(", ")", ";", "return", "debugger", ".", "callFunctionOnObject", "(", "method", ",", "objectId", ")", ";", "}" ]
Calls the method and parses the result, the result must be a string @param method the method to call @return response of ECMAScript in string presentation
[ "Calls", "the", "method", "and", "parses", "the", "result", "the", "result", "must", "be", "a", "string" ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaWebElement.java#L93-L96
3,113
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaWebElement.java
OperaWebElement.executeMethod
private void executeMethod(String script) { parent.assertConnected(); debugger.callFunctionOnObject(script, objectId, false); }
java
private void executeMethod(String script) { parent.assertConnected(); debugger.callFunctionOnObject(script, objectId, false); }
[ "private", "void", "executeMethod", "(", "String", "script", ")", "{", "parent", ".", "assertConnected", "(", ")", ";", "debugger", ".", "callFunctionOnObject", "(", "script", ",", "objectId", ",", "false", ")", ";", "}" ]
Executes the given script with the element's object ID, but does not parse the response. @param script the script to execute
[ "Executes", "the", "given", "script", "with", "the", "element", "s", "object", "ID", "but", "does", "not", "parse", "the", "response", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaWebElement.java#L103-L106
3,114
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaWebElement.java
OperaWebElement.middleClick
@Deprecated @SuppressWarnings("unused") public void middleClick() { // TODO(andreastt): Add this to Actions Point point = coordinates.inViewPort(); exec.mouseAction(point.x, point.y, OperaMouseKeys.MIDDLE); }
java
@Deprecated @SuppressWarnings("unused") public void middleClick() { // TODO(andreastt): Add this to Actions Point point = coordinates.inViewPort(); exec.mouseAction(point.x, point.y, OperaMouseKeys.MIDDLE); }
[ "@", "Deprecated", "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "void", "middleClick", "(", ")", "{", "// TODO(andreastt): Add this to Actions", "Point", "point", "=", "coordinates", ".", "inViewPort", "(", ")", ";", "exec", ".", "mouseAction", "(", "point", ".", "x", ",", "point", ".", "y", ",", "OperaMouseKeys", ".", "MIDDLE", ")", ";", "}" ]
Click the middle mouse button at the top left corner of the element. Will not verify whether element is available for interaction first. @deprecated
[ "Click", "the", "middle", "mouse", "button", "at", "the", "top", "left", "corner", "of", "the", "element", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaWebElement.java#L146-L151
3,115
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaWebElement.java
OperaWebElement.getLocation
public Point getLocation() { assertElementNotStale(); String coordinates = debugger.callFunctionOnObject("var coords = " + OperaAtom.GET_LOCATION + "(locator); return coords.x + ',' + coords.y;", objectId); // TODO: The goog.dom.getDocumentScrollElement_() function the Google closure library doesn't // return the document for SVG documents. This is used by the above atom. In this case the // coordinates string will be empty, so we use this fallback to get the coordinates. Hopefully // a fix will be forthcoming in the closure library. if (coordinates.isEmpty()) { logger.warning("Falling back to non-atom positioning code in getLocation"); coordinates = debugger.callFunctionOnObject("var coords = locator.getBoundingClientRect();" + "return (coords.left-window.pageXOffset)+','+(coords.top-window.pageYOffset)", objectId); } String[] location = coordinates.split(","); return new Point(Integer.valueOf(location[0]), Integer.valueOf(location[1])); }
java
public Point getLocation() { assertElementNotStale(); String coordinates = debugger.callFunctionOnObject("var coords = " + OperaAtom.GET_LOCATION + "(locator); return coords.x + ',' + coords.y;", objectId); // TODO: The goog.dom.getDocumentScrollElement_() function the Google closure library doesn't // return the document for SVG documents. This is used by the above atom. In this case the // coordinates string will be empty, so we use this fallback to get the coordinates. Hopefully // a fix will be forthcoming in the closure library. if (coordinates.isEmpty()) { logger.warning("Falling back to non-atom positioning code in getLocation"); coordinates = debugger.callFunctionOnObject("var coords = locator.getBoundingClientRect();" + "return (coords.left-window.pageXOffset)+','+(coords.top-window.pageYOffset)", objectId); } String[] location = coordinates.split(","); return new Point(Integer.valueOf(location[0]), Integer.valueOf(location[1])); }
[ "public", "Point", "getLocation", "(", ")", "{", "assertElementNotStale", "(", ")", ";", "String", "coordinates", "=", "debugger", ".", "callFunctionOnObject", "(", "\"var coords = \"", "+", "OperaAtom", ".", "GET_LOCATION", "+", "\"(locator); return coords.x + ',' + coords.y;\"", ",", "objectId", ")", ";", "// TODO: The goog.dom.getDocumentScrollElement_() function the Google closure library doesn't", "// return the document for SVG documents. This is used by the above atom. In this case the", "// coordinates string will be empty, so we use this fallback to get the coordinates. Hopefully", "// a fix will be forthcoming in the closure library.", "if", "(", "coordinates", ".", "isEmpty", "(", ")", ")", "{", "logger", ".", "warning", "(", "\"Falling back to non-atom positioning code in getLocation\"", ")", ";", "coordinates", "=", "debugger", ".", "callFunctionOnObject", "(", "\"var coords = locator.getBoundingClientRect();\"", "+", "\"return (coords.left-window.pageXOffset)+','+(coords.top-window.pageYOffset)\"", ",", "objectId", ")", ";", "}", "String", "[", "]", "location", "=", "coordinates", ".", "split", "(", "\",\"", ")", ";", "return", "new", "Point", "(", "Integer", ".", "valueOf", "(", "location", "[", "0", "]", ")", ",", "Integer", ".", "valueOf", "(", "location", "[", "1", "]", ")", ")", ";", "}" ]
Click top left, can be modified to click in the middle
[ "Click", "top", "left", "can", "be", "modified", "to", "click", "in", "the", "middle" ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaWebElement.java#L271-L292
3,116
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaWebElement.java
OperaWebElement.getImageHash
public String getImageHash(long timeout, List<String> hashes) { return saveScreenshot("", timeout, false, hashes); }
java
public String getImageHash(long timeout, List<String> hashes) { return saveScreenshot("", timeout, false, hashes); }
[ "public", "String", "getImageHash", "(", "long", "timeout", ",", "List", "<", "String", ">", "hashes", ")", "{", "return", "saveScreenshot", "(", "\"\"", ",", "timeout", ",", "false", ",", "hashes", ")", ";", "}" ]
Takes a screenshot after timeout milliseconds of the area this element's bounding-box covers and returns the MD5 hash. @param timeout the number of milliseconds to wait before taking the screenshot @param hashes optional hashes to compare the hashes with @return an MD5 hash as a string
[ "Takes", "a", "screenshot", "after", "timeout", "milliseconds", "of", "the", "area", "this", "element", "s", "bounding", "-", "box", "covers", "and", "returns", "the", "MD5", "hash", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaWebElement.java#L322-L324
3,117
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaWebElement.java
OperaWebElement.saveScreenshot
public String saveScreenshot(String filename, long timeout) { return saveScreenshot(filename, timeout, true, new ArrayList<String>()); }
java
public String saveScreenshot(String filename, long timeout) { return saveScreenshot(filename, timeout, true, new ArrayList<String>()); }
[ "public", "String", "saveScreenshot", "(", "String", "filename", ",", "long", "timeout", ")", "{", "return", "saveScreenshot", "(", "filename", ",", "timeout", ",", "true", ",", "new", "ArrayList", "<", "String", ">", "(", ")", ")", ";", "}" ]
Take a screenshot of the area this element covers. Saves a copy of the image to the given filename. @param filename the location to save the screenshot @param timeout the number of milliseconds to wait before taking the screenshot @return the MD5 hash of the screenshot
[ "Take", "a", "screenshot", "of", "the", "area", "this", "element", "covers", ".", "Saves", "a", "copy", "of", "the", "image", "to", "the", "given", "filename", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaWebElement.java#L345-L347
3,118
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaWebElement.java
OperaWebElement.saveScreenshot
public String saveScreenshot(String filename, long timeout, boolean includeImage, List<String> hashes) { assertElementNotStale(); Canvas canvas = buildCanvas(); ScreenCaptureReply reply = exec.screenWatcher(canvas, timeout, includeImage, hashes); if (includeImage && reply.getPng() != null) { FileChannel stream; try { stream = new FileOutputStream(filename).getChannel(); stream.write(ByteBuffer.wrap(reply.getPng())); stream.close(); } catch (IOException e) { throw new WebDriverException("Failed to write file: " + e.getMessage(), e); } } return reply.getMd5(); }
java
public String saveScreenshot(String filename, long timeout, boolean includeImage, List<String> hashes) { assertElementNotStale(); Canvas canvas = buildCanvas(); ScreenCaptureReply reply = exec.screenWatcher(canvas, timeout, includeImage, hashes); if (includeImage && reply.getPng() != null) { FileChannel stream; try { stream = new FileOutputStream(filename).getChannel(); stream.write(ByteBuffer.wrap(reply.getPng())); stream.close(); } catch (IOException e) { throw new WebDriverException("Failed to write file: " + e.getMessage(), e); } } return reply.getMd5(); }
[ "public", "String", "saveScreenshot", "(", "String", "filename", ",", "long", "timeout", ",", "boolean", "includeImage", ",", "List", "<", "String", ">", "hashes", ")", "{", "assertElementNotStale", "(", ")", ";", "Canvas", "canvas", "=", "buildCanvas", "(", ")", ";", "ScreenCaptureReply", "reply", "=", "exec", ".", "screenWatcher", "(", "canvas", ",", "timeout", ",", "includeImage", ",", "hashes", ")", ";", "if", "(", "includeImage", "&&", "reply", ".", "getPng", "(", ")", "!=", "null", ")", "{", "FileChannel", "stream", ";", "try", "{", "stream", "=", "new", "FileOutputStream", "(", "filename", ")", ".", "getChannel", "(", ")", ";", "stream", ".", "write", "(", "ByteBuffer", ".", "wrap", "(", "reply", ".", "getPng", "(", ")", ")", ")", ";", "stream", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "WebDriverException", "(", "\"Failed to write file: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}", "return", "reply", ".", "getMd5", "(", ")", ";", "}" ]
Take a screenshot of the area this element covers. If the hash of the image matches any of the given hashes then no image is saved, otherwise it saves a copy of the image to the given filename. @param filename the location to save the screenshot @param timeout the number of milliseconds to wait before taking the screenshot @param includeImage whether to get the image data. Disable if you just need the MD5 hash @param hashes known image hashes @return the MD5 hash of the screenshot
[ "Take", "a", "screenshot", "of", "the", "area", "this", "element", "covers", ".", "If", "the", "hash", "of", "the", "image", "matches", "any", "of", "the", "given", "hashes", "then", "no", "image", "is", "saved", "otherwise", "it", "saves", "a", "copy", "of", "the", "image", "to", "the", "given", "filename", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaWebElement.java#L360-L381
3,119
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaWebElement.java
OperaWebElement.containsColor
@SuppressWarnings("unused") @Deprecated public boolean containsColor(OperaColors... colors) { assertElementNotStale(); Canvas canvas = buildCanvas(); ScreenCaptureReply reply = exec.containsColor(canvas, 100L, colors); List<ColorResult> results = reply.getColorResults(); for (ColorResult result : results) { if (result.getCount() > 0) { return true; } } return false; }
java
@SuppressWarnings("unused") @Deprecated public boolean containsColor(OperaColors... colors) { assertElementNotStale(); Canvas canvas = buildCanvas(); ScreenCaptureReply reply = exec.containsColor(canvas, 100L, colors); List<ColorResult> results = reply.getColorResults(); for (ColorResult result : results) { if (result.getCount() > 0) { return true; } } return false; }
[ "@", "SuppressWarnings", "(", "\"unused\"", ")", "@", "Deprecated", "public", "boolean", "containsColor", "(", "OperaColors", "...", "colors", ")", "{", "assertElementNotStale", "(", ")", ";", "Canvas", "canvas", "=", "buildCanvas", "(", ")", ";", "ScreenCaptureReply", "reply", "=", "exec", ".", "containsColor", "(", "canvas", ",", "100L", ",", "colors", ")", ";", "List", "<", "ColorResult", ">", "results", "=", "reply", ".", "getColorResults", "(", ")", ";", "for", "(", "ColorResult", "result", ":", "results", ")", "{", "if", "(", "result", ".", "getCount", "(", ")", ">", "0", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if the current page contains any of the given colors. Used on tests that use red to show a failure. @param colors list of colors to check for @return true if the page contains any of the given colors, false otherwise @deprecated
[ "Check", "if", "the", "current", "page", "contains", "any", "of", "the", "given", "colors", ".", "Used", "on", "tests", "that", "use", "red", "to", "show", "a", "failure", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaWebElement.java#L405-L422
3,120
operasoftware/operaprestodriver
src/com/opera/core/systems/OperaWebElement.java
OperaWebElement.buildCanvas
private Canvas buildCanvas() { Canvas canvas = new Canvas(); Dimension dimension = getSize(); Point point = coordinates.inViewPort(); int x = point.x; int y = point.y; // Avoid internal error by making sure we have some width and height int w = Math.max(dimension.width, 1); int h = Math.max(dimension.height, 1); canvas.setX(x); canvas.setY(y); canvas.setHeight(h); canvas.setWidth(w); canvas.setViewPortRelative(true); return canvas; }
java
private Canvas buildCanvas() { Canvas canvas = new Canvas(); Dimension dimension = getSize(); Point point = coordinates.inViewPort(); int x = point.x; int y = point.y; // Avoid internal error by making sure we have some width and height int w = Math.max(dimension.width, 1); int h = Math.max(dimension.height, 1); canvas.setX(x); canvas.setY(y); canvas.setHeight(h); canvas.setWidth(w); canvas.setViewPortRelative(true); return canvas; }
[ "private", "Canvas", "buildCanvas", "(", ")", "{", "Canvas", "canvas", "=", "new", "Canvas", "(", ")", ";", "Dimension", "dimension", "=", "getSize", "(", ")", ";", "Point", "point", "=", "coordinates", ".", "inViewPort", "(", ")", ";", "int", "x", "=", "point", ".", "x", ";", "int", "y", "=", "point", ".", "y", ";", "// Avoid internal error by making sure we have some width and height", "int", "w", "=", "Math", ".", "max", "(", "dimension", ".", "width", ",", "1", ")", ";", "int", "h", "=", "Math", ".", "max", "(", "dimension", ".", "height", ",", "1", ")", ";", "canvas", ".", "setX", "(", "x", ")", ";", "canvas", ".", "setY", "(", "y", ")", ";", "canvas", ".", "setHeight", "(", "h", ")", ";", "canvas", ".", "setWidth", "(", "w", ")", ";", "canvas", ".", "setViewPortRelative", "(", "true", ")", ";", "return", "canvas", ";", "}" ]
Create a "canvas", which is an object that specifies a rectangle to take a screenshot of. @return a canvas representing the size and position of this element.
[ "Create", "a", "canvas", "which", "is", "an", "object", "that", "specifies", "a", "rectangle", "to", "take", "a", "screenshot", "of", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaWebElement.java#L429-L447
3,121
operasoftware/operaprestodriver
src/com/opera/core/systems/scope/stp/StpConnection.java
StpConnection.close
public void close() { if (socketChannel == null) { return; } monitor.remove(socketChannel); try { socketChannel.close(); } catch (IOException ignored) { /* nothing to be done */ } finally { socketChannel = null; } }
java
public void close() { if (socketChannel == null) { return; } monitor.remove(socketChannel); try { socketChannel.close(); } catch (IOException ignored) { /* nothing to be done */ } finally { socketChannel = null; } }
[ "public", "void", "close", "(", ")", "{", "if", "(", "socketChannel", "==", "null", ")", "{", "return", ";", "}", "monitor", ".", "remove", "(", "socketChannel", ")", ";", "try", "{", "socketChannel", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ignored", ")", "{", "/* nothing to be done */", "}", "finally", "{", "socketChannel", "=", "null", ";", "}", "}" ]
Switches the wait state and wakes up the selector to process.
[ "Switches", "the", "wait", "state", "and", "wakes", "up", "the", "selector", "to", "process", "." ]
1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/scope/stp/StpConnection.java#L303-L316
3,122
rythmengine/rythmengine
src/main/java/org/rythmengine/RythmEngine.java
RythmEngine._processConf
private Map<String, Object> _processConf(Map<String, ?> conf) { Map<String, Object> m = new HashMap<String, Object>(conf.size()); for (String s : conf.keySet()) { Object o = conf.get(s); if (s.startsWith("rythm.")) s = s.replaceFirst("rythm\\.", ""); m.put(s, o); } return m; }
java
private Map<String, Object> _processConf(Map<String, ?> conf) { Map<String, Object> m = new HashMap<String, Object>(conf.size()); for (String s : conf.keySet()) { Object o = conf.get(s); if (s.startsWith("rythm.")) s = s.replaceFirst("rythm\\.", ""); m.put(s, o); } return m; }
[ "private", "Map", "<", "String", ",", "Object", ">", "_processConf", "(", "Map", "<", "String", ",", "?", ">", "conf", ")", "{", "Map", "<", "String", ",", "Object", ">", "m", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", "conf", ".", "size", "(", ")", ")", ";", "for", "(", "String", "s", ":", "conf", ".", "keySet", "(", ")", ")", "{", "Object", "o", "=", "conf", ".", "get", "(", "s", ")", ";", "if", "(", "s", ".", "startsWith", "(", "\"rythm.\"", ")", ")", "s", "=", "s", ".", "replaceFirst", "(", "\"rythm\\\\.\"", ",", "\"\"", ")", ";", "m", ".", "put", "(", "s", ",", "o", ")", ";", "}", "return", "m", ";", "}" ]
trim "rythm." from conf keys
[ "trim", "rythm", ".", "from", "conf", "keys" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/RythmEngine.java#L486-L494
3,123
rythmengine/rythmengine
src/main/java/org/rythmengine/RythmEngine.java
RythmEngine.renderString
@SuppressWarnings("unchecked") public String renderString(String key, String template, Object... args) { boolean typeInferenceEnabled = conf().typeInferenceEnabled(); if (typeInferenceEnabled) { ParamTypeInferencer.registerParams(this, args); } if (typeInferenceEnabled) { key += ParamTypeInferencer.uuid(); } try { TemplateClass tc = classes().getByTemplate(key, false); if (null == tc) { tc = new TemplateClass(new StringTemplateResource(key, template), this); //classes().add(key, tc); } ITemplate t = tc.asTemplate(this); setRenderArgs(t, args); return t.render(); } finally { renderCleanUp(); } }
java
@SuppressWarnings("unchecked") public String renderString(String key, String template, Object... args) { boolean typeInferenceEnabled = conf().typeInferenceEnabled(); if (typeInferenceEnabled) { ParamTypeInferencer.registerParams(this, args); } if (typeInferenceEnabled) { key += ParamTypeInferencer.uuid(); } try { TemplateClass tc = classes().getByTemplate(key, false); if (null == tc) { tc = new TemplateClass(new StringTemplateResource(key, template), this); //classes().add(key, tc); } ITemplate t = tc.asTemplate(this); setRenderArgs(t, args); return t.render(); } finally { renderCleanUp(); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "String", "renderString", "(", "String", "key", ",", "String", "template", ",", "Object", "...", "args", ")", "{", "boolean", "typeInferenceEnabled", "=", "conf", "(", ")", ".", "typeInferenceEnabled", "(", ")", ";", "if", "(", "typeInferenceEnabled", ")", "{", "ParamTypeInferencer", ".", "registerParams", "(", "this", ",", "args", ")", ";", "}", "if", "(", "typeInferenceEnabled", ")", "{", "key", "+=", "ParamTypeInferencer", ".", "uuid", "(", ")", ";", "}", "try", "{", "TemplateClass", "tc", "=", "classes", "(", ")", ".", "getByTemplate", "(", "key", ",", "false", ")", ";", "if", "(", "null", "==", "tc", ")", "{", "tc", "=", "new", "TemplateClass", "(", "new", "StringTemplateResource", "(", "key", ",", "template", ")", ",", "this", ")", ";", "//classes().add(key, tc);", "}", "ITemplate", "t", "=", "tc", ".", "asTemplate", "(", "this", ")", ";", "setRenderArgs", "(", "t", ",", "args", ")", ";", "return", "t", ".", "render", "(", ")", ";", "}", "finally", "{", "renderCleanUp", "(", ")", ";", "}", "}" ]
Render result from a direct template content. The template key has been provided as well <p>See {@link #getTemplate(java.io.File, Object...)} for note on render args</p> @param key the template key which will be used to generate @param template the inline template content @param args the render args array @return render result
[ "Render", "result", "from", "a", "direct", "template", "content", ".", "The", "template", "key", "has", "been", "provided", "as", "well" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/RythmEngine.java#L1173-L1195
3,124
rythmengine/rythmengine
src/main/java/org/rythmengine/RythmEngine.java
RythmEngine.renderIfTemplateExists
public String renderIfTemplateExists(String template, Object... args) { boolean typeInferenceEnabled = conf().typeInferenceEnabled(); if (typeInferenceEnabled) { ParamTypeInferencer.registerParams(this, args); } if (nonExistsTemplates.contains(template)) return ""; String key = template; if (typeInferenceEnabled) { key += ParamTypeInferencer.uuid(); } try { TemplateClass tc = classes().getByTemplate(template); if (null == tc) { ITemplateResource rsrc = resourceManager().getResource(template); if (rsrc.isValid()) { tc = new TemplateClass(rsrc, this); //classes().add(key, tc); } else { nonExistsTemplates.add(template); if (isDevMode() && nonExistsTemplatesChecker == null) { nonExistsTemplatesChecker = new NonExistsTemplatesChecker(); } return ""; } } ITemplate t = tc.asTemplate(this); setRenderArgs(t, args); return t.render(); } finally { renderCleanUp(); } }
java
public String renderIfTemplateExists(String template, Object... args) { boolean typeInferenceEnabled = conf().typeInferenceEnabled(); if (typeInferenceEnabled) { ParamTypeInferencer.registerParams(this, args); } if (nonExistsTemplates.contains(template)) return ""; String key = template; if (typeInferenceEnabled) { key += ParamTypeInferencer.uuid(); } try { TemplateClass tc = classes().getByTemplate(template); if (null == tc) { ITemplateResource rsrc = resourceManager().getResource(template); if (rsrc.isValid()) { tc = new TemplateClass(rsrc, this); //classes().add(key, tc); } else { nonExistsTemplates.add(template); if (isDevMode() && nonExistsTemplatesChecker == null) { nonExistsTemplatesChecker = new NonExistsTemplatesChecker(); } return ""; } } ITemplate t = tc.asTemplate(this); setRenderArgs(t, args); return t.render(); } finally { renderCleanUp(); } }
[ "public", "String", "renderIfTemplateExists", "(", "String", "template", ",", "Object", "...", "args", ")", "{", "boolean", "typeInferenceEnabled", "=", "conf", "(", ")", ".", "typeInferenceEnabled", "(", ")", ";", "if", "(", "typeInferenceEnabled", ")", "{", "ParamTypeInferencer", ".", "registerParams", "(", "this", ",", "args", ")", ";", "}", "if", "(", "nonExistsTemplates", ".", "contains", "(", "template", ")", ")", "return", "\"\"", ";", "String", "key", "=", "template", ";", "if", "(", "typeInferenceEnabled", ")", "{", "key", "+=", "ParamTypeInferencer", ".", "uuid", "(", ")", ";", "}", "try", "{", "TemplateClass", "tc", "=", "classes", "(", ")", ".", "getByTemplate", "(", "template", ")", ";", "if", "(", "null", "==", "tc", ")", "{", "ITemplateResource", "rsrc", "=", "resourceManager", "(", ")", ".", "getResource", "(", "template", ")", ";", "if", "(", "rsrc", ".", "isValid", "(", ")", ")", "{", "tc", "=", "new", "TemplateClass", "(", "rsrc", ",", "this", ")", ";", "//classes().add(key, tc);", "}", "else", "{", "nonExistsTemplates", ".", "add", "(", "template", ")", ";", "if", "(", "isDevMode", "(", ")", "&&", "nonExistsTemplatesChecker", "==", "null", ")", "{", "nonExistsTemplatesChecker", "=", "new", "NonExistsTemplatesChecker", "(", ")", ";", "}", "return", "\"\"", ";", "}", "}", "ITemplate", "t", "=", "tc", ".", "asTemplate", "(", "this", ")", ";", "setRenderArgs", "(", "t", ",", "args", ")", ";", "return", "t", ".", "render", "(", ")", ";", "}", "finally", "{", "renderCleanUp", "(", ")", ";", "}", "}" ]
Render template if specified template exists, otherwise return empty string @param template the template source path @param args render args. See {@link #getTemplate(String, Object...)} @return render result
[ "Render", "template", "if", "specified", "template", "exists", "otherwise", "return", "empty", "string" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/RythmEngine.java#L1371-L1405
3,125
rythmengine/rythmengine
src/main/java/org/rythmengine/RythmEngine.java
RythmEngine.eval
public Object eval(String script) { // // use Java's ScriptEngine at the moment // ScriptEngineManager manager = new ScriptEngineManager(); // ScriptEngine jsEngine = manager.getEngineByName("JavaScript"); // try { // return jsEngine.eval(script); // } catch (ScriptException e) { // throw new RuntimeException(e); // } return eval(script, Collections.<String, Object>emptyMap()); }
java
public Object eval(String script) { // // use Java's ScriptEngine at the moment // ScriptEngineManager manager = new ScriptEngineManager(); // ScriptEngine jsEngine = manager.getEngineByName("JavaScript"); // try { // return jsEngine.eval(script); // } catch (ScriptException e) { // throw new RuntimeException(e); // } return eval(script, Collections.<String, Object>emptyMap()); }
[ "public", "Object", "eval", "(", "String", "script", ")", "{", "// // use Java's ScriptEngine at the moment", "// ScriptEngineManager manager = new ScriptEngineManager();", "// ScriptEngine jsEngine = manager.getEngineByName(\"JavaScript\");", "// try {", "// return jsEngine.eval(script);", "// } catch (ScriptException e) {", "// throw new RuntimeException(e);", "// }", "return", "eval", "(", "script", ",", "Collections", ".", "<", "String", ",", "Object", ">", "emptyMap", "(", ")", ")", ";", "}" ]
Evaluate a script and return executing result. Note the API is not mature yet don't use it in your application @param script @return the result
[ "Evaluate", "a", "script", "and", "return", "executing", "result", ".", "Note", "the", "API", "is", "not", "mature", "yet", "don", "t", "use", "it", "in", "your", "application" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/RythmEngine.java#L1418-L1428
3,126
rythmengine/rythmengine
src/main/java/org/rythmengine/RythmEngine.java
RythmEngine.invalidate
public void invalidate(TemplateClass parent) { if (mode().isProd()) return; Set<TemplateClass> children = extendMap.get(parent); if (null == children) return; for (TemplateClass child : children) { invalidate(child); child.reset(); } }
java
public void invalidate(TemplateClass parent) { if (mode().isProd()) return; Set<TemplateClass> children = extendMap.get(parent); if (null == children) return; for (TemplateClass child : children) { invalidate(child); child.reset(); } }
[ "public", "void", "invalidate", "(", "TemplateClass", "parent", ")", "{", "if", "(", "mode", "(", ")", ".", "isProd", "(", ")", ")", "return", ";", "Set", "<", "TemplateClass", ">", "children", "=", "extendMap", ".", "get", "(", "parent", ")", ";", "if", "(", "null", "==", "children", ")", "return", ";", "for", "(", "TemplateClass", "child", ":", "children", ")", "{", "invalidate", "(", "child", ")", ";", "child", ".", "reset", "(", ")", ";", "}", "}" ]
called to invalidate all template class which extends the parent
[ "called", "to", "invalidate", "all", "template", "class", "which", "extends", "the", "parent" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/RythmEngine.java#L1914-L1922
3,127
rythmengine/rythmengine
src/main/java/org/rythmengine/RythmEngine.java
RythmEngine.shutdown
public void shutdown() { if (zombie) { return; } logger.info("Shutting down Rythm Engine: [%s]", id()); if (null != _cacheService) { try { _cacheService.shutdown(); } catch (Exception e) { logger.error(e, "Error shutdown cache service"); } } if (null != _secureExecutor) { try { _secureExecutor.shutdown(); } catch (Exception e) { logger.error(e, "Error shutdown secure executor"); } } if (null != _resourceManager) { try { _resourceManager.shutdown(); } catch (Exception e) { logger.error(e, "Error shutdown resource manager"); } } if (null != shutdownListener) { try { shutdownListener.onShutdown(); } catch (Exception e) { logger.error(e, "Error execute shutdown listener"); } } if (null != nonExistsTemplatesChecker) { nonExistsTemplatesChecker.onShutdown(); } if (null != _templates) _templates.clear(); if (null != _classes) _classes.clear(); if (null != _nonExistsTags) _nonExistsTags.clear(); if (null != nonExistsTemplates) nonExistsTemplates.clear(); if (null != _nonTmpls) _nonTmpls.clear(); _classLoader = null; Rythm.RenderTime.clear(); zombie = true; }
java
public void shutdown() { if (zombie) { return; } logger.info("Shutting down Rythm Engine: [%s]", id()); if (null != _cacheService) { try { _cacheService.shutdown(); } catch (Exception e) { logger.error(e, "Error shutdown cache service"); } } if (null != _secureExecutor) { try { _secureExecutor.shutdown(); } catch (Exception e) { logger.error(e, "Error shutdown secure executor"); } } if (null != _resourceManager) { try { _resourceManager.shutdown(); } catch (Exception e) { logger.error(e, "Error shutdown resource manager"); } } if (null != shutdownListener) { try { shutdownListener.onShutdown(); } catch (Exception e) { logger.error(e, "Error execute shutdown listener"); } } if (null != nonExistsTemplatesChecker) { nonExistsTemplatesChecker.onShutdown(); } if (null != _templates) _templates.clear(); if (null != _classes) _classes.clear(); if (null != _nonExistsTags) _nonExistsTags.clear(); if (null != nonExistsTemplates) nonExistsTemplates.clear(); if (null != _nonTmpls) _nonTmpls.clear(); _classLoader = null; Rythm.RenderTime.clear(); zombie = true; }
[ "public", "void", "shutdown", "(", ")", "{", "if", "(", "zombie", ")", "{", "return", ";", "}", "logger", ".", "info", "(", "\"Shutting down Rythm Engine: [%s]\"", ",", "id", "(", ")", ")", ";", "if", "(", "null", "!=", "_cacheService", ")", "{", "try", "{", "_cacheService", ".", "shutdown", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "e", ",", "\"Error shutdown cache service\"", ")", ";", "}", "}", "if", "(", "null", "!=", "_secureExecutor", ")", "{", "try", "{", "_secureExecutor", ".", "shutdown", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "e", ",", "\"Error shutdown secure executor\"", ")", ";", "}", "}", "if", "(", "null", "!=", "_resourceManager", ")", "{", "try", "{", "_resourceManager", ".", "shutdown", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "e", ",", "\"Error shutdown resource manager\"", ")", ";", "}", "}", "if", "(", "null", "!=", "shutdownListener", ")", "{", "try", "{", "shutdownListener", ".", "onShutdown", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "e", ",", "\"Error execute shutdown listener\"", ")", ";", "}", "}", "if", "(", "null", "!=", "nonExistsTemplatesChecker", ")", "{", "nonExistsTemplatesChecker", ".", "onShutdown", "(", ")", ";", "}", "if", "(", "null", "!=", "_templates", ")", "_templates", ".", "clear", "(", ")", ";", "if", "(", "null", "!=", "_classes", ")", "_classes", ".", "clear", "(", ")", ";", "if", "(", "null", "!=", "_nonExistsTags", ")", "_nonExistsTags", ".", "clear", "(", ")", ";", "if", "(", "null", "!=", "nonExistsTemplates", ")", "nonExistsTemplates", ".", "clear", "(", ")", ";", "if", "(", "null", "!=", "_nonTmpls", ")", "_nonTmpls", ".", "clear", "(", ")", ";", "_classLoader", "=", "null", ";", "Rythm", ".", "RenderTime", ".", "clear", "(", ")", ";", "zombie", "=", "true", ";", "}" ]
Shutdown this rythm engine
[ "Shutdown", "this", "rythm", "engine" ]
064b565f08d9da07378bf77a9dd856ea5831cc92
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/RythmEngine.java#L2116-L2160
3,128
CloudBees-community/syslog-java-client
src/main/java/com/cloudbees/syslog/sender/AbstractSyslogMessageSender.java
AbstractSyslogMessageSender.sendMessage
@Override public void sendMessage(CharArrayWriter message) throws IOException { SyslogMessage syslogMessage = new SyslogMessage() .withAppName(defaultAppName) .withFacility(defaultFacility) .withHostname(defaultMessageHostname) .withSeverity(defaultSeverity) .withMsg(message); sendMessage(syslogMessage); }
java
@Override public void sendMessage(CharArrayWriter message) throws IOException { SyslogMessage syslogMessage = new SyslogMessage() .withAppName(defaultAppName) .withFacility(defaultFacility) .withHostname(defaultMessageHostname) .withSeverity(defaultSeverity) .withMsg(message); sendMessage(syslogMessage); }
[ "@", "Override", "public", "void", "sendMessage", "(", "CharArrayWriter", "message", ")", "throws", "IOException", "{", "SyslogMessage", "syslogMessage", "=", "new", "SyslogMessage", "(", ")", ".", "withAppName", "(", "defaultAppName", ")", ".", "withFacility", "(", "defaultFacility", ")", ".", "withHostname", "(", "defaultMessageHostname", ")", ".", "withSeverity", "(", "defaultSeverity", ")", ".", "withMsg", "(", "message", ")", ";", "sendMessage", "(", "syslogMessage", ")", ";", "}" ]
Send the given text message @param message @throws java.io.IOException
[ "Send", "the", "given", "text", "message" ]
41e01206e4ce17c6d225ffb443bf19792a3f3c3a
https://github.com/CloudBees-community/syslog-java-client/blob/41e01206e4ce17c6d225ffb443bf19792a3f3c3a/src/main/java/com/cloudbees/syslog/sender/AbstractSyslogMessageSender.java#L43-L54
3,129
CloudBees-community/syslog-java-client
src/main/java/com/cloudbees/syslog/SDElement.java
SDElement.setSdParams
public void setSdParams(List<SDParam> sdParams) { if (null == sdParams) { throw new IllegalArgumentException("sdParams list cannot be null"); } this.sdParams.addAll(sdParams); }
java
public void setSdParams(List<SDParam> sdParams) { if (null == sdParams) { throw new IllegalArgumentException("sdParams list cannot be null"); } this.sdParams.addAll(sdParams); }
[ "public", "void", "setSdParams", "(", "List", "<", "SDParam", ">", "sdParams", ")", "{", "if", "(", "null", "==", "sdParams", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"sdParams list cannot be null\"", ")", ";", "}", "this", ".", "sdParams", ".", "addAll", "(", "sdParams", ")", ";", "}" ]
Set the value of sdParams @param sdParams new value of sdParams
[ "Set", "the", "value", "of", "sdParams" ]
41e01206e4ce17c6d225ffb443bf19792a3f3c3a
https://github.com/CloudBees-community/syslog-java-client/blob/41e01206e4ce17c6d225ffb443bf19792a3f3c3a/src/main/java/com/cloudbees/syslog/SDElement.java#L77-L82
3,130
CloudBees-community/syslog-java-client
src/main/java/com/cloudbees/syslog/SDElement.java
SDElement.addSDParam
public SDElement addSDParam(String paramName, String paramValue) { return addSDParam(new SDParam(paramName, paramValue)); }
java
public SDElement addSDParam(String paramName, String paramValue) { return addSDParam(new SDParam(paramName, paramValue)); }
[ "public", "SDElement", "addSDParam", "(", "String", "paramName", ",", "String", "paramValue", ")", "{", "return", "addSDParam", "(", "new", "SDParam", "(", "paramName", ",", "paramValue", ")", ")", ";", "}" ]
Adds a SDParam @param paramName the PARAM-NAME @param paramValue the PARAM-VALUE @return
[ "Adds", "a", "SDParam" ]
41e01206e4ce17c6d225ffb443bf19792a3f3c3a
https://github.com/CloudBees-community/syslog-java-client/blob/41e01206e4ce17c6d225ffb443bf19792a3f3c3a/src/main/java/com/cloudbees/syslog/SDElement.java#L90-L92
3,131
nmorel/gwt-jackson
extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/googlecode/objectify/Key.java
Key.getRoot
@SuppressWarnings( "unchecked" ) public <V> Key<V> getRoot() { if ( this.getParent() == null ) { return (Key<V>) this; } else { return this.getParent().getRoot(); } }
java
@SuppressWarnings( "unchecked" ) public <V> Key<V> getRoot() { if ( this.getParent() == null ) { return (Key<V>) this; } else { return this.getParent().getRoot(); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "V", ">", "Key", "<", "V", ">", "getRoot", "(", ")", "{", "if", "(", "this", ".", "getParent", "(", ")", "==", "null", ")", "{", "return", "(", "Key", "<", "V", ">", ")", "this", ";", "}", "else", "{", "return", "this", ".", "getParent", "(", ")", ".", "getRoot", "(", ")", ";", "}", "}" ]
Gets the root of a parent graph of keys. If a Key has no parent, it is the root. @return the topmost parent key, or this object itself if it is the root. Note that the root key could potentially have any type.
[ "Gets", "the", "root", "of", "a", "parent", "graph", "of", "keys", ".", "If", "a", "Key", "has", "no", "parent", "it", "is", "the", "root", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/googlecode/objectify/Key.java#L192-L199
3,132
nmorel/gwt-jackson
extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/googlecode/objectify/Key.java
Key.equivalent
public boolean equivalent( Ref<T> other ) { return (other == null) ? false : equals( other.key() ); }
java
public boolean equivalent( Ref<T> other ) { return (other == null) ? false : equals( other.key() ); }
[ "public", "boolean", "equivalent", "(", "Ref", "<", "T", ">", "other", ")", "{", "return", "(", "other", "==", "null", ")", "?", "false", ":", "equals", "(", "other", ".", "key", "(", ")", ")", ";", "}" ]
A type-safe equivalence comparison
[ "A", "type", "-", "safe", "equivalence", "comparison" ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/googlecode/objectify/Key.java#L211-L213
3,133
nmorel/gwt-jackson
extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/googlecode/objectify/Key.java
Key.key
public static <V> Key<V> key( com.google.appengine.api.datastore.Key raw ) { if ( raw == null ) { return null; } else { return new Key<V>( raw ); } }
java
public static <V> Key<V> key( com.google.appengine.api.datastore.Key raw ) { if ( raw == null ) { return null; } else { return new Key<V>( raw ); } }
[ "public", "static", "<", "V", ">", "Key", "<", "V", ">", "key", "(", "com", ".", "google", ".", "appengine", ".", "api", ".", "datastore", ".", "Key", "raw", ")", "{", "if", "(", "raw", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "return", "new", "Key", "<", "V", ">", "(", "raw", ")", ";", "}", "}" ]
Easy null-safe conversion of the raw key.
[ "Easy", "null", "-", "safe", "conversion", "of", "the", "raw", "key", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/googlecode/objectify/Key.java#L254-L260
3,134
nmorel/gwt-jackson
extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/googlecode/objectify/Key.java
Key.raw
public static com.google.appengine.api.datastore.Key raw( Key<?> typed ) { if ( typed == null ) { return null; } else { return typed.getRaw(); } }
java
public static com.google.appengine.api.datastore.Key raw( Key<?> typed ) { if ( typed == null ) { return null; } else { return typed.getRaw(); } }
[ "public", "static", "com", ".", "google", ".", "appengine", ".", "api", ".", "datastore", ".", "Key", "raw", "(", "Key", "<", "?", ">", "typed", ")", "{", "if", "(", "typed", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "return", "typed", ".", "getRaw", "(", ")", ";", "}", "}" ]
Easy null-safe conversion of the typed key.
[ "Easy", "null", "-", "safe", "conversion", "of", "the", "typed", "key", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/googlecode/objectify/Key.java#L265-L271
3,135
nmorel/gwt-jackson
gwt-jackson/src/main/resources/com/github/nmorel/gwtjackson/super/java/util/UUID.java
UUID.fromString
public static UUID fromString( String name ) { UUID newUUID = new UUID(); newUUID.uuidValue = name; return newUUID; }
java
public static UUID fromString( String name ) { UUID newUUID = new UUID(); newUUID.uuidValue = name; return newUUID; }
[ "public", "static", "UUID", "fromString", "(", "String", "name", ")", "{", "UUID", "newUUID", "=", "new", "UUID", "(", ")", ";", "newUUID", ".", "uuidValue", "=", "name", ";", "return", "newUUID", ";", "}" ]
Constructs a new UUID from a string representation. @param name @return
[ "Constructs", "a", "new", "UUID", "from", "a", "string", "representation", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/resources/com/github/nmorel/gwtjackson/super/java/util/UUID.java#L49-L53
3,136
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/JsonSerializationContext.java
JsonSerializationContext.traceWriterInfo
private void traceWriterInfo( Object value, JsonWriter writer ) { if ( getLogger().isLoggable( Level.INFO ) ) { getLogger().log( Level.INFO, "Error on value <" + value + ">. Current output : <" + writer.getOutput() + ">" ); } }
java
private void traceWriterInfo( Object value, JsonWriter writer ) { if ( getLogger().isLoggable( Level.INFO ) ) { getLogger().log( Level.INFO, "Error on value <" + value + ">. Current output : <" + writer.getOutput() + ">" ); } }
[ "private", "void", "traceWriterInfo", "(", "Object", "value", ",", "JsonWriter", "writer", ")", "{", "if", "(", "getLogger", "(", ")", ".", "isLoggable", "(", "Level", ".", "INFO", ")", ")", "{", "getLogger", "(", ")", ".", "log", "(", "Level", ".", "INFO", ",", "\"Error on value <\"", "+", "value", "+", "\">. Current output : <\"", "+", "writer", ".", "getOutput", "(", ")", "+", "\">\"", ")", ";", "}", "}" ]
Trace the current writer state @param value current value
[ "Trace", "the", "current", "writer", "state" ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/JsonSerializationContext.java#L562-L566
3,137
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/ObjectMapperCreator.java
ObjectMapperCreator.extractMappedType
private JClassType extractMappedType( JClassType interfaceClass ) throws UnableToCompleteException { JClassType intf = interfaceClass.isInterface(); if ( intf == null ) { logger.log( TreeLogger.Type.ERROR, "Expected " + interfaceClass + " to be an interface." ); throw new UnableToCompleteException(); } JClassType[] intfs = intf.getImplementedInterfaces(); for ( JClassType t : intfs ) { if ( t.getQualifiedSourceName().equals( OBJECT_MAPPER_CLASS ) ) { return extractParameterizedType( OBJECT_MAPPER_CLASS, t.isParameterized() ); } else if ( t.getQualifiedSourceName().equals( OBJECT_READER_CLASS ) ) { return extractParameterizedType( OBJECT_READER_CLASS, t.isParameterized() ); } else if ( t.getQualifiedSourceName().equals( OBJECT_WRITER_CLASS ) ) { return extractParameterizedType( OBJECT_WRITER_CLASS, t.isParameterized() ); } } logger.log( TreeLogger.Type.ERROR, "Expected " + interfaceClass + " to extend one of the following interface : " + OBJECT_MAPPER_CLASS + ", " + OBJECT_READER_CLASS + " or " + OBJECT_WRITER_CLASS ); throw new UnableToCompleteException(); }
java
private JClassType extractMappedType( JClassType interfaceClass ) throws UnableToCompleteException { JClassType intf = interfaceClass.isInterface(); if ( intf == null ) { logger.log( TreeLogger.Type.ERROR, "Expected " + interfaceClass + " to be an interface." ); throw new UnableToCompleteException(); } JClassType[] intfs = intf.getImplementedInterfaces(); for ( JClassType t : intfs ) { if ( t.getQualifiedSourceName().equals( OBJECT_MAPPER_CLASS ) ) { return extractParameterizedType( OBJECT_MAPPER_CLASS, t.isParameterized() ); } else if ( t.getQualifiedSourceName().equals( OBJECT_READER_CLASS ) ) { return extractParameterizedType( OBJECT_READER_CLASS, t.isParameterized() ); } else if ( t.getQualifiedSourceName().equals( OBJECT_WRITER_CLASS ) ) { return extractParameterizedType( OBJECT_WRITER_CLASS, t.isParameterized() ); } } logger.log( TreeLogger.Type.ERROR, "Expected " + interfaceClass + " to extend one of the following interface : " + OBJECT_MAPPER_CLASS + ", " + OBJECT_READER_CLASS + " or " + OBJECT_WRITER_CLASS ); throw new UnableToCompleteException(); }
[ "private", "JClassType", "extractMappedType", "(", "JClassType", "interfaceClass", ")", "throws", "UnableToCompleteException", "{", "JClassType", "intf", "=", "interfaceClass", ".", "isInterface", "(", ")", ";", "if", "(", "intf", "==", "null", ")", "{", "logger", ".", "log", "(", "TreeLogger", ".", "Type", ".", "ERROR", ",", "\"Expected \"", "+", "interfaceClass", "+", "\" to be an interface.\"", ")", ";", "throw", "new", "UnableToCompleteException", "(", ")", ";", "}", "JClassType", "[", "]", "intfs", "=", "intf", ".", "getImplementedInterfaces", "(", ")", ";", "for", "(", "JClassType", "t", ":", "intfs", ")", "{", "if", "(", "t", ".", "getQualifiedSourceName", "(", ")", ".", "equals", "(", "OBJECT_MAPPER_CLASS", ")", ")", "{", "return", "extractParameterizedType", "(", "OBJECT_MAPPER_CLASS", ",", "t", ".", "isParameterized", "(", ")", ")", ";", "}", "else", "if", "(", "t", ".", "getQualifiedSourceName", "(", ")", ".", "equals", "(", "OBJECT_READER_CLASS", ")", ")", "{", "return", "extractParameterizedType", "(", "OBJECT_READER_CLASS", ",", "t", ".", "isParameterized", "(", ")", ")", ";", "}", "else", "if", "(", "t", ".", "getQualifiedSourceName", "(", ")", ".", "equals", "(", "OBJECT_WRITER_CLASS", ")", ")", "{", "return", "extractParameterizedType", "(", "OBJECT_WRITER_CLASS", ",", "t", ".", "isParameterized", "(", ")", ")", ";", "}", "}", "logger", ".", "log", "(", "TreeLogger", ".", "Type", ".", "ERROR", ",", "\"Expected \"", "+", "interfaceClass", "+", "\" to extend one of the following interface : \"", "+", "OBJECT_MAPPER_CLASS", "+", "\", \"", "+", "OBJECT_READER_CLASS", "+", "\" or \"", "+", "OBJECT_WRITER_CLASS", ")", ";", "throw", "new", "UnableToCompleteException", "(", ")", ";", "}" ]
Extract the type to map from the interface. @param interfaceClass the interface @return the extracted type to map @throws UnableToCompleteException if we don't find the type
[ "Extract", "the", "type", "to", "map", "from", "the", "interface", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/ObjectMapperCreator.java#L157-L177
3,138
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/ObjectMapperCreator.java
ObjectMapperCreator.extractParameterizedType
private JClassType extractParameterizedType( String clazz, JParameterizedType parameterizedType ) throws UnableToCompleteException { if ( parameterizedType == null ) { logger.log( TreeLogger.Type.ERROR, "Expected the " + clazz + " declaration to specify a parameterized type." ); throw new UnableToCompleteException(); } JClassType[] typeParameters = parameterizedType.getTypeArgs(); if ( typeParameters == null || typeParameters.length != 1 ) { logger.log( TreeLogger.Type.ERROR, "Expected the " + clazz + " declaration to specify 1 parameterized type." ); throw new UnableToCompleteException(); } return typeParameters[0]; }
java
private JClassType extractParameterizedType( String clazz, JParameterizedType parameterizedType ) throws UnableToCompleteException { if ( parameterizedType == null ) { logger.log( TreeLogger.Type.ERROR, "Expected the " + clazz + " declaration to specify a parameterized type." ); throw new UnableToCompleteException(); } JClassType[] typeParameters = parameterizedType.getTypeArgs(); if ( typeParameters == null || typeParameters.length != 1 ) { logger.log( TreeLogger.Type.ERROR, "Expected the " + clazz + " declaration to specify 1 parameterized type." ); throw new UnableToCompleteException(); } return typeParameters[0]; }
[ "private", "JClassType", "extractParameterizedType", "(", "String", "clazz", ",", "JParameterizedType", "parameterizedType", ")", "throws", "UnableToCompleteException", "{", "if", "(", "parameterizedType", "==", "null", ")", "{", "logger", ".", "log", "(", "TreeLogger", ".", "Type", ".", "ERROR", ",", "\"Expected the \"", "+", "clazz", "+", "\" declaration to specify a parameterized type.\"", ")", ";", "throw", "new", "UnableToCompleteException", "(", ")", ";", "}", "JClassType", "[", "]", "typeParameters", "=", "parameterizedType", ".", "getTypeArgs", "(", ")", ";", "if", "(", "typeParameters", "==", "null", "||", "typeParameters", ".", "length", "!=", "1", ")", "{", "logger", ".", "log", "(", "TreeLogger", ".", "Type", ".", "ERROR", ",", "\"Expected the \"", "+", "clazz", "+", "\" declaration to specify 1 parameterized type.\"", ")", ";", "throw", "new", "UnableToCompleteException", "(", ")", ";", "}", "return", "typeParameters", "[", "0", "]", ";", "}" ]
Extract the parameter's type. @param clazz the name of the interface @param parameterizedType the parameterized type @return the extracted type @throws UnableToCompleteException if the type contains zero or more than one parameter
[ "Extract", "the", "parameter", "s", "type", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/ObjectMapperCreator.java#L188-L199
3,139
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/ObjectMapperCreator.java
ObjectMapperCreator.buildConstructor
private MethodSpec buildConstructor( JClassType mappedTypeClass ) { Optional<JsonRootName> jsonRootName = findFirstEncounteredAnnotationsOnAllHierarchy( configuration, mappedTypeClass, JsonRootName.class ); String rootName; if ( !jsonRootName.isPresent() || Strings.isNullOrEmpty( jsonRootName.get().value() ) ) { rootName = mappedTypeClass.getSimpleSourceName(); } else { rootName = jsonRootName.get().value(); } return MethodSpec.constructorBuilder() .addModifiers( Modifier.PUBLIC ) .addStatement( "super($S)", rootName ) .build(); }
java
private MethodSpec buildConstructor( JClassType mappedTypeClass ) { Optional<JsonRootName> jsonRootName = findFirstEncounteredAnnotationsOnAllHierarchy( configuration, mappedTypeClass, JsonRootName.class ); String rootName; if ( !jsonRootName.isPresent() || Strings.isNullOrEmpty( jsonRootName.get().value() ) ) { rootName = mappedTypeClass.getSimpleSourceName(); } else { rootName = jsonRootName.get().value(); } return MethodSpec.constructorBuilder() .addModifiers( Modifier.PUBLIC ) .addStatement( "super($S)", rootName ) .build(); }
[ "private", "MethodSpec", "buildConstructor", "(", "JClassType", "mappedTypeClass", ")", "{", "Optional", "<", "JsonRootName", ">", "jsonRootName", "=", "findFirstEncounteredAnnotationsOnAllHierarchy", "(", "configuration", ",", "mappedTypeClass", ",", "JsonRootName", ".", "class", ")", ";", "String", "rootName", ";", "if", "(", "!", "jsonRootName", ".", "isPresent", "(", ")", "||", "Strings", ".", "isNullOrEmpty", "(", "jsonRootName", ".", "get", "(", ")", ".", "value", "(", ")", ")", ")", "{", "rootName", "=", "mappedTypeClass", ".", "getSimpleSourceName", "(", ")", ";", "}", "else", "{", "rootName", "=", "jsonRootName", ".", "get", "(", ")", ".", "value", "(", ")", ";", "}", "return", "MethodSpec", ".", "constructorBuilder", "(", ")", ".", "addModifiers", "(", "Modifier", ".", "PUBLIC", ")", ".", "addStatement", "(", "\"super($S)\"", ",", "rootName", ")", ".", "build", "(", ")", ";", "}" ]
Build the constructor. @param mappedTypeClass the type to map @return the constructor method
[ "Build", "the", "constructor", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/ObjectMapperCreator.java#L208-L222
3,140
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/ObjectMapperCreator.java
ObjectMapperCreator.buildNewDeserializerMethod
private MethodSpec buildNewDeserializerMethod( JClassType mappedTypeClass ) throws UnableToCompleteException { JDeserializerType type; try { type = getJsonDeserializerFromType( mappedTypeClass ); } catch ( UnsupportedTypeException e ) { logger.log( Type.ERROR, "Cannot generate mapper due to previous errors : " + e.getMessage() ); throw new UnableToCompleteException(); } return MethodSpec.methodBuilder( "newDeserializer" ) .addModifiers( Modifier.PROTECTED ) .addAnnotation( Override.class ) .returns( parameterizedName( JsonDeserializer.class, mappedTypeClass ) ) .addStatement( "return $L", type.getInstance() ) .build(); }
java
private MethodSpec buildNewDeserializerMethod( JClassType mappedTypeClass ) throws UnableToCompleteException { JDeserializerType type; try { type = getJsonDeserializerFromType( mappedTypeClass ); } catch ( UnsupportedTypeException e ) { logger.log( Type.ERROR, "Cannot generate mapper due to previous errors : " + e.getMessage() ); throw new UnableToCompleteException(); } return MethodSpec.methodBuilder( "newDeserializer" ) .addModifiers( Modifier.PROTECTED ) .addAnnotation( Override.class ) .returns( parameterizedName( JsonDeserializer.class, mappedTypeClass ) ) .addStatement( "return $L", type.getInstance() ) .build(); }
[ "private", "MethodSpec", "buildNewDeserializerMethod", "(", "JClassType", "mappedTypeClass", ")", "throws", "UnableToCompleteException", "{", "JDeserializerType", "type", ";", "try", "{", "type", "=", "getJsonDeserializerFromType", "(", "mappedTypeClass", ")", ";", "}", "catch", "(", "UnsupportedTypeException", "e", ")", "{", "logger", ".", "log", "(", "Type", ".", "ERROR", ",", "\"Cannot generate mapper due to previous errors : \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "throw", "new", "UnableToCompleteException", "(", ")", ";", "}", "return", "MethodSpec", ".", "methodBuilder", "(", "\"newDeserializer\"", ")", ".", "addModifiers", "(", "Modifier", ".", "PROTECTED", ")", ".", "addAnnotation", "(", "Override", ".", "class", ")", ".", "returns", "(", "parameterizedName", "(", "JsonDeserializer", ".", "class", ",", "mappedTypeClass", ")", ")", ".", "addStatement", "(", "\"return $L\"", ",", "type", ".", "getInstance", "(", ")", ")", ".", "build", "(", ")", ";", "}" ]
Build the new deserializer method. @param mappedTypeClass the type to map @return the method
[ "Build", "the", "new", "deserializer", "method", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/ObjectMapperCreator.java#L231-L246
3,141
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/ObjectMapperCreator.java
ObjectMapperCreator.buildNewSerializerMethod
private MethodSpec buildNewSerializerMethod( JClassType mappedTypeClass ) throws UnableToCompleteException { JSerializerType type; try { type = getJsonSerializerFromType( mappedTypeClass ); } catch ( UnsupportedTypeException e ) { logger.log( Type.ERROR, "Cannot generate mapper due to previous errors : " + e.getMessage() ); throw new UnableToCompleteException(); } return MethodSpec.methodBuilder( "newSerializer" ) .addModifiers( Modifier.PROTECTED ) .addAnnotation( Override.class ) .returns( ParameterizedTypeName.get( ClassName.get( JsonSerializer.class ), DEFAULT_WILDCARD ) ) .addStatement( "return $L", type.getInstance() ) .build(); }
java
private MethodSpec buildNewSerializerMethod( JClassType mappedTypeClass ) throws UnableToCompleteException { JSerializerType type; try { type = getJsonSerializerFromType( mappedTypeClass ); } catch ( UnsupportedTypeException e ) { logger.log( Type.ERROR, "Cannot generate mapper due to previous errors : " + e.getMessage() ); throw new UnableToCompleteException(); } return MethodSpec.methodBuilder( "newSerializer" ) .addModifiers( Modifier.PROTECTED ) .addAnnotation( Override.class ) .returns( ParameterizedTypeName.get( ClassName.get( JsonSerializer.class ), DEFAULT_WILDCARD ) ) .addStatement( "return $L", type.getInstance() ) .build(); }
[ "private", "MethodSpec", "buildNewSerializerMethod", "(", "JClassType", "mappedTypeClass", ")", "throws", "UnableToCompleteException", "{", "JSerializerType", "type", ";", "try", "{", "type", "=", "getJsonSerializerFromType", "(", "mappedTypeClass", ")", ";", "}", "catch", "(", "UnsupportedTypeException", "e", ")", "{", "logger", ".", "log", "(", "Type", ".", "ERROR", ",", "\"Cannot generate mapper due to previous errors : \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "throw", "new", "UnableToCompleteException", "(", ")", ";", "}", "return", "MethodSpec", ".", "methodBuilder", "(", "\"newSerializer\"", ")", ".", "addModifiers", "(", "Modifier", ".", "PROTECTED", ")", ".", "addAnnotation", "(", "Override", ".", "class", ")", ".", "returns", "(", "ParameterizedTypeName", ".", "get", "(", "ClassName", ".", "get", "(", "JsonSerializer", ".", "class", ")", ",", "DEFAULT_WILDCARD", ")", ")", ".", "addStatement", "(", "\"return $L\"", ",", "type", ".", "getInstance", "(", ")", ")", ".", "build", "(", ")", ";", "}" ]
Build the new serializer method. @param mappedTypeClass the type to map @return the method
[ "Build", "the", "new", "serializer", "method", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/ObjectMapperCreator.java#L255-L270
3,142
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/utils/DateFormat.java
DateFormat.hasTz
private static boolean hasTz( String pattern ) { boolean inQuote = false; for ( int i = 0; i < pattern.length(); i++ ) { char ch = pattern.charAt( i ); // If inside quote, except two quote connected, just copy or exit. if ( inQuote ) { if ( ch == '\'' ) { if ( i + 1 < pattern.length() && pattern.charAt( i + 1 ) == '\'' ) { // Quote appeared twice continuously, interpret as one quote. ++i; } else { inQuote = false; } } continue; } // Outside quote now. if ( "Zzv".indexOf( ch ) >= 0 ) { return true; } // Two consecutive quotes is a quote literal, inside or outside of quotes. if ( ch == '\'' ) { if ( i + 1 < pattern.length() && pattern.charAt( i + 1 ) == '\'' ) { i++; } else { inQuote = true; } } } return false; }
java
private static boolean hasTz( String pattern ) { boolean inQuote = false; for ( int i = 0; i < pattern.length(); i++ ) { char ch = pattern.charAt( i ); // If inside quote, except two quote connected, just copy or exit. if ( inQuote ) { if ( ch == '\'' ) { if ( i + 1 < pattern.length() && pattern.charAt( i + 1 ) == '\'' ) { // Quote appeared twice continuously, interpret as one quote. ++i; } else { inQuote = false; } } continue; } // Outside quote now. if ( "Zzv".indexOf( ch ) >= 0 ) { return true; } // Two consecutive quotes is a quote literal, inside or outside of quotes. if ( ch == '\'' ) { if ( i + 1 < pattern.length() && pattern.charAt( i + 1 ) == '\'' ) { i++; } else { inQuote = true; } } } return false; }
[ "private", "static", "boolean", "hasTz", "(", "String", "pattern", ")", "{", "boolean", "inQuote", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pattern", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "ch", "=", "pattern", ".", "charAt", "(", "i", ")", ";", "// If inside quote, except two quote connected, just copy or exit.", "if", "(", "inQuote", ")", "{", "if", "(", "ch", "==", "'", "'", ")", "{", "if", "(", "i", "+", "1", "<", "pattern", ".", "length", "(", ")", "&&", "pattern", ".", "charAt", "(", "i", "+", "1", ")", "==", "'", "'", ")", "{", "// Quote appeared twice continuously, interpret as one quote.", "++", "i", ";", "}", "else", "{", "inQuote", "=", "false", ";", "}", "}", "continue", ";", "}", "// Outside quote now.", "if", "(", "\"Zzv\"", ".", "indexOf", "(", "ch", ")", ">=", "0", ")", "{", "return", "true", ";", "}", "// Two consecutive quotes is a quote literal, inside or outside of quotes.", "if", "(", "ch", "==", "'", "'", ")", "{", "if", "(", "i", "+", "1", "<", "pattern", ".", "length", "(", ")", "&&", "pattern", ".", "charAt", "(", "i", "+", "1", ")", "==", "'", "'", ")", "{", "i", "++", ";", "}", "else", "{", "inQuote", "=", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Find if a pattern contains informations about the timezone. @param pattern pattern @return true if the pattern contains informations about the timezone, false otherwise
[ "Find", "if", "a", "pattern", "contains", "informations", "about", "the", "timezone", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/utils/DateFormat.java#L207-L242
3,143
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/JsonDeserializer.java
JsonDeserializer.deserializeNullValue
protected T deserializeNullValue( JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params ) { reader.skipValue(); return null; }
java
protected T deserializeNullValue( JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params ) { reader.skipValue(); return null; }
[ "protected", "T", "deserializeNullValue", "(", "JsonReader", "reader", ",", "JsonDeserializationContext", "ctx", ",", "JsonDeserializerParameters", "params", ")", "{", "reader", ".", "skipValue", "(", ")", ";", "return", "null", ";", "}" ]
Deserialize the null value. This method allows children to override the default behaviour. @param reader {@link JsonReader} used to read the JSON input @param ctx Context for the full deserialization process @param params Parameters for this deserialization @return the deserialized object
[ "Deserialize", "the", "null", "value", ".", "This", "method", "allows", "children", "to", "override", "the", "default", "behaviour", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/JsonDeserializer.java#L68-L71
3,144
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/JsonDeserializer.java
JsonDeserializer.setBackReference
public void setBackReference( String referenceName, Object reference, T value, JsonDeserializationContext ctx ) { throw new JsonDeserializationException( "Cannot set a back reference to the type managed by this deserializer" ); }
java
public void setBackReference( String referenceName, Object reference, T value, JsonDeserializationContext ctx ) { throw new JsonDeserializationException( "Cannot set a back reference to the type managed by this deserializer" ); }
[ "public", "void", "setBackReference", "(", "String", "referenceName", ",", "Object", "reference", ",", "T", "value", ",", "JsonDeserializationContext", "ctx", ")", "{", "throw", "new", "JsonDeserializationException", "(", "\"Cannot set a back reference to the type managed by this deserializer\"", ")", ";", "}" ]
Set the back reference. @param referenceName name of the reference @param referenceName name of the reference @param referenceName name of the reference @param referenceName name of the reference @param referenceName name of the reference @param referenceName name of the reference @param reference reference to set @param value value to set the reference to. @param ctx Context for the full deserialization process @see com.fasterxml.jackson.annotation.JsonBackReference
[ "Set", "the", "back", "reference", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/JsonDeserializer.java#L97-L99
3,145
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/deser/map/key/KeyDeserializer.java
KeyDeserializer.deserialize
public T deserialize( String key, JsonDeserializationContext ctx ) throws JsonDeserializationException { if ( null == key ) { return null; } return doDeserialize( key, ctx ); }
java
public T deserialize( String key, JsonDeserializationContext ctx ) throws JsonDeserializationException { if ( null == key ) { return null; } return doDeserialize( key, ctx ); }
[ "public", "T", "deserialize", "(", "String", "key", ",", "JsonDeserializationContext", "ctx", ")", "throws", "JsonDeserializationException", "{", "if", "(", "null", "==", "key", ")", "{", "return", "null", ";", "}", "return", "doDeserialize", "(", "key", ",", "ctx", ")", ";", "}" ]
Deserializes a key into an object. @param key key to deserialize @param ctx Context for the full deserialization process @return the deserialized object @throws com.github.nmorel.gwtjackson.client.exception.JsonDeserializationException if an error occurs during the deserialization
[ "Deserializes", "a", "key", "into", "an", "object", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/deser/map/key/KeyDeserializer.java#L38-L43
3,146
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/CreatorUtils.java
CreatorUtils.isAnnotationPresent
public static <T extends Annotation> boolean isAnnotationPresent( Class<T> annotation, List<? extends HasAnnotations> hasAnnotationsList ) { for ( HasAnnotations accessor : hasAnnotationsList ) { if ( accessor.isAnnotationPresent( annotation ) ) { return true; } } return false; }
java
public static <T extends Annotation> boolean isAnnotationPresent( Class<T> annotation, List<? extends HasAnnotations> hasAnnotationsList ) { for ( HasAnnotations accessor : hasAnnotationsList ) { if ( accessor.isAnnotationPresent( annotation ) ) { return true; } } return false; }
[ "public", "static", "<", "T", "extends", "Annotation", ">", "boolean", "isAnnotationPresent", "(", "Class", "<", "T", ">", "annotation", ",", "List", "<", "?", "extends", "HasAnnotations", ">", "hasAnnotationsList", ")", "{", "for", "(", "HasAnnotations", "accessor", ":", "hasAnnotationsList", ")", "{", "if", "(", "accessor", ".", "isAnnotationPresent", "(", "annotation", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true when one of the type has the specified annotation @param annotation the annotation @param hasAnnotationsList the types @return true if one the type has the annotation @param <T> a T object.
[ "Returns", "true", "when", "one", "of", "the", "type", "has", "the", "specified", "annotation" ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/CreatorUtils.java#L106-L114
3,147
nmorel/gwt-jackson
extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/google/appengine/api/datastore/GeoPt.java
GeoPt.compareTo
@Override public int compareTo( GeoPt o ) { int latResult = ((Float) latitude).compareTo( o.latitude ); if ( latResult != 0 ) { return latResult; } return ((Float) longitude).compareTo( o.longitude ); }
java
@Override public int compareTo( GeoPt o ) { int latResult = ((Float) latitude).compareTo( o.latitude ); if ( latResult != 0 ) { return latResult; } return ((Float) longitude).compareTo( o.longitude ); }
[ "@", "Override", "public", "int", "compareTo", "(", "GeoPt", "o", ")", "{", "int", "latResult", "=", "(", "(", "Float", ")", "latitude", ")", ".", "compareTo", "(", "o", ".", "latitude", ")", ";", "if", "(", "latResult", "!=", "0", ")", "{", "return", "latResult", ";", "}", "return", "(", "(", "Float", ")", "longitude", ")", ".", "compareTo", "(", "o", ".", "longitude", ")", ";", "}" ]
Sort first by latitude, then by longitude
[ "Sort", "first", "by", "latitude", "then", "by", "longitude" ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/google/appengine/api/datastore/GeoPt.java#L62-L69
3,148
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/ser/bean/BeanPropertySerializer.java
BeanPropertySerializer.serializePropertyName
public void serializePropertyName( JsonWriter writer, T bean, JsonSerializationContext ctx ) { writer.unescapeName( propertyName ); }
java
public void serializePropertyName( JsonWriter writer, T bean, JsonSerializationContext ctx ) { writer.unescapeName( propertyName ); }
[ "public", "void", "serializePropertyName", "(", "JsonWriter", "writer", ",", "T", "bean", ",", "JsonSerializationContext", "ctx", ")", "{", "writer", ".", "unescapeName", "(", "propertyName", ")", ";", "}" ]
Serializes the property name @param writer writer @param bean bean containing the property to serialize @param ctx context of the serialization process
[ "Serializes", "the", "property", "name" ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/ser/bean/BeanPropertySerializer.java#L82-L84
3,149
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/ser/bean/BeanPropertySerializer.java
BeanPropertySerializer.serialize
public void serialize( JsonWriter writer, T bean, JsonSerializationContext ctx ) { getSerializer().serialize( writer, getValue( bean, ctx ), ctx, getParameters() ); }
java
public void serialize( JsonWriter writer, T bean, JsonSerializationContext ctx ) { getSerializer().serialize( writer, getValue( bean, ctx ), ctx, getParameters() ); }
[ "public", "void", "serialize", "(", "JsonWriter", "writer", ",", "T", "bean", ",", "JsonSerializationContext", "ctx", ")", "{", "getSerializer", "(", ")", ".", "serialize", "(", "writer", ",", "getValue", "(", "bean", ",", "ctx", ")", ",", "ctx", ",", "getParameters", "(", ")", ")", ";", "}" ]
Serializes the property defined for this instance. @param writer writer @param bean bean containing the property to serialize @param ctx context of the serialization process
[ "Serializes", "the", "property", "defined", "for", "this", "instance", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/ser/bean/BeanPropertySerializer.java#L102-L104
3,150
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/RebindConfiguration.java
RebindConfiguration.getMixInAnnotations
public Optional<JClassType> getMixInAnnotations( JType type ) { return Optional.fromNullable( mixInAnnotations.get( type.getQualifiedSourceName() ) ); }
java
public Optional<JClassType> getMixInAnnotations( JType type ) { return Optional.fromNullable( mixInAnnotations.get( type.getQualifiedSourceName() ) ); }
[ "public", "Optional", "<", "JClassType", ">", "getMixInAnnotations", "(", "JType", "type", ")", "{", "return", "Optional", ".", "fromNullable", "(", "mixInAnnotations", ".", "get", "(", "type", ".", "getQualifiedSourceName", "(", ")", ")", ")", ";", "}" ]
Return the mixin type for the given type @param type a {@link com.google.gwt.core.ext.typeinfo.JType} object. @return a {@link com.google.gwt.thirdparty.guava.common.base.Optional} object.
[ "Return", "the", "mixin", "type", "for", "the", "given", "type" ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/RebindConfiguration.java#L573-L575
3,151
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/JsonDeserializationContext.java
JsonDeserializationContext.traceReaderInfo
private void traceReaderInfo( JsonReader reader ) { if ( null != reader && getLogger().isLoggable( Level.INFO ) ) { getLogger().log( Level.INFO, "Error at line " + reader.getLineNumber() + " and column " + reader .getColumnNumber() + " of input <" + reader.getInput() + ">" ); } }
java
private void traceReaderInfo( JsonReader reader ) { if ( null != reader && getLogger().isLoggable( Level.INFO ) ) { getLogger().log( Level.INFO, "Error at line " + reader.getLineNumber() + " and column " + reader .getColumnNumber() + " of input <" + reader.getInput() + ">" ); } }
[ "private", "void", "traceReaderInfo", "(", "JsonReader", "reader", ")", "{", "if", "(", "null", "!=", "reader", "&&", "getLogger", "(", ")", ".", "isLoggable", "(", "Level", ".", "INFO", ")", ")", "{", "getLogger", "(", ")", ".", "log", "(", "Level", ".", "INFO", ",", "\"Error at line \"", "+", "reader", ".", "getLineNumber", "(", ")", "+", "\" and column \"", "+", "reader", ".", "getColumnNumber", "(", ")", "+", "\" of input <\"", "+", "reader", ".", "getInput", "(", ")", "+", "\">\"", ")", ";", "}", "}" ]
Trace the current reader state
[ "Trace", "the", "current", "reader", "state" ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/JsonDeserializationContext.java#L398-L403
3,152
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractCreator.java
AbstractCreator.getMapperInfo
protected final BeanJsonMapperInfo getMapperInfo( JClassType beanType ) throws UnableToCompleteException { BeanJsonMapperInfo mapperInfo = typeOracle.getBeanJsonMapperInfo( beanType ); if ( null != mapperInfo ) { return mapperInfo; } boolean samePackage = true; String packageName = beanType.getPackage().getName(); // We can't create classes in the java package so we prefix it. if ( packageName.startsWith( "java." ) ) { packageName = "gwtjackson." + packageName; samePackage = false; } // Retrieve the informations on the beans and its properties. BeanInfo beanInfo = BeanProcessor.processBean( logger, typeOracle, configuration, beanType ); PropertiesContainer properties = PropertyProcessor .findAllProperties( configuration, logger, typeOracle, beanInfo, samePackage ); beanInfo = BeanProcessor.processProperties( configuration, logger, typeOracle, beanInfo, properties ); // We concatenate the name of all the enclosing classes. StringBuilder builder = new StringBuilder( beanType.getSimpleSourceName() ); JClassType enclosingType = beanType.getEnclosingType(); while ( null != enclosingType ) { builder.insert( 0, enclosingType.getSimpleSourceName() + "_" ); enclosingType = enclosingType.getEnclosingType(); } // If the type is specific to the mapper, we concatenate the name and hash of the mapper to it. boolean isSpecificToMapper = configuration.isSpecificToMapper( beanType ); if ( isSpecificToMapper ) { JClassType rootMapperClass = configuration.getRootMapperClass(); builder.insert( 0, '_' ).insert( 0, configuration.getRootMapperHash() ).insert( 0, '_' ).insert( 0, rootMapperClass .getSimpleSourceName() ); } String simpleSerializerClassName = builder.toString() + "BeanJsonSerializerImpl"; String simpleDeserializerClassName = builder.toString() + "BeanJsonDeserializerImpl"; mapperInfo = new BeanJsonMapperInfo( beanType, packageName, samePackage, simpleSerializerClassName, simpleDeserializerClassName, beanInfo, properties .getProperties() ); typeOracle.addBeanJsonMapperInfo( beanType, mapperInfo ); return mapperInfo; }
java
protected final BeanJsonMapperInfo getMapperInfo( JClassType beanType ) throws UnableToCompleteException { BeanJsonMapperInfo mapperInfo = typeOracle.getBeanJsonMapperInfo( beanType ); if ( null != mapperInfo ) { return mapperInfo; } boolean samePackage = true; String packageName = beanType.getPackage().getName(); // We can't create classes in the java package so we prefix it. if ( packageName.startsWith( "java." ) ) { packageName = "gwtjackson." + packageName; samePackage = false; } // Retrieve the informations on the beans and its properties. BeanInfo beanInfo = BeanProcessor.processBean( logger, typeOracle, configuration, beanType ); PropertiesContainer properties = PropertyProcessor .findAllProperties( configuration, logger, typeOracle, beanInfo, samePackage ); beanInfo = BeanProcessor.processProperties( configuration, logger, typeOracle, beanInfo, properties ); // We concatenate the name of all the enclosing classes. StringBuilder builder = new StringBuilder( beanType.getSimpleSourceName() ); JClassType enclosingType = beanType.getEnclosingType(); while ( null != enclosingType ) { builder.insert( 0, enclosingType.getSimpleSourceName() + "_" ); enclosingType = enclosingType.getEnclosingType(); } // If the type is specific to the mapper, we concatenate the name and hash of the mapper to it. boolean isSpecificToMapper = configuration.isSpecificToMapper( beanType ); if ( isSpecificToMapper ) { JClassType rootMapperClass = configuration.getRootMapperClass(); builder.insert( 0, '_' ).insert( 0, configuration.getRootMapperHash() ).insert( 0, '_' ).insert( 0, rootMapperClass .getSimpleSourceName() ); } String simpleSerializerClassName = builder.toString() + "BeanJsonSerializerImpl"; String simpleDeserializerClassName = builder.toString() + "BeanJsonDeserializerImpl"; mapperInfo = new BeanJsonMapperInfo( beanType, packageName, samePackage, simpleSerializerClassName, simpleDeserializerClassName, beanInfo, properties .getProperties() ); typeOracle.addBeanJsonMapperInfo( beanType, mapperInfo ); return mapperInfo; }
[ "protected", "final", "BeanJsonMapperInfo", "getMapperInfo", "(", "JClassType", "beanType", ")", "throws", "UnableToCompleteException", "{", "BeanJsonMapperInfo", "mapperInfo", "=", "typeOracle", ".", "getBeanJsonMapperInfo", "(", "beanType", ")", ";", "if", "(", "null", "!=", "mapperInfo", ")", "{", "return", "mapperInfo", ";", "}", "boolean", "samePackage", "=", "true", ";", "String", "packageName", "=", "beanType", ".", "getPackage", "(", ")", ".", "getName", "(", ")", ";", "// We can't create classes in the java package so we prefix it.", "if", "(", "packageName", ".", "startsWith", "(", "\"java.\"", ")", ")", "{", "packageName", "=", "\"gwtjackson.\"", "+", "packageName", ";", "samePackage", "=", "false", ";", "}", "// Retrieve the informations on the beans and its properties.", "BeanInfo", "beanInfo", "=", "BeanProcessor", ".", "processBean", "(", "logger", ",", "typeOracle", ",", "configuration", ",", "beanType", ")", ";", "PropertiesContainer", "properties", "=", "PropertyProcessor", ".", "findAllProperties", "(", "configuration", ",", "logger", ",", "typeOracle", ",", "beanInfo", ",", "samePackage", ")", ";", "beanInfo", "=", "BeanProcessor", ".", "processProperties", "(", "configuration", ",", "logger", ",", "typeOracle", ",", "beanInfo", ",", "properties", ")", ";", "// We concatenate the name of all the enclosing classes.", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", "beanType", ".", "getSimpleSourceName", "(", ")", ")", ";", "JClassType", "enclosingType", "=", "beanType", ".", "getEnclosingType", "(", ")", ";", "while", "(", "null", "!=", "enclosingType", ")", "{", "builder", ".", "insert", "(", "0", ",", "enclosingType", ".", "getSimpleSourceName", "(", ")", "+", "\"_\"", ")", ";", "enclosingType", "=", "enclosingType", ".", "getEnclosingType", "(", ")", ";", "}", "// If the type is specific to the mapper, we concatenate the name and hash of the mapper to it.", "boolean", "isSpecificToMapper", "=", "configuration", ".", "isSpecificToMapper", "(", "beanType", ")", ";", "if", "(", "isSpecificToMapper", ")", "{", "JClassType", "rootMapperClass", "=", "configuration", ".", "getRootMapperClass", "(", ")", ";", "builder", ".", "insert", "(", "0", ",", "'", "'", ")", ".", "insert", "(", "0", ",", "configuration", ".", "getRootMapperHash", "(", ")", ")", ".", "insert", "(", "0", ",", "'", "'", ")", ".", "insert", "(", "0", ",", "rootMapperClass", ".", "getSimpleSourceName", "(", ")", ")", ";", "}", "String", "simpleSerializerClassName", "=", "builder", ".", "toString", "(", ")", "+", "\"BeanJsonSerializerImpl\"", ";", "String", "simpleDeserializerClassName", "=", "builder", ".", "toString", "(", ")", "+", "\"BeanJsonDeserializerImpl\"", ";", "mapperInfo", "=", "new", "BeanJsonMapperInfo", "(", "beanType", ",", "packageName", ",", "samePackage", ",", "simpleSerializerClassName", ",", "simpleDeserializerClassName", ",", "beanInfo", ",", "properties", ".", "getProperties", "(", ")", ")", ";", "typeOracle", ".", "addBeanJsonMapperInfo", "(", "beanType", ",", "mapperInfo", ")", ";", "return", "mapperInfo", ";", "}" ]
Returns the mapper information for the given type. The result is cached. @param beanType the type @return the mapper information @throws com.google.gwt.core.ext.UnableToCompleteException if an exception occured while processing the type
[ "Returns", "the", "mapper", "information", "for", "the", "given", "type", ".", "The", "result", "is", "cached", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractCreator.java#L150-L196
3,153
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractCreator.java
AbstractCreator.constructorCallCode
private CodeBlock constructorCallCode( ClassName className, ImmutableList<? extends JParameterizedMapper> parameters ) { CodeBlock.Builder builder = CodeBlock.builder(); builder.add( "new $T", className ); return methodCallCodeWithJParameterizedMapperParameters( builder, parameters ); }
java
private CodeBlock constructorCallCode( ClassName className, ImmutableList<? extends JParameterizedMapper> parameters ) { CodeBlock.Builder builder = CodeBlock.builder(); builder.add( "new $T", className ); return methodCallCodeWithJParameterizedMapperParameters( builder, parameters ); }
[ "private", "CodeBlock", "constructorCallCode", "(", "ClassName", "className", ",", "ImmutableList", "<", "?", "extends", "JParameterizedMapper", ">", "parameters", ")", "{", "CodeBlock", ".", "Builder", "builder", "=", "CodeBlock", ".", "builder", "(", ")", ";", "builder", ".", "add", "(", "\"new $T\"", ",", "className", ")", ";", "return", "methodCallCodeWithJParameterizedMapperParameters", "(", "builder", ",", "parameters", ")", ";", "}" ]
Build the code to call the constructor of a class @param className the class to call @param parameters the parameters of the constructor @return the code calling the constructor
[ "Build", "the", "code", "to", "call", "the", "constructor", "of", "a", "class" ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractCreator.java#L855-L859
3,154
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractCreator.java
AbstractCreator.initMethodCallCode
private CodeBlock.Builder initMethodCallCode( MapperInstance instance ) { CodeBlock.Builder builder = CodeBlock.builder(); if ( null == instance.getInstanceCreationMethod().isConstructor() ) { builder.add( "$T.$L", rawName( instance.getMapperType() ), instance.getInstanceCreationMethod().getName() ); } else { builder.add( "new $T", typeName( instance.getMapperType() ) ); } return builder; }
java
private CodeBlock.Builder initMethodCallCode( MapperInstance instance ) { CodeBlock.Builder builder = CodeBlock.builder(); if ( null == instance.getInstanceCreationMethod().isConstructor() ) { builder.add( "$T.$L", rawName( instance.getMapperType() ), instance.getInstanceCreationMethod().getName() ); } else { builder.add( "new $T", typeName( instance.getMapperType() ) ); } return builder; }
[ "private", "CodeBlock", ".", "Builder", "initMethodCallCode", "(", "MapperInstance", "instance", ")", "{", "CodeBlock", ".", "Builder", "builder", "=", "CodeBlock", ".", "builder", "(", ")", ";", "if", "(", "null", "==", "instance", ".", "getInstanceCreationMethod", "(", ")", ".", "isConstructor", "(", ")", ")", "{", "builder", ".", "add", "(", "\"$T.$L\"", ",", "rawName", "(", "instance", ".", "getMapperType", "(", ")", ")", ",", "instance", ".", "getInstanceCreationMethod", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "else", "{", "builder", ".", "add", "(", "\"new $T\"", ",", "typeName", "(", "instance", ".", "getMapperType", "(", ")", ")", ")", ";", "}", "return", "builder", ";", "}" ]
Initialize the code builder to create a mapper. @param instance the class to call @return the code builder to create the mapper
[ "Initialize", "the", "code", "builder", "to", "create", "a", "mapper", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractCreator.java#L868-L876
3,155
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/utils/Base64Utils.java
Base64Utils.fromBase64
public static byte[] fromBase64(String data) { if (data == null) { return null; } int len = data.length(); assert (len % 4) == 0; if (len == 0) { return new byte[0]; } char[] chars = new char[len]; data.getChars(0, len, chars, 0); int olen = 3 * (len / 4); if (chars[len - 2] == '=') { --olen; } if (chars[len - 1] == '=') { --olen; } byte[] bytes = new byte[olen]; int iidx = 0; int oidx = 0; while (iidx < len) { int c0 = base64Values[chars[iidx++] & 0xff]; int c1 = base64Values[chars[iidx++] & 0xff]; int c2 = base64Values[chars[iidx++] & 0xff]; int c3 = base64Values[chars[iidx++] & 0xff]; int c24 = (c0 << 18) | (c1 << 12) | (c2 << 6) | c3; bytes[oidx++] = (byte) (c24 >> 16); if (oidx == olen) { break; } bytes[oidx++] = (byte) (c24 >> 8); if (oidx == olen) { break; } bytes[oidx++] = (byte) c24; } return bytes; }
java
public static byte[] fromBase64(String data) { if (data == null) { return null; } int len = data.length(); assert (len % 4) == 0; if (len == 0) { return new byte[0]; } char[] chars = new char[len]; data.getChars(0, len, chars, 0); int olen = 3 * (len / 4); if (chars[len - 2] == '=') { --olen; } if (chars[len - 1] == '=') { --olen; } byte[] bytes = new byte[olen]; int iidx = 0; int oidx = 0; while (iidx < len) { int c0 = base64Values[chars[iidx++] & 0xff]; int c1 = base64Values[chars[iidx++] & 0xff]; int c2 = base64Values[chars[iidx++] & 0xff]; int c3 = base64Values[chars[iidx++] & 0xff]; int c24 = (c0 << 18) | (c1 << 12) | (c2 << 6) | c3; bytes[oidx++] = (byte) (c24 >> 16); if (oidx == olen) { break; } bytes[oidx++] = (byte) (c24 >> 8); if (oidx == olen) { break; } bytes[oidx++] = (byte) c24; } return bytes; }
[ "public", "static", "byte", "[", "]", "fromBase64", "(", "String", "data", ")", "{", "if", "(", "data", "==", "null", ")", "{", "return", "null", ";", "}", "int", "len", "=", "data", ".", "length", "(", ")", ";", "assert", "(", "len", "%", "4", ")", "==", "0", ";", "if", "(", "len", "==", "0", ")", "{", "return", "new", "byte", "[", "0", "]", ";", "}", "char", "[", "]", "chars", "=", "new", "char", "[", "len", "]", ";", "data", ".", "getChars", "(", "0", ",", "len", ",", "chars", ",", "0", ")", ";", "int", "olen", "=", "3", "*", "(", "len", "/", "4", ")", ";", "if", "(", "chars", "[", "len", "-", "2", "]", "==", "'", "'", ")", "{", "--", "olen", ";", "}", "if", "(", "chars", "[", "len", "-", "1", "]", "==", "'", "'", ")", "{", "--", "olen", ";", "}", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "olen", "]", ";", "int", "iidx", "=", "0", ";", "int", "oidx", "=", "0", ";", "while", "(", "iidx", "<", "len", ")", "{", "int", "c0", "=", "base64Values", "[", "chars", "[", "iidx", "++", "]", "&", "0xff", "]", ";", "int", "c1", "=", "base64Values", "[", "chars", "[", "iidx", "++", "]", "&", "0xff", "]", ";", "int", "c2", "=", "base64Values", "[", "chars", "[", "iidx", "++", "]", "&", "0xff", "]", ";", "int", "c3", "=", "base64Values", "[", "chars", "[", "iidx", "++", "]", "&", "0xff", "]", ";", "int", "c24", "=", "(", "c0", "<<", "18", ")", "|", "(", "c1", "<<", "12", ")", "|", "(", "c2", "<<", "6", ")", "|", "c3", ";", "bytes", "[", "oidx", "++", "]", "=", "(", "byte", ")", "(", "c24", ">>", "16", ")", ";", "if", "(", "oidx", "==", "olen", ")", "{", "break", ";", "}", "bytes", "[", "oidx", "++", "]", "=", "(", "byte", ")", "(", "c24", ">>", "8", ")", ";", "if", "(", "oidx", "==", "olen", ")", "{", "break", ";", "}", "bytes", "[", "oidx", "++", "]", "=", "(", "byte", ")", "c24", ";", "}", "return", "bytes", ";", "}" ]
Decode a base64 string into a byte array. @param data the encoded data. @return a byte array. @see #fromBase64(String)
[ "Decode", "a", "base64", "string", "into", "a", "byte", "array", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/client/utils/Base64Utils.java#L71-L117
3,156
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/BeanJsonDeserializerCreator.java
BeanJsonDeserializerCreator.buildNewInstanceMethodForBuilder
private void buildNewInstanceMethodForBuilder( MethodSpec.Builder newInstanceMethodBuilder ) { newInstanceMethodBuilder.addStatement( "return new $T(builderDeserializer.deserializeInline(reader, ctx, params, null, null, null, bufferedProperties).build(), bufferedProperties)", parameterizedName( Instance.class, beanInfo.getType() ) ); }
java
private void buildNewInstanceMethodForBuilder( MethodSpec.Builder newInstanceMethodBuilder ) { newInstanceMethodBuilder.addStatement( "return new $T(builderDeserializer.deserializeInline(reader, ctx, params, null, null, null, bufferedProperties).build(), bufferedProperties)", parameterizedName( Instance.class, beanInfo.getType() ) ); }
[ "private", "void", "buildNewInstanceMethodForBuilder", "(", "MethodSpec", ".", "Builder", "newInstanceMethodBuilder", ")", "{", "newInstanceMethodBuilder", ".", "addStatement", "(", "\"return new $T(builderDeserializer.deserializeInline(reader, ctx, params, null, null, null, bufferedProperties).build(), bufferedProperties)\"", ",", "parameterizedName", "(", "Instance", ".", "class", ",", "beanInfo", ".", "getType", "(", ")", ")", ")", ";", "}" ]
Generate the instance builder class body for a builder. @param newInstanceMethodBuilder builder for the {@link InstanceBuilder#newInstance(JsonReader, JsonDeserializationContext, JsonDeserializerParameters, Map, Map)} method
[ "Generate", "the", "instance", "builder", "class", "body", "for", "a", "builder", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/BeanJsonDeserializerCreator.java#L268-L271
3,157
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/BeanJsonDeserializerCreator.java
BeanJsonDeserializerCreator.buildNewInstanceMethodForDefaultConstructor
private void buildNewInstanceMethodForDefaultConstructor( MethodSpec.Builder newInstanceMethodBuilder, MethodSpec createMethod ) { newInstanceMethodBuilder.addStatement( "return new $T($N(), bufferedProperties)", parameterizedName( Instance.class, beanInfo.getType() ), createMethod ); }
java
private void buildNewInstanceMethodForDefaultConstructor( MethodSpec.Builder newInstanceMethodBuilder, MethodSpec createMethod ) { newInstanceMethodBuilder.addStatement( "return new $T($N(), bufferedProperties)", parameterizedName( Instance.class, beanInfo.getType() ), createMethod ); }
[ "private", "void", "buildNewInstanceMethodForDefaultConstructor", "(", "MethodSpec", ".", "Builder", "newInstanceMethodBuilder", ",", "MethodSpec", "createMethod", ")", "{", "newInstanceMethodBuilder", ".", "addStatement", "(", "\"return new $T($N(), bufferedProperties)\"", ",", "parameterizedName", "(", "Instance", ".", "class", ",", "beanInfo", ".", "getType", "(", ")", ")", ",", "createMethod", ")", ";", "}" ]
Generate the instance builder class body for a default constructor. We directly instantiate the bean at the builder creation and we set the properties to it @param newInstanceMethodBuilder builder for the {@link InstanceBuilder#newInstance(JsonReader, JsonDeserializationContext, JsonDeserializerParameters, Map, Map)} method @param createMethod the create method
[ "Generate", "the", "instance", "builder", "class", "body", "for", "a", "default", "constructor", ".", "We", "directly", "instantiate", "the", "bean", "at", "the", "builder", "creation", "and", "we", "set", "the", "properties", "to", "it" ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/BeanJsonDeserializerCreator.java#L282-L285
3,158
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/BeanJsonDeserializerCreator.java
BeanJsonDeserializerCreator.buildNewInstanceMethodForConstructorOrFactoryMethodDelegation
private void buildNewInstanceMethodForConstructorOrFactoryMethodDelegation( MethodSpec.Builder newInstanceMethodBuilder, MethodSpec createMethod ) { String param = String.format( "%s%s.deserialize(reader, ctx)", INSTANCE_BUILDER_DESERIALIZER_PREFIX, String .format( INSTANCE_BUILDER_VARIABLE_FORMAT, 0 ) ); newInstanceMethodBuilder.addStatement( "return new $T($N($L), bufferedProperties)", parameterizedName( Instance.class, beanInfo.getType() ), createMethod, param ); }
java
private void buildNewInstanceMethodForConstructorOrFactoryMethodDelegation( MethodSpec.Builder newInstanceMethodBuilder, MethodSpec createMethod ) { String param = String.format( "%s%s.deserialize(reader, ctx)", INSTANCE_BUILDER_DESERIALIZER_PREFIX, String .format( INSTANCE_BUILDER_VARIABLE_FORMAT, 0 ) ); newInstanceMethodBuilder.addStatement( "return new $T($N($L), bufferedProperties)", parameterizedName( Instance.class, beanInfo.getType() ), createMethod, param ); }
[ "private", "void", "buildNewInstanceMethodForConstructorOrFactoryMethodDelegation", "(", "MethodSpec", ".", "Builder", "newInstanceMethodBuilder", ",", "MethodSpec", "createMethod", ")", "{", "String", "param", "=", "String", ".", "format", "(", "\"%s%s.deserialize(reader, ctx)\"", ",", "INSTANCE_BUILDER_DESERIALIZER_PREFIX", ",", "String", ".", "format", "(", "INSTANCE_BUILDER_VARIABLE_FORMAT", ",", "0", ")", ")", ";", "newInstanceMethodBuilder", ".", "addStatement", "(", "\"return new $T($N($L), bufferedProperties)\"", ",", "parameterizedName", "(", "Instance", ".", "class", ",", "beanInfo", ".", "getType", "(", ")", ")", ",", "createMethod", ",", "param", ")", ";", "}" ]
Generate the instance builder class body for a constructor or factory method with delegation. @param newInstanceMethodBuilder builder for the {@link InstanceBuilder#newInstance(JsonReader, JsonDeserializationContext, JsonDeserializerParameters, Map, Map)} method @param createMethod the create method
[ "Generate", "the", "instance", "builder", "class", "body", "for", "a", "constructor", "or", "factory", "method", "with", "delegation", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/BeanJsonDeserializerCreator.java#L437-L444
3,159
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractBeanJsonCreator.java
AbstractBeanJsonCreator.buildConstructor
private void buildConstructor( TypeSpec.Builder typeBuilder ) { MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder().addModifiers( Modifier.PUBLIC ); if ( !beanInfo.getParameterizedTypes().isEmpty() ) { Class mapperClass; String mapperNameFormat; if ( isSerializer() ) { mapperClass = Serializer.class; mapperNameFormat = TYPE_PARAMETER_SERIALIZER_FIELD_NAME; } else { mapperClass = Deserializer.class; mapperNameFormat = TYPE_PARAMETER_DESERIALIZER_FIELD_NAME; } for ( int i = 0; i < beanInfo.getParameterizedTypes().size(); i++ ) { JClassType argType = beanInfo.getParameterizedTypes().get( i ); String mapperName = String.format( mapperNameFormat, i ); TypeName mapperType = parameterizedName( mapperClass, argType ); FieldSpec field = FieldSpec.builder( mapperType, mapperName, Modifier.PRIVATE, Modifier.FINAL ).build(); typeBuilder.addField( field ); ParameterSpec parameter = ParameterSpec.builder( mapperType, mapperName ).build(); constructorBuilder.addParameter( parameter ); constructorBuilder.addStatement( "this.$N = $N", field, parameter ); } } typeBuilder.addMethod( constructorBuilder.build() ); }
java
private void buildConstructor( TypeSpec.Builder typeBuilder ) { MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder().addModifiers( Modifier.PUBLIC ); if ( !beanInfo.getParameterizedTypes().isEmpty() ) { Class mapperClass; String mapperNameFormat; if ( isSerializer() ) { mapperClass = Serializer.class; mapperNameFormat = TYPE_PARAMETER_SERIALIZER_FIELD_NAME; } else { mapperClass = Deserializer.class; mapperNameFormat = TYPE_PARAMETER_DESERIALIZER_FIELD_NAME; } for ( int i = 0; i < beanInfo.getParameterizedTypes().size(); i++ ) { JClassType argType = beanInfo.getParameterizedTypes().get( i ); String mapperName = String.format( mapperNameFormat, i ); TypeName mapperType = parameterizedName( mapperClass, argType ); FieldSpec field = FieldSpec.builder( mapperType, mapperName, Modifier.PRIVATE, Modifier.FINAL ).build(); typeBuilder.addField( field ); ParameterSpec parameter = ParameterSpec.builder( mapperType, mapperName ).build(); constructorBuilder.addParameter( parameter ); constructorBuilder.addStatement( "this.$N = $N", field, parameter ); } } typeBuilder.addMethod( constructorBuilder.build() ); }
[ "private", "void", "buildConstructor", "(", "TypeSpec", ".", "Builder", "typeBuilder", ")", "{", "MethodSpec", ".", "Builder", "constructorBuilder", "=", "MethodSpec", ".", "constructorBuilder", "(", ")", ".", "addModifiers", "(", "Modifier", ".", "PUBLIC", ")", ";", "if", "(", "!", "beanInfo", ".", "getParameterizedTypes", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "Class", "mapperClass", ";", "String", "mapperNameFormat", ";", "if", "(", "isSerializer", "(", ")", ")", "{", "mapperClass", "=", "Serializer", ".", "class", ";", "mapperNameFormat", "=", "TYPE_PARAMETER_SERIALIZER_FIELD_NAME", ";", "}", "else", "{", "mapperClass", "=", "Deserializer", ".", "class", ";", "mapperNameFormat", "=", "TYPE_PARAMETER_DESERIALIZER_FIELD_NAME", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "beanInfo", ".", "getParameterizedTypes", "(", ")", ".", "size", "(", ")", ";", "i", "++", ")", "{", "JClassType", "argType", "=", "beanInfo", ".", "getParameterizedTypes", "(", ")", ".", "get", "(", "i", ")", ";", "String", "mapperName", "=", "String", ".", "format", "(", "mapperNameFormat", ",", "i", ")", ";", "TypeName", "mapperType", "=", "parameterizedName", "(", "mapperClass", ",", "argType", ")", ";", "FieldSpec", "field", "=", "FieldSpec", ".", "builder", "(", "mapperType", ",", "mapperName", ",", "Modifier", ".", "PRIVATE", ",", "Modifier", ".", "FINAL", ")", ".", "build", "(", ")", ";", "typeBuilder", ".", "addField", "(", "field", ")", ";", "ParameterSpec", "parameter", "=", "ParameterSpec", ".", "builder", "(", "mapperType", ",", "mapperName", ")", ".", "build", "(", ")", ";", "constructorBuilder", ".", "addParameter", "(", "parameter", ")", ";", "constructorBuilder", ".", "addStatement", "(", "\"this.$N = $N\"", ",", "field", ",", "parameter", ")", ";", "}", "}", "typeBuilder", ".", "addMethod", "(", "constructorBuilder", ".", "build", "(", ")", ")", ";", "}" ]
Build the constructor and the final fields. @param typeBuilder the type builder
[ "Build", "the", "constructor", "and", "the", "final", "fields", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractBeanJsonCreator.java#L194-L223
3,160
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractBeanJsonCreator.java
AbstractBeanJsonCreator.buildClassGetterMethod
private MethodSpec buildClassGetterMethod() { return MethodSpec.methodBuilder( isSerializer() ? "getSerializedType" : "getDeserializedType" ) .addModifiers( Modifier.PUBLIC ) .addAnnotation( Override.class ) .returns( Class.class ) .addStatement( "return $T.class", rawName( beanInfo.getType() ) ) .build(); }
java
private MethodSpec buildClassGetterMethod() { return MethodSpec.methodBuilder( isSerializer() ? "getSerializedType" : "getDeserializedType" ) .addModifiers( Modifier.PUBLIC ) .addAnnotation( Override.class ) .returns( Class.class ) .addStatement( "return $T.class", rawName( beanInfo.getType() ) ) .build(); }
[ "private", "MethodSpec", "buildClassGetterMethod", "(", ")", "{", "return", "MethodSpec", ".", "methodBuilder", "(", "isSerializer", "(", ")", "?", "\"getSerializedType\"", ":", "\"getDeserializedType\"", ")", ".", "addModifiers", "(", "Modifier", ".", "PUBLIC", ")", ".", "addAnnotation", "(", "Override", ".", "class", ")", ".", "returns", "(", "Class", ".", "class", ")", ".", "addStatement", "(", "\"return $T.class\"", ",", "rawName", "(", "beanInfo", ".", "getType", "(", ")", ")", ")", ".", "build", "(", ")", ";", "}" ]
Build the method that returns the class of the mapped type. @return the method built
[ "Build", "the", "method", "that", "returns", "the", "class", "of", "the", "mapped", "type", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractBeanJsonCreator.java#L230-L237
3,161
nmorel/gwt-jackson
gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractBeanJsonCreator.java
AbstractBeanJsonCreator.buildCommonPropertyParameters
protected final void buildCommonPropertyParameters( CodeBlock.Builder paramBuilder, PropertyInfo property ) { if ( property.getFormat().isPresent() ) { JsonFormat format = property.getFormat().get(); if ( !Strings.isNullOrEmpty( format.pattern() ) ) { paramBuilder.add( "\n.setPattern($S)", format.pattern() ); } paramBuilder.add( "\n.setShape($T.$L)", Shape.class, format.shape().name() ); if ( !Strings.isNullOrEmpty( format.locale() ) && !JsonFormat.DEFAULT_LOCALE.equals( format.locale() ) ) { logger.log( Type.WARN, "JsonFormat.locale is not supported by default" ); paramBuilder.add( "\n.setLocale($S)", format.locale() ); } } if ( property.getIgnoredProperties().isPresent() ) { for ( String ignoredProperty : property.getIgnoredProperties().get() ) { paramBuilder.add( "\n.addIgnoredProperty($S)", ignoredProperty ); } } }
java
protected final void buildCommonPropertyParameters( CodeBlock.Builder paramBuilder, PropertyInfo property ) { if ( property.getFormat().isPresent() ) { JsonFormat format = property.getFormat().get(); if ( !Strings.isNullOrEmpty( format.pattern() ) ) { paramBuilder.add( "\n.setPattern($S)", format.pattern() ); } paramBuilder.add( "\n.setShape($T.$L)", Shape.class, format.shape().name() ); if ( !Strings.isNullOrEmpty( format.locale() ) && !JsonFormat.DEFAULT_LOCALE.equals( format.locale() ) ) { logger.log( Type.WARN, "JsonFormat.locale is not supported by default" ); paramBuilder.add( "\n.setLocale($S)", format.locale() ); } } if ( property.getIgnoredProperties().isPresent() ) { for ( String ignoredProperty : property.getIgnoredProperties().get() ) { paramBuilder.add( "\n.addIgnoredProperty($S)", ignoredProperty ); } } }
[ "protected", "final", "void", "buildCommonPropertyParameters", "(", "CodeBlock", ".", "Builder", "paramBuilder", ",", "PropertyInfo", "property", ")", "{", "if", "(", "property", ".", "getFormat", "(", ")", ".", "isPresent", "(", ")", ")", "{", "JsonFormat", "format", "=", "property", ".", "getFormat", "(", ")", ".", "get", "(", ")", ";", "if", "(", "!", "Strings", ".", "isNullOrEmpty", "(", "format", ".", "pattern", "(", ")", ")", ")", "{", "paramBuilder", ".", "add", "(", "\"\\n.setPattern($S)\"", ",", "format", ".", "pattern", "(", ")", ")", ";", "}", "paramBuilder", ".", "add", "(", "\"\\n.setShape($T.$L)\"", ",", "Shape", ".", "class", ",", "format", ".", "shape", "(", ")", ".", "name", "(", ")", ")", ";", "if", "(", "!", "Strings", ".", "isNullOrEmpty", "(", "format", ".", "locale", "(", ")", ")", "&&", "!", "JsonFormat", ".", "DEFAULT_LOCALE", ".", "equals", "(", "format", ".", "locale", "(", ")", ")", ")", "{", "logger", ".", "log", "(", "Type", ".", "WARN", ",", "\"JsonFormat.locale is not supported by default\"", ")", ";", "paramBuilder", ".", "add", "(", "\"\\n.setLocale($S)\"", ",", "format", ".", "locale", "(", ")", ")", ";", "}", "}", "if", "(", "property", ".", "getIgnoredProperties", "(", ")", ".", "isPresent", "(", ")", ")", "{", "for", "(", "String", "ignoredProperty", ":", "property", ".", "getIgnoredProperties", "(", ")", ".", "get", "(", ")", ")", "{", "paramBuilder", ".", "add", "(", "\"\\n.addIgnoredProperty($S)\"", ",", "ignoredProperty", ")", ";", "}", "}", "}" ]
Add the common property parameters to the code builder. @param paramBuilder the code builder @param property the information about the property
[ "Add", "the", "common", "property", "parameters", "to", "the", "code", "builder", "." ]
3fdc4350a27a9b64fc437d5fe516bf9191b74824
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/AbstractBeanJsonCreator.java#L284-L305
3,162
wouterd/docker-maven-plugin
src/main/java/net/wouterdanes/docker/remoteapi/MiscService.java
MiscService.getVersionInfo
public DockerVersionInfo getVersionInfo() { String json = getServiceEndPoint() .path("/version") .request(MediaType.APPLICATION_JSON_TYPE) .get(String.class); return toObject(json, DockerVersionInfo.class); }
java
public DockerVersionInfo getVersionInfo() { String json = getServiceEndPoint() .path("/version") .request(MediaType.APPLICATION_JSON_TYPE) .get(String.class); return toObject(json, DockerVersionInfo.class); }
[ "public", "DockerVersionInfo", "getVersionInfo", "(", ")", "{", "String", "json", "=", "getServiceEndPoint", "(", ")", ".", "path", "(", "\"/version\"", ")", ".", "request", "(", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "get", "(", "String", ".", "class", ")", ";", "return", "toObject", "(", "json", ",", "DockerVersionInfo", ".", "class", ")", ";", "}" ]
Returns the Docker version information @return a {@link DockerVersionInfo} instance describing this docker installation.
[ "Returns", "the", "Docker", "version", "information" ]
ea15f9e6c273989bb91f4228fb52cb73d00e07b3
https://github.com/wouterd/docker-maven-plugin/blob/ea15f9e6c273989bb91f4228fb52cb73d00e07b3/src/main/java/net/wouterdanes/docker/remoteapi/MiscService.java#L69-L76
3,163
wouterd/docker-maven-plugin
src/main/java/net/wouterdanes/docker/remoteapi/MiscService.java
MiscService.commitContainer
public String commitContainer( String container, Optional<String> repo, Optional<String> tag, Optional<String> comment, Optional<String> author) { WebTarget request = getServiceEndPoint() .path("/commit") .queryParam("container", container) .queryParam("repo", repo.orElse(null)) .queryParam("tag", tag.orElse(null)) .queryParam("comment", comment.orElse(null)) .queryParam("author", author.orElse(null)); String json = request .request(MediaType.APPLICATION_JSON_TYPE) .method(HttpMethod.POST, String.class); ContainerCommitResponse result = toObject(json, ContainerCommitResponse.class); return result.getId(); }
java
public String commitContainer( String container, Optional<String> repo, Optional<String> tag, Optional<String> comment, Optional<String> author) { WebTarget request = getServiceEndPoint() .path("/commit") .queryParam("container", container) .queryParam("repo", repo.orElse(null)) .queryParam("tag", tag.orElse(null)) .queryParam("comment", comment.orElse(null)) .queryParam("author", author.orElse(null)); String json = request .request(MediaType.APPLICATION_JSON_TYPE) .method(HttpMethod.POST, String.class); ContainerCommitResponse result = toObject(json, ContainerCommitResponse.class); return result.getId(); }
[ "public", "String", "commitContainer", "(", "String", "container", ",", "Optional", "<", "String", ">", "repo", ",", "Optional", "<", "String", ">", "tag", ",", "Optional", "<", "String", ">", "comment", ",", "Optional", "<", "String", ">", "author", ")", "{", "WebTarget", "request", "=", "getServiceEndPoint", "(", ")", ".", "path", "(", "\"/commit\"", ")", ".", "queryParam", "(", "\"container\"", ",", "container", ")", ".", "queryParam", "(", "\"repo\"", ",", "repo", ".", "orElse", "(", "null", ")", ")", ".", "queryParam", "(", "\"tag\"", ",", "tag", ".", "orElse", "(", "null", ")", ")", ".", "queryParam", "(", "\"comment\"", ",", "comment", ".", "orElse", "(", "null", ")", ")", ".", "queryParam", "(", "\"author\"", ",", "author", ".", "orElse", "(", "null", ")", ")", ";", "String", "json", "=", "request", ".", "request", "(", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "method", "(", "HttpMethod", ".", "POST", ",", "String", ".", "class", ")", ";", "ContainerCommitResponse", "result", "=", "toObject", "(", "json", ",", "ContainerCommitResponse", ".", "class", ")", ";", "return", "result", ".", "getId", "(", ")", ";", "}" ]
Create a new image from a container's changes @param container source container @param repo repository @param tag tag @param comment commit message @param author author (e.g., "John Hannibal Smith &lt;[email protected]&gt;") @return the ID of the created image
[ "Create", "a", "new", "image", "from", "a", "container", "s", "changes" ]
ea15f9e6c273989bb91f4228fb52cb73d00e07b3
https://github.com/wouterd/docker-maven-plugin/blob/ea15f9e6c273989bb91f4228fb52cb73d00e07b3/src/main/java/net/wouterdanes/docker/remoteapi/MiscService.java#L89-L111
3,164
wouterd/docker-maven-plugin
src/main/java/net/wouterdanes/docker/remoteapi/MiscService.java
MiscService.buildImage
public String buildImage(byte[] tarArchive, Optional<String> name, Optional<String> buildArguments) { Response response = getServiceEndPoint() .path("/build") .queryParam("q", true) .queryParam("t", name.orElse(null)) .queryParam("buildargs", UriComponent.encode(buildArguments.orElse(null), UriComponent.Type.QUERY_PARAM_SPACE_ENCODED)) .queryParam("forcerm") .request(MediaType.APPLICATION_JSON_TYPE) .header(REGISTRY_AUTH_HEADER, getRegistryAuthHeaderValue()) .post(Entity.entity(tarArchive, "application/tar")); InputStream inputStream = (InputStream) response.getEntity(); String imageId = parseSteamForImageId(inputStream); if (imageId == null) { throw new DockerException("Can't obtain ID from build output stream."); } return imageId; }
java
public String buildImage(byte[] tarArchive, Optional<String> name, Optional<String> buildArguments) { Response response = getServiceEndPoint() .path("/build") .queryParam("q", true) .queryParam("t", name.orElse(null)) .queryParam("buildargs", UriComponent.encode(buildArguments.orElse(null), UriComponent.Type.QUERY_PARAM_SPACE_ENCODED)) .queryParam("forcerm") .request(MediaType.APPLICATION_JSON_TYPE) .header(REGISTRY_AUTH_HEADER, getRegistryAuthHeaderValue()) .post(Entity.entity(tarArchive, "application/tar")); InputStream inputStream = (InputStream) response.getEntity(); String imageId = parseSteamForImageId(inputStream); if (imageId == null) { throw new DockerException("Can't obtain ID from build output stream."); } return imageId; }
[ "public", "String", "buildImage", "(", "byte", "[", "]", "tarArchive", ",", "Optional", "<", "String", ">", "name", ",", "Optional", "<", "String", ">", "buildArguments", ")", "{", "Response", "response", "=", "getServiceEndPoint", "(", ")", ".", "path", "(", "\"/build\"", ")", ".", "queryParam", "(", "\"q\"", ",", "true", ")", ".", "queryParam", "(", "\"t\"", ",", "name", ".", "orElse", "(", "null", ")", ")", ".", "queryParam", "(", "\"buildargs\"", ",", "UriComponent", ".", "encode", "(", "buildArguments", ".", "orElse", "(", "null", ")", ",", "UriComponent", ".", "Type", ".", "QUERY_PARAM_SPACE_ENCODED", ")", ")", ".", "queryParam", "(", "\"forcerm\"", ")", ".", "request", "(", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "header", "(", "REGISTRY_AUTH_HEADER", ",", "getRegistryAuthHeaderValue", "(", ")", ")", ".", "post", "(", "Entity", ".", "entity", "(", "tarArchive", ",", "\"application/tar\"", ")", ")", ";", "InputStream", "inputStream", "=", "(", "InputStream", ")", "response", ".", "getEntity", "(", ")", ";", "String", "imageId", "=", "parseSteamForImageId", "(", "inputStream", ")", ";", "if", "(", "imageId", "==", "null", ")", "{", "throw", "new", "DockerException", "(", "\"Can't obtain ID from build output stream.\"", ")", ";", "}", "return", "imageId", ";", "}" ]
Builds an image based on the passed tar archive. Optionally names &amp; tags the image @param tarArchive the tar archive to use as a source for the image @param name the name and optional tag of the image. @param buildArguments a list of optional build arguments made available to the Dockerfile. @return the ID of the created image
[ "Builds", "an", "image", "based", "on", "the", "passed", "tar", "archive", ".", "Optionally", "names", "&amp", ";", "tags", "the", "image" ]
ea15f9e6c273989bb91f4228fb52cb73d00e07b3
https://github.com/wouterd/docker-maven-plugin/blob/ea15f9e6c273989bb91f4228fb52cb73d00e07b3/src/main/java/net/wouterdanes/docker/remoteapi/MiscService.java#L121-L141
3,165
tmullender/ansible-maven-plugin
src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java
AbstractAnsibleMojo.execute
public void execute() throws MojoExecutionException, MojoFailureException { try { final List<String> command = createCommand(); checkWorkingDirectory(); final int status = execute(command); if (failOnAnsibleError && status != 0){ throw new MojoFailureException("Non-zero exit status returned"); } } catch (IOException e) { throw new MojoExecutionException("Unable to run playbook", e); } catch (InterruptedException e) { throw new MojoExecutionException("Run interrupted", e); } }
java
public void execute() throws MojoExecutionException, MojoFailureException { try { final List<String> command = createCommand(); checkWorkingDirectory(); final int status = execute(command); if (failOnAnsibleError && status != 0){ throw new MojoFailureException("Non-zero exit status returned"); } } catch (IOException e) { throw new MojoExecutionException("Unable to run playbook", e); } catch (InterruptedException e) { throw new MojoExecutionException("Run interrupted", e); } }
[ "public", "void", "execute", "(", ")", "throws", "MojoExecutionException", ",", "MojoFailureException", "{", "try", "{", "final", "List", "<", "String", ">", "command", "=", "createCommand", "(", ")", ";", "checkWorkingDirectory", "(", ")", ";", "final", "int", "status", "=", "execute", "(", "command", ")", ";", "if", "(", "failOnAnsibleError", "&&", "status", "!=", "0", ")", "{", "throw", "new", "MojoFailureException", "(", "\"Non-zero exit status returned\"", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Unable to run playbook\"", ",", "e", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Run interrupted\"", ",", "e", ")", ";", "}", "}" ]
Constructs a command from the configured parameters and executes it, logging output at debug @throws MojoExecutionException when unable to run the ansible command
[ "Constructs", "a", "command", "from", "the", "configured", "parameters", "and", "executes", "it", "logging", "output", "at", "debug" ]
6f6542b3c3c1558501f7b1f54601914b25d5be2d
https://github.com/tmullender/ansible-maven-plugin/blob/6f6542b3c3c1558501f7b1f54601914b25d5be2d/src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java#L137-L150
3,166
tmullender/ansible-maven-plugin
src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java
AbstractAnsibleMojo.addOptions
protected void addOptions(final List<String> command) { command.addAll(createOption("-c", connection)); command.addAll(createOption("-f", forks)); command.addAll(createOption("-i", inventory)); command.addAll(createOption("-l", limit)); command.addAll(createOption("-M", modulePath)); command.addAll(createOption("--private-key", privateKey)); command.addAll(createOption("-T", timeout)); command.addAll(createOption("-u", remoteUser)); command.addAll(createOption("--vault-password-file", vaultPasswordFile)); }
java
protected void addOptions(final List<String> command) { command.addAll(createOption("-c", connection)); command.addAll(createOption("-f", forks)); command.addAll(createOption("-i", inventory)); command.addAll(createOption("-l", limit)); command.addAll(createOption("-M", modulePath)); command.addAll(createOption("--private-key", privateKey)); command.addAll(createOption("-T", timeout)); command.addAll(createOption("-u", remoteUser)); command.addAll(createOption("--vault-password-file", vaultPasswordFile)); }
[ "protected", "void", "addOptions", "(", "final", "List", "<", "String", ">", "command", ")", "{", "command", ".", "addAll", "(", "createOption", "(", "\"-c\"", ",", "connection", ")", ")", ";", "command", ".", "addAll", "(", "createOption", "(", "\"-f\"", ",", "forks", ")", ")", ";", "command", ".", "addAll", "(", "createOption", "(", "\"-i\"", ",", "inventory", ")", ")", ";", "command", ".", "addAll", "(", "createOption", "(", "\"-l\"", ",", "limit", ")", ")", ";", "command", ".", "addAll", "(", "createOption", "(", "\"-M\"", ",", "modulePath", ")", ")", ";", "command", ".", "addAll", "(", "createOption", "(", "\"--private-key\"", ",", "privateKey", ")", ")", ";", "command", ".", "addAll", "(", "createOption", "(", "\"-T\"", ",", "timeout", ")", ")", ";", "command", ".", "addAll", "(", "createOption", "(", "\"-u\"", ",", "remoteUser", ")", ")", ";", "command", ".", "addAll", "(", "createOption", "(", "\"--vault-password-file\"", ",", "vaultPasswordFile", ")", ")", ";", "}" ]
Adds the configured options to the list of command strings @param command the existing command
[ "Adds", "the", "configured", "options", "to", "the", "list", "of", "command", "strings" ]
6f6542b3c3c1558501f7b1f54601914b25d5be2d
https://github.com/tmullender/ansible-maven-plugin/blob/6f6542b3c3c1558501f7b1f54601914b25d5be2d/src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java#L248-L258
3,167
tmullender/ansible-maven-plugin
src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java
AbstractAnsibleMojo.createOption
protected List<String> createOption(final String option, final List<String> values) { if (values == null){ return new ArrayList<String>(); } final List<String> list = new ArrayList<String>(); for (String value: values) { list.add(option); list.add(value); } return list; }
java
protected List<String> createOption(final String option, final List<String> values) { if (values == null){ return new ArrayList<String>(); } final List<String> list = new ArrayList<String>(); for (String value: values) { list.add(option); list.add(value); } return list; }
[ "protected", "List", "<", "String", ">", "createOption", "(", "final", "String", "option", ",", "final", "List", "<", "String", ">", "values", ")", "{", "if", "(", "values", "==", "null", ")", "{", "return", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "}", "final", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "value", ":", "values", ")", "{", "list", ".", "add", "(", "option", ")", ";", "list", ".", "add", "(", "value", ")", ";", "}", "return", "list", ";", "}" ]
Creates a list for the given option, an empty list if the option's values is null @param option the option to add @param values the values for the option @return a list of the strings for the given option, empty if the option should not be used
[ "Creates", "a", "list", "for", "the", "given", "option", "an", "empty", "list", "if", "the", "option", "s", "values", "is", "null" ]
6f6542b3c3c1558501f7b1f54601914b25d5be2d
https://github.com/tmullender/ansible-maven-plugin/blob/6f6542b3c3c1558501f7b1f54601914b25d5be2d/src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java#L279-L289
3,168
tmullender/ansible-maven-plugin
src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java
AbstractAnsibleMojo.findClasspathFile
protected String findClasspathFile(final String path) throws IOException { if (path == null){ return null; } final File file = new File(path); if (file.exists()){ return file.getAbsolutePath(); } return createTmpFile(path).getAbsolutePath(); }
java
protected String findClasspathFile(final String path) throws IOException { if (path == null){ return null; } final File file = new File(path); if (file.exists()){ return file.getAbsolutePath(); } return createTmpFile(path).getAbsolutePath(); }
[ "protected", "String", "findClasspathFile", "(", "final", "String", "path", ")", "throws", "IOException", "{", "if", "(", "path", "==", "null", ")", "{", "return", "null", ";", "}", "final", "File", "file", "=", "new", "File", "(", "path", ")", ";", "if", "(", "file", ".", "exists", "(", ")", ")", "{", "return", "file", ".", "getAbsolutePath", "(", ")", ";", "}", "return", "createTmpFile", "(", "path", ")", ".", "getAbsolutePath", "(", ")", ";", "}" ]
Checks whether the given file is an absolute path or a classpath file @param path the relative path @return the absolute path to the extracted file @throws IOException if the path can not be determined
[ "Checks", "whether", "the", "given", "file", "is", "an", "absolute", "path", "or", "a", "classpath", "file" ]
6f6542b3c3c1558501f7b1f54601914b25d5be2d
https://github.com/tmullender/ansible-maven-plugin/blob/6f6542b3c3c1558501f7b1f54601914b25d5be2d/src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java#L310-L319
3,169
tmullender/ansible-maven-plugin
src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java
AbstractAnsibleMojo.createTmpFile
private File createTmpFile(final String path) throws IOException { getLog().debug("Creating temporary file for: " + path); final File output = new File(System.getProperty("java.io.tmpdir"), "ansible-maven-plugin." + System.nanoTime()); final FileOutputStream outputStream = new FileOutputStream(output); final InputStream inputStream = getClass().getResourceAsStream("/" + path); if (inputStream == null){ throw new FileNotFoundException("Unable to locate: " + path); } copy(inputStream, outputStream); return output; }
java
private File createTmpFile(final String path) throws IOException { getLog().debug("Creating temporary file for: " + path); final File output = new File(System.getProperty("java.io.tmpdir"), "ansible-maven-plugin." + System.nanoTime()); final FileOutputStream outputStream = new FileOutputStream(output); final InputStream inputStream = getClass().getResourceAsStream("/" + path); if (inputStream == null){ throw new FileNotFoundException("Unable to locate: " + path); } copy(inputStream, outputStream); return output; }
[ "private", "File", "createTmpFile", "(", "final", "String", "path", ")", "throws", "IOException", "{", "getLog", "(", ")", ".", "debug", "(", "\"Creating temporary file for: \"", "+", "path", ")", ";", "final", "File", "output", "=", "new", "File", "(", "System", ".", "getProperty", "(", "\"java.io.tmpdir\"", ")", ",", "\"ansible-maven-plugin.\"", "+", "System", ".", "nanoTime", "(", ")", ")", ";", "final", "FileOutputStream", "outputStream", "=", "new", "FileOutputStream", "(", "output", ")", ";", "final", "InputStream", "inputStream", "=", "getClass", "(", ")", ".", "getResourceAsStream", "(", "\"/\"", "+", "path", ")", ";", "if", "(", "inputStream", "==", "null", ")", "{", "throw", "new", "FileNotFoundException", "(", "\"Unable to locate: \"", "+", "path", ")", ";", "}", "copy", "(", "inputStream", ",", "outputStream", ")", ";", "return", "output", ";", "}" ]
Copies a classpath resource to the tmp directory to allow it to be run by ansible @param path the relative path @return the File object representing the extracted file @throws IOException if the path is not found
[ "Copies", "a", "classpath", "resource", "to", "the", "tmp", "directory", "to", "allow", "it", "to", "be", "run", "by", "ansible" ]
6f6542b3c3c1558501f7b1f54601914b25d5be2d
https://github.com/tmullender/ansible-maven-plugin/blob/6f6542b3c3c1558501f7b1f54601914b25d5be2d/src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java#L327-L337
3,170
tmullender/ansible-maven-plugin
src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java
AbstractAnsibleMojo.copy
private void copy(final InputStream inputStream, final FileOutputStream outputStream) throws IOException { final byte[] buffer = new byte[1024*4]; int n; try { while (-1 != (n = inputStream.read(buffer))) { outputStream.write(buffer, 0, n); } } finally { inputStream.close(); outputStream.close(); } }
java
private void copy(final InputStream inputStream, final FileOutputStream outputStream) throws IOException { final byte[] buffer = new byte[1024*4]; int n; try { while (-1 != (n = inputStream.read(buffer))) { outputStream.write(buffer, 0, n); } } finally { inputStream.close(); outputStream.close(); } }
[ "private", "void", "copy", "(", "final", "InputStream", "inputStream", ",", "final", "FileOutputStream", "outputStream", ")", "throws", "IOException", "{", "final", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "1024", "*", "4", "]", ";", "int", "n", ";", "try", "{", "while", "(", "-", "1", "!=", "(", "n", "=", "inputStream", ".", "read", "(", "buffer", ")", ")", ")", "{", "outputStream", ".", "write", "(", "buffer", ",", "0", ",", "n", ")", ";", "}", "}", "finally", "{", "inputStream", ".", "close", "(", ")", ";", "outputStream", ".", "close", "(", ")", ";", "}", "}" ]
Copies the input stream to the output stream using a 4K buffer @param inputStream the stream to copy @param outputStream the stream to write to @throws IOException if there is an exception reading or writing
[ "Copies", "the", "input", "stream", "to", "the", "output", "stream", "using", "a", "4K", "buffer" ]
6f6542b3c3c1558501f7b1f54601914b25d5be2d
https://github.com/tmullender/ansible-maven-plugin/blob/6f6542b3c3c1558501f7b1f54601914b25d5be2d/src/main/java/co/escapeideas/maven/ansible/AbstractAnsibleMojo.java#L345-L356
3,171
WASdev/ci.gradle
src/main/groovy/net/wasdev/wlp/gradle/plugins/utils/ServerConfigDocument.java
ServerConfigDocument.parseNames
private void parseNames(Document doc, String expression) throws XPathExpressionException, IOException, SAXException { // parse input document XPath xPath = XPathFactory.newInstance().newXPath(); NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { if (nodeList.item(i).getAttributes().getNamedItem("name") != null) { String nodeValue = nodeList.item(i).getAttributes().getNamedItem("name").getNodeValue(); // add unique values only if (!nodeValue.isEmpty()) { String resolved = getResolvedVariable(nodeValue); if (!names.contains(resolved)) { names.add(resolved); } } } else { String nodeValue = nodeList.item(i).getAttributes().getNamedItem("location").getNodeValue(); // add unique values only if (!nodeValue.isEmpty()) { String resolved = getResolvedVariable(nodeValue); if (!namelessLocations.contains(resolved)) { namelessLocations.add(resolved); } } } } }
java
private void parseNames(Document doc, String expression) throws XPathExpressionException, IOException, SAXException { // parse input document XPath xPath = XPathFactory.newInstance().newXPath(); NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { if (nodeList.item(i).getAttributes().getNamedItem("name") != null) { String nodeValue = nodeList.item(i).getAttributes().getNamedItem("name").getNodeValue(); // add unique values only if (!nodeValue.isEmpty()) { String resolved = getResolvedVariable(nodeValue); if (!names.contains(resolved)) { names.add(resolved); } } } else { String nodeValue = nodeList.item(i).getAttributes().getNamedItem("location").getNodeValue(); // add unique values only if (!nodeValue.isEmpty()) { String resolved = getResolvedVariable(nodeValue); if (!namelessLocations.contains(resolved)) { namelessLocations.add(resolved); } } } } }
[ "private", "void", "parseNames", "(", "Document", "doc", ",", "String", "expression", ")", "throws", "XPathExpressionException", ",", "IOException", ",", "SAXException", "{", "// parse input document", "XPath", "xPath", "=", "XPathFactory", ".", "newInstance", "(", ")", ".", "newXPath", "(", ")", ";", "NodeList", "nodeList", "=", "(", "NodeList", ")", "xPath", ".", "compile", "(", "expression", ")", ".", "evaluate", "(", "doc", ",", "XPathConstants", ".", "NODESET", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodeList", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "if", "(", "nodeList", ".", "item", "(", "i", ")", ".", "getAttributes", "(", ")", ".", "getNamedItem", "(", "\"name\"", ")", "!=", "null", ")", "{", "String", "nodeValue", "=", "nodeList", ".", "item", "(", "i", ")", ".", "getAttributes", "(", ")", ".", "getNamedItem", "(", "\"name\"", ")", ".", "getNodeValue", "(", ")", ";", "// add unique values only", "if", "(", "!", "nodeValue", ".", "isEmpty", "(", ")", ")", "{", "String", "resolved", "=", "getResolvedVariable", "(", "nodeValue", ")", ";", "if", "(", "!", "names", ".", "contains", "(", "resolved", ")", ")", "{", "names", ".", "add", "(", "resolved", ")", ";", "}", "}", "}", "else", "{", "String", "nodeValue", "=", "nodeList", ".", "item", "(", "i", ")", ".", "getAttributes", "(", ")", ".", "getNamedItem", "(", "\"location\"", ")", ".", "getNodeValue", "(", ")", ";", "// add unique values only", "if", "(", "!", "nodeValue", ".", "isEmpty", "(", ")", ")", "{", "String", "resolved", "=", "getResolvedVariable", "(", "nodeValue", ")", ";", "if", "(", "!", "namelessLocations", ".", "contains", "(", "resolved", ")", ")", "{", "namelessLocations", ".", "add", "(", "resolved", ")", ";", "}", "}", "}", "}", "}" ]
Checks for application names in the document. Will add locations without names to a Set
[ "Checks", "for", "application", "names", "in", "the", "document", ".", "Will", "add", "locations", "without", "names", "to", "a", "Set" ]
523a35e5146c1c5ab8f3aa00d353bbe91eecc180
https://github.com/WASdev/ci.gradle/blob/523a35e5146c1c5ab8f3aa00d353bbe91eecc180/src/main/groovy/net/wasdev/wlp/gradle/plugins/utils/ServerConfigDocument.java#L225-L254
3,172
FXMisc/Flowless
src/main/java/org/fxmisc/flowless/VirtualFlow.java
VirtualFlow.createHorizontal
public static <T, C extends Cell<T, ?>> VirtualFlow<T, C> createHorizontal( ObservableList<T> items, Function<? super T, ? extends C> cellFactory) { return createHorizontal(items, cellFactory, Gravity.FRONT); }
java
public static <T, C extends Cell<T, ?>> VirtualFlow<T, C> createHorizontal( ObservableList<T> items, Function<? super T, ? extends C> cellFactory) { return createHorizontal(items, cellFactory, Gravity.FRONT); }
[ "public", "static", "<", "T", ",", "C", "extends", "Cell", "<", "T", ",", "?", ">", ">", "VirtualFlow", "<", "T", ",", "C", ">", "createHorizontal", "(", "ObservableList", "<", "T", ">", "items", ",", "Function", "<", "?", "super", "T", ",", "?", "extends", "C", ">", "cellFactory", ")", "{", "return", "createHorizontal", "(", "items", ",", "cellFactory", ",", "Gravity", ".", "FRONT", ")", ";", "}" ]
Creates a viewport that lays out content horizontally from left to right
[ "Creates", "a", "viewport", "that", "lays", "out", "content", "horizontally", "from", "left", "to", "right" ]
dce2269ebafed8f79203d00085af41f06f3083bc
https://github.com/FXMisc/Flowless/blob/dce2269ebafed8f79203d00085af41f06f3083bc/src/main/java/org/fxmisc/flowless/VirtualFlow.java#L84-L88
3,173
FXMisc/Flowless
src/main/java/org/fxmisc/flowless/VirtualFlow.java
VirtualFlow.createHorizontal
public static <T, C extends Cell<T, ?>> VirtualFlow<T, C> createHorizontal( ObservableList<T> items, Function<? super T, ? extends C> cellFactory, Gravity gravity) { return new VirtualFlow<>(items, cellFactory, new HorizontalHelper(), gravity); }
java
public static <T, C extends Cell<T, ?>> VirtualFlow<T, C> createHorizontal( ObservableList<T> items, Function<? super T, ? extends C> cellFactory, Gravity gravity) { return new VirtualFlow<>(items, cellFactory, new HorizontalHelper(), gravity); }
[ "public", "static", "<", "T", ",", "C", "extends", "Cell", "<", "T", ",", "?", ">", ">", "VirtualFlow", "<", "T", ",", "C", ">", "createHorizontal", "(", "ObservableList", "<", "T", ">", "items", ",", "Function", "<", "?", "super", "T", ",", "?", "extends", "C", ">", "cellFactory", ",", "Gravity", "gravity", ")", "{", "return", "new", "VirtualFlow", "<>", "(", "items", ",", "cellFactory", ",", "new", "HorizontalHelper", "(", ")", ",", "gravity", ")", ";", "}" ]
Creates a viewport that lays out content horizontally
[ "Creates", "a", "viewport", "that", "lays", "out", "content", "horizontally" ]
dce2269ebafed8f79203d00085af41f06f3083bc
https://github.com/FXMisc/Flowless/blob/dce2269ebafed8f79203d00085af41f06f3083bc/src/main/java/org/fxmisc/flowless/VirtualFlow.java#L93-L98
3,174
FXMisc/Flowless
src/main/java/org/fxmisc/flowless/VirtualFlow.java
VirtualFlow.createVertical
public static <T, C extends Cell<T, ?>> VirtualFlow<T, C> createVertical( ObservableList<T> items, Function<? super T, ? extends C> cellFactory, Gravity gravity) { return new VirtualFlow<>(items, cellFactory, new VerticalHelper(), gravity); }
java
public static <T, C extends Cell<T, ?>> VirtualFlow<T, C> createVertical( ObservableList<T> items, Function<? super T, ? extends C> cellFactory, Gravity gravity) { return new VirtualFlow<>(items, cellFactory, new VerticalHelper(), gravity); }
[ "public", "static", "<", "T", ",", "C", "extends", "Cell", "<", "T", ",", "?", ">", ">", "VirtualFlow", "<", "T", ",", "C", ">", "createVertical", "(", "ObservableList", "<", "T", ">", "items", ",", "Function", "<", "?", "super", "T", ",", "?", "extends", "C", ">", "cellFactory", ",", "Gravity", "gravity", ")", "{", "return", "new", "VirtualFlow", "<>", "(", "items", ",", "cellFactory", ",", "new", "VerticalHelper", "(", ")", ",", "gravity", ")", ";", "}" ]
Creates a viewport that lays out content vertically from top to bottom
[ "Creates", "a", "viewport", "that", "lays", "out", "content", "vertically", "from", "top", "to", "bottom" ]
dce2269ebafed8f79203d00085af41f06f3083bc
https://github.com/FXMisc/Flowless/blob/dce2269ebafed8f79203d00085af41f06f3083bc/src/main/java/org/fxmisc/flowless/VirtualFlow.java#L112-L117
3,175
FXMisc/Flowless
src/main/java/org/fxmisc/flowless/VirtualFlow.java
VirtualFlow.getCell
public C getCell(int itemIndex) { Lists.checkIndex(itemIndex, items.size()); return cellPositioner.getSizedCell(itemIndex); }
java
public C getCell(int itemIndex) { Lists.checkIndex(itemIndex, items.size()); return cellPositioner.getSizedCell(itemIndex); }
[ "public", "C", "getCell", "(", "int", "itemIndex", ")", "{", "Lists", ".", "checkIndex", "(", "itemIndex", ",", "items", ".", "size", "(", ")", ")", ";", "return", "cellPositioner", ".", "getSizedCell", "(", "itemIndex", ")", ";", "}" ]
If the item is out of view, instantiates a new cell for the item. The returned cell will be properly sized, but not properly positioned relative to the cells in the viewport, unless it is itself in the viewport. @return Cell for the given item. The cell will be valid only until the next layout pass. It should therefore not be stored. It is intended to be used for measurement purposes only.
[ "If", "the", "item", "is", "out", "of", "view", "instantiates", "a", "new", "cell", "for", "the", "item", ".", "The", "returned", "cell", "will", "be", "properly", "sized", "but", "not", "properly", "positioned", "relative", "to", "the", "cells", "in", "the", "viewport", "unless", "it", "is", "itself", "in", "the", "viewport", "." ]
dce2269ebafed8f79203d00085af41f06f3083bc
https://github.com/FXMisc/Flowless/blob/dce2269ebafed8f79203d00085af41f06f3083bc/src/main/java/org/fxmisc/flowless/VirtualFlow.java#L209-L212
3,176
FXMisc/Flowless
src/main/java/org/fxmisc/flowless/VirtualFlow.java
VirtualFlow.hit
public VirtualFlowHit<C> hit(double x, double y) { double bOff = orientation.getX(x, y); double lOff = orientation.getY(x, y); bOff += breadthOffset0.getValue(); if(items.isEmpty()) { return orientation.hitAfterCells(bOff, lOff); } layout(); int firstVisible = getFirstVisibleIndex(); firstVisible = navigator.fillBackwardFrom0(firstVisible, lOff); C firstCell = cellPositioner.getVisibleCell(firstVisible); int lastVisible = getLastVisibleIndex(); lastVisible = navigator.fillForwardFrom0(lastVisible, lOff); C lastCell = cellPositioner.getVisibleCell(lastVisible); if(lOff < orientation.minY(firstCell)) { return orientation.hitBeforeCells(bOff, lOff - orientation.minY(firstCell)); } else if(lOff >= orientation.maxY(lastCell)) { return orientation.hitAfterCells(bOff, lOff - orientation.maxY(lastCell)); } else { for(int i = firstVisible; i <= lastVisible; ++i) { C cell = cellPositioner.getVisibleCell(i); if(lOff < orientation.maxY(cell)) { return orientation.cellHit(i, cell, bOff, lOff - orientation.minY(cell)); } } throw new AssertionError("unreachable code"); } }
java
public VirtualFlowHit<C> hit(double x, double y) { double bOff = orientation.getX(x, y); double lOff = orientation.getY(x, y); bOff += breadthOffset0.getValue(); if(items.isEmpty()) { return orientation.hitAfterCells(bOff, lOff); } layout(); int firstVisible = getFirstVisibleIndex(); firstVisible = navigator.fillBackwardFrom0(firstVisible, lOff); C firstCell = cellPositioner.getVisibleCell(firstVisible); int lastVisible = getLastVisibleIndex(); lastVisible = navigator.fillForwardFrom0(lastVisible, lOff); C lastCell = cellPositioner.getVisibleCell(lastVisible); if(lOff < orientation.minY(firstCell)) { return orientation.hitBeforeCells(bOff, lOff - orientation.minY(firstCell)); } else if(lOff >= orientation.maxY(lastCell)) { return orientation.hitAfterCells(bOff, lOff - orientation.maxY(lastCell)); } else { for(int i = firstVisible; i <= lastVisible; ++i) { C cell = cellPositioner.getVisibleCell(i); if(lOff < orientation.maxY(cell)) { return orientation.cellHit(i, cell, bOff, lOff - orientation.minY(cell)); } } throw new AssertionError("unreachable code"); } }
[ "public", "VirtualFlowHit", "<", "C", ">", "hit", "(", "double", "x", ",", "double", "y", ")", "{", "double", "bOff", "=", "orientation", ".", "getX", "(", "x", ",", "y", ")", ";", "double", "lOff", "=", "orientation", ".", "getY", "(", "x", ",", "y", ")", ";", "bOff", "+=", "breadthOffset0", ".", "getValue", "(", ")", ";", "if", "(", "items", ".", "isEmpty", "(", ")", ")", "{", "return", "orientation", ".", "hitAfterCells", "(", "bOff", ",", "lOff", ")", ";", "}", "layout", "(", ")", ";", "int", "firstVisible", "=", "getFirstVisibleIndex", "(", ")", ";", "firstVisible", "=", "navigator", ".", "fillBackwardFrom0", "(", "firstVisible", ",", "lOff", ")", ";", "C", "firstCell", "=", "cellPositioner", ".", "getVisibleCell", "(", "firstVisible", ")", ";", "int", "lastVisible", "=", "getLastVisibleIndex", "(", ")", ";", "lastVisible", "=", "navigator", ".", "fillForwardFrom0", "(", "lastVisible", ",", "lOff", ")", ";", "C", "lastCell", "=", "cellPositioner", ".", "getVisibleCell", "(", "lastVisible", ")", ";", "if", "(", "lOff", "<", "orientation", ".", "minY", "(", "firstCell", ")", ")", "{", "return", "orientation", ".", "hitBeforeCells", "(", "bOff", ",", "lOff", "-", "orientation", ".", "minY", "(", "firstCell", ")", ")", ";", "}", "else", "if", "(", "lOff", ">=", "orientation", ".", "maxY", "(", "lastCell", ")", ")", "{", "return", "orientation", ".", "hitAfterCells", "(", "bOff", ",", "lOff", "-", "orientation", ".", "maxY", "(", "lastCell", ")", ")", ";", "}", "else", "{", "for", "(", "int", "i", "=", "firstVisible", ";", "i", "<=", "lastVisible", ";", "++", "i", ")", "{", "C", "cell", "=", "cellPositioner", ".", "getVisibleCell", "(", "i", ")", ";", "if", "(", "lOff", "<", "orientation", ".", "maxY", "(", "cell", ")", ")", "{", "return", "orientation", ".", "cellHit", "(", "i", ",", "cell", ",", "bOff", ",", "lOff", "-", "orientation", ".", "minY", "(", "cell", ")", ")", ";", "}", "}", "throw", "new", "AssertionError", "(", "\"unreachable code\"", ")", ";", "}", "}" ]
Hits this virtual flow at the given coordinates. @param x x offset from the left edge of the viewport @param y y offset from the top edge of the viewport @return hit info containing the cell that was hit and coordinates relative to the cell. If the hit was before the cells (i.e. above a vertical flow content or left of a horizontal flow content), returns a <em>hit before cells</em> containing offset from the top left corner of the content. If the hit was after the cells (i.e. below a vertical flow content or right of a horizontal flow content), returns a <em>hit after cells</em> containing offset from the top right corner of the content of a horizontal flow or bottom left corner of the content of a vertical flow.
[ "Hits", "this", "virtual", "flow", "at", "the", "given", "coordinates", "." ]
dce2269ebafed8f79203d00085af41f06f3083bc
https://github.com/FXMisc/Flowless/blob/dce2269ebafed8f79203d00085af41f06f3083bc/src/main/java/org/fxmisc/flowless/VirtualFlow.java#L398-L431
3,177
FXMisc/Flowless
src/main/java/org/fxmisc/flowless/CellPositioner.java
CellPositioner.getSizedCell
C getSizedCell(int itemIndex) { C cell = cellManager.getCell(itemIndex); double breadth = sizeTracker.breadthFor(itemIndex); double length = sizeTracker.lengthFor(itemIndex); orientation.resize(cell, breadth, length); return cell; }
java
C getSizedCell(int itemIndex) { C cell = cellManager.getCell(itemIndex); double breadth = sizeTracker.breadthFor(itemIndex); double length = sizeTracker.lengthFor(itemIndex); orientation.resize(cell, breadth, length); return cell; }
[ "C", "getSizedCell", "(", "int", "itemIndex", ")", "{", "C", "cell", "=", "cellManager", ".", "getCell", "(", "itemIndex", ")", ";", "double", "breadth", "=", "sizeTracker", ".", "breadthFor", "(", "itemIndex", ")", ";", "double", "length", "=", "sizeTracker", ".", "lengthFor", "(", "itemIndex", ")", ";", "orientation", ".", "resize", "(", "cell", ",", "breadth", ",", "length", ")", ";", "return", "cell", ";", "}" ]
Returns properly sized, but not properly positioned cell for the given index.
[ "Returns", "properly", "sized", "but", "not", "properly", "positioned", "cell", "for", "the", "given", "index", "." ]
dce2269ebafed8f79203d00085af41f06f3083bc
https://github.com/FXMisc/Flowless/blob/dce2269ebafed8f79203d00085af41f06f3083bc/src/main/java/org/fxmisc/flowless/CellPositioner.java#L216-L222
3,178
FXMisc/Flowless
src/main/java/org/fxmisc/flowless/CellListManager.java
CellListManager.cropTo
public void cropTo(int fromItem, int toItem) { fromItem = Math.max(fromItem, 0); toItem = Math.min(toItem, cells.size()); cells.forget(0, fromItem); cells.forget(toItem, cells.size()); }
java
public void cropTo(int fromItem, int toItem) { fromItem = Math.max(fromItem, 0); toItem = Math.min(toItem, cells.size()); cells.forget(0, fromItem); cells.forget(toItem, cells.size()); }
[ "public", "void", "cropTo", "(", "int", "fromItem", ",", "int", "toItem", ")", "{", "fromItem", "=", "Math", ".", "max", "(", "fromItem", ",", "0", ")", ";", "toItem", "=", "Math", ".", "min", "(", "toItem", ",", "cells", ".", "size", "(", ")", ")", ";", "cells", ".", "forget", "(", "0", ",", "fromItem", ")", ";", "cells", ".", "forget", "(", "toItem", ",", "cells", ".", "size", "(", ")", ")", ";", "}" ]
Updates the list of cells to display @param fromItem the index of the first item to display @param toItem the index of the last item to display
[ "Updates", "the", "list", "of", "cells", "to", "display" ]
dce2269ebafed8f79203d00085af41f06f3083bc
https://github.com/FXMisc/Flowless/blob/dce2269ebafed8f79203d00085af41f06f3083bc/src/main/java/org/fxmisc/flowless/CellListManager.java#L82-L87
3,179
FXMisc/Flowless
src/main/java/org/fxmisc/flowless/Navigator.java
Navigator.fillBackwardFrom0
int fillBackwardFrom0(int itemIndex, double upTo) { double min = orientation.minY(positioner.getVisibleCell(itemIndex)); int i = itemIndex; while(min > upTo && i > 0) { --i; C c = positioner.placeEndFromStart(i, min); min = orientation.minY(c); } return i; }
java
int fillBackwardFrom0(int itemIndex, double upTo) { double min = orientation.minY(positioner.getVisibleCell(itemIndex)); int i = itemIndex; while(min > upTo && i > 0) { --i; C c = positioner.placeEndFromStart(i, min); min = orientation.minY(c); } return i; }
[ "int", "fillBackwardFrom0", "(", "int", "itemIndex", ",", "double", "upTo", ")", "{", "double", "min", "=", "orientation", ".", "minY", "(", "positioner", ".", "getVisibleCell", "(", "itemIndex", ")", ")", ";", "int", "i", "=", "itemIndex", ";", "while", "(", "min", ">", "upTo", "&&", "i", ">", "0", ")", "{", "--", "i", ";", "C", "c", "=", "positioner", ".", "placeEndFromStart", "(", "i", ",", "min", ")", ";", "min", "=", "orientation", ".", "minY", "(", "c", ")", ";", "}", "return", "i", ";", "}" ]
does not re-place the anchor cell
[ "does", "not", "re", "-", "place", "the", "anchor", "cell" ]
dce2269ebafed8f79203d00085af41f06f3083bc
https://github.com/FXMisc/Flowless/blob/dce2269ebafed8f79203d00085af41f06f3083bc/src/main/java/org/fxmisc/flowless/Navigator.java#L297-L306
3,180
FXMisc/Flowless
src/main/java/org/fxmisc/flowless/Navigator.java
Navigator.fillViewportFrom
private void fillViewportFrom(int itemIndex) { // cell for itemIndex is assumed to be placed correctly // fill up to the ground int ground = fillTowardsGroundFrom0(itemIndex); // if ground not reached, shift cells to the ground double gapBefore = distanceFromGround(ground); if(gapBefore > 0) { shiftCellsTowardsGround(ground, itemIndex, gapBefore); } // fill up to the sky int sky = fillTowardsSkyFrom0(itemIndex); // if sky not reached, add more cells under the ground and then shift double gapAfter = distanceFromSky(sky); if(gapAfter > 0) { ground = fillTowardsGroundFrom0(ground, -gapAfter); double extraBefore = -distanceFromGround(ground); double shift = Math.min(gapAfter, extraBefore); shiftCellsTowardsGround(ground, sky, -shift); } // crop to the visible cells int first = Math.min(ground, sky); int last = Math.max(ground, sky); while(first < last && orientation.maxY(positioner.getVisibleCell(first)) <= 0.0) { ++first; } while(last > first && orientation.minY(positioner.getVisibleCell(last)) >= sizeTracker.getViewportLength()) { --last; } firstVisibleIndex = first; lastVisibleIndex = last; positioner.cropTo(first, last + 1); }
java
private void fillViewportFrom(int itemIndex) { // cell for itemIndex is assumed to be placed correctly // fill up to the ground int ground = fillTowardsGroundFrom0(itemIndex); // if ground not reached, shift cells to the ground double gapBefore = distanceFromGround(ground); if(gapBefore > 0) { shiftCellsTowardsGround(ground, itemIndex, gapBefore); } // fill up to the sky int sky = fillTowardsSkyFrom0(itemIndex); // if sky not reached, add more cells under the ground and then shift double gapAfter = distanceFromSky(sky); if(gapAfter > 0) { ground = fillTowardsGroundFrom0(ground, -gapAfter); double extraBefore = -distanceFromGround(ground); double shift = Math.min(gapAfter, extraBefore); shiftCellsTowardsGround(ground, sky, -shift); } // crop to the visible cells int first = Math.min(ground, sky); int last = Math.max(ground, sky); while(first < last && orientation.maxY(positioner.getVisibleCell(first)) <= 0.0) { ++first; } while(last > first && orientation.minY(positioner.getVisibleCell(last)) >= sizeTracker.getViewportLength()) { --last; } firstVisibleIndex = first; lastVisibleIndex = last; positioner.cropTo(first, last + 1); }
[ "private", "void", "fillViewportFrom", "(", "int", "itemIndex", ")", "{", "// cell for itemIndex is assumed to be placed correctly", "// fill up to the ground", "int", "ground", "=", "fillTowardsGroundFrom0", "(", "itemIndex", ")", ";", "// if ground not reached, shift cells to the ground", "double", "gapBefore", "=", "distanceFromGround", "(", "ground", ")", ";", "if", "(", "gapBefore", ">", "0", ")", "{", "shiftCellsTowardsGround", "(", "ground", ",", "itemIndex", ",", "gapBefore", ")", ";", "}", "// fill up to the sky", "int", "sky", "=", "fillTowardsSkyFrom0", "(", "itemIndex", ")", ";", "// if sky not reached, add more cells under the ground and then shift", "double", "gapAfter", "=", "distanceFromSky", "(", "sky", ")", ";", "if", "(", "gapAfter", ">", "0", ")", "{", "ground", "=", "fillTowardsGroundFrom0", "(", "ground", ",", "-", "gapAfter", ")", ";", "double", "extraBefore", "=", "-", "distanceFromGround", "(", "ground", ")", ";", "double", "shift", "=", "Math", ".", "min", "(", "gapAfter", ",", "extraBefore", ")", ";", "shiftCellsTowardsGround", "(", "ground", ",", "sky", ",", "-", "shift", ")", ";", "}", "// crop to the visible cells", "int", "first", "=", "Math", ".", "min", "(", "ground", ",", "sky", ")", ";", "int", "last", "=", "Math", ".", "max", "(", "ground", ",", "sky", ")", ";", "while", "(", "first", "<", "last", "&&", "orientation", ".", "maxY", "(", "positioner", ".", "getVisibleCell", "(", "first", ")", ")", "<=", "0.0", ")", "{", "++", "first", ";", "}", "while", "(", "last", ">", "first", "&&", "orientation", ".", "minY", "(", "positioner", ".", "getVisibleCell", "(", "last", ")", ")", ">=", "sizeTracker", ".", "getViewportLength", "(", ")", ")", "{", "--", "last", ";", "}", "firstVisibleIndex", "=", "first", ";", "lastVisibleIndex", "=", "last", ";", "positioner", ".", "cropTo", "(", "first", ",", "last", "+", "1", ")", ";", "}" ]
Starting from the anchor cell's node, fills the viewport from the anchor to the "ground" and then from the anchor to the "sky". @param itemIndex the index of the anchor cell
[ "Starting", "from", "the", "anchor", "cell", "s", "node", "fills", "the", "viewport", "from", "the", "anchor", "to", "the", "ground", "and", "then", "from", "the", "anchor", "to", "the", "sky", "." ]
dce2269ebafed8f79203d00085af41f06f3083bc
https://github.com/FXMisc/Flowless/blob/dce2269ebafed8f79203d00085af41f06f3083bc/src/main/java/org/fxmisc/flowless/Navigator.java#L314-L352
3,181
play1-maven-plugin/play1-maven-plugin
play-selenium-junit4/src/main/java/com/google/code/play/selenium/parser/JSoupSeleneseParser.java
JSoupSeleneseParser.getCommand
private List<String> getCommand( Element trNode ) { List<String> result = new ArrayList<String>(); Elements trChildNodes = trNode.getElementsByTag( "TD" ); for ( Element trChild : trChildNodes ) { result.add( getTableDataValue( trChild ) ); } if ( result.size() != 1 && result.size() != 3 ) { throw new RuntimeException( "Something strange" ); // FIXME } return result; }
java
private List<String> getCommand( Element trNode ) { List<String> result = new ArrayList<String>(); Elements trChildNodes = trNode.getElementsByTag( "TD" ); for ( Element trChild : trChildNodes ) { result.add( getTableDataValue( trChild ) ); } if ( result.size() != 1 && result.size() != 3 ) { throw new RuntimeException( "Something strange" ); // FIXME } return result; }
[ "private", "List", "<", "String", ">", "getCommand", "(", "Element", "trNode", ")", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "Elements", "trChildNodes", "=", "trNode", ".", "getElementsByTag", "(", "\"TD\"", ")", ";", "for", "(", "Element", "trChild", ":", "trChildNodes", ")", "{", "result", ".", "add", "(", "getTableDataValue", "(", "trChild", ")", ")", ";", "}", "if", "(", "result", ".", "size", "(", ")", "!=", "1", "&&", "result", ".", "size", "(", ")", "!=", "3", ")", "{", "throw", "new", "RuntimeException", "(", "\"Something strange\"", ")", ";", "// FIXME", "}", "return", "result", ";", "}" ]
processing table row
[ "processing", "table", "row" ]
d5b2c29f4eb911e605a41529bf0aa0f83ec0aded
https://github.com/play1-maven-plugin/play1-maven-plugin/blob/d5b2c29f4eb911e605a41529bf0aa0f83ec0aded/play-selenium-junit4/src/main/java/com/google/code/play/selenium/parser/JSoupSeleneseParser.java#L56-L69
3,182
play1-maven-plugin/play1-maven-plugin
play-selenium-junit4/src/main/java/com/google/code/play/selenium/parser/JSoupSeleneseParser.java
JSoupSeleneseParser.getTableDataValue
private String getTableDataValue( Element tdNode ) { //return tdNode.html(); StringBuffer buf = new StringBuffer(); List<Node> childNodes = tdNode.childNodes(); for ( Node tdChild : childNodes ) { if ( tdChild instanceof TextNode ) { buf.append( ( (TextNode) tdChild ).text() ); } else if ( tdChild instanceof Element ) { Element tdChildElement = (Element) tdChild; if ( "br".equals( tdChildElement.tagName() ) ) { buf.append( "<br />" ); } } } return buf.toString(); }
java
private String getTableDataValue( Element tdNode ) { //return tdNode.html(); StringBuffer buf = new StringBuffer(); List<Node> childNodes = tdNode.childNodes(); for ( Node tdChild : childNodes ) { if ( tdChild instanceof TextNode ) { buf.append( ( (TextNode) tdChild ).text() ); } else if ( tdChild instanceof Element ) { Element tdChildElement = (Element) tdChild; if ( "br".equals( tdChildElement.tagName() ) ) { buf.append( "<br />" ); } } } return buf.toString(); }
[ "private", "String", "getTableDataValue", "(", "Element", "tdNode", ")", "{", "//return tdNode.html();", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "List", "<", "Node", ">", "childNodes", "=", "tdNode", ".", "childNodes", "(", ")", ";", "for", "(", "Node", "tdChild", ":", "childNodes", ")", "{", "if", "(", "tdChild", "instanceof", "TextNode", ")", "{", "buf", ".", "append", "(", "(", "(", "TextNode", ")", "tdChild", ")", ".", "text", "(", ")", ")", ";", "}", "else", "if", "(", "tdChild", "instanceof", "Element", ")", "{", "Element", "tdChildElement", "=", "(", "Element", ")", "tdChild", ";", "if", "(", "\"br\"", ".", "equals", "(", "tdChildElement", ".", "tagName", "(", ")", ")", ")", "{", "buf", ".", "append", "(", "\"<br />\"", ")", ";", "}", "}", "}", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
processing table data
[ "processing", "table", "data" ]
d5b2c29f4eb911e605a41529bf0aa0f83ec0aded
https://github.com/play1-maven-plugin/play1-maven-plugin/blob/d5b2c29f4eb911e605a41529bf0aa0f83ec0aded/play-selenium-junit4/src/main/java/com/google/code/play/selenium/parser/JSoupSeleneseParser.java#L72-L93
3,183
play1-maven-plugin/play1-maven-plugin
play-maven-plugin/src/main/java/com/google/code/play/AbstractPlayMojo.java
AbstractPlayMojo.findFrameworkArtifact
protected Artifact findFrameworkArtifact( boolean minVersionWins ) { Artifact result = null; Set<?> artifacts = project.getArtifacts(); for ( Iterator<?> iter = artifacts.iterator(); iter.hasNext(); ) { Artifact artifact = (Artifact) iter.next(); if ( "zip".equals( artifact.getType() ) ) { if ( "framework".equals( artifact.getClassifier() ) ) { result = artifact; if ( !minVersionWins ) { break; } // System.out.println( "added framework: " + artifact.getGroupId() + ":" + artifact.getArtifactId() // ); // don't break, maybe there is "framework-min" artifact too } // "module-min" overrides "module" (if present) else if ( "framework-min".equals( artifact.getClassifier() ) ) { result = artifact; // System.out.println( "added framework-min: " + artifact.getGroupId() + ":" // + artifact.getArtifactId() ); if ( minVersionWins ) { break; } } } } return result; }
java
protected Artifact findFrameworkArtifact( boolean minVersionWins ) { Artifact result = null; Set<?> artifacts = project.getArtifacts(); for ( Iterator<?> iter = artifacts.iterator(); iter.hasNext(); ) { Artifact artifact = (Artifact) iter.next(); if ( "zip".equals( artifact.getType() ) ) { if ( "framework".equals( artifact.getClassifier() ) ) { result = artifact; if ( !minVersionWins ) { break; } // System.out.println( "added framework: " + artifact.getGroupId() + ":" + artifact.getArtifactId() // ); // don't break, maybe there is "framework-min" artifact too } // "module-min" overrides "module" (if present) else if ( "framework-min".equals( artifact.getClassifier() ) ) { result = artifact; // System.out.println( "added framework-min: " + artifact.getGroupId() + ":" // + artifact.getArtifactId() ); if ( minVersionWins ) { break; } } } } return result; }
[ "protected", "Artifact", "findFrameworkArtifact", "(", "boolean", "minVersionWins", ")", "{", "Artifact", "result", "=", "null", ";", "Set", "<", "?", ">", "artifacts", "=", "project", ".", "getArtifacts", "(", ")", ";", "for", "(", "Iterator", "<", "?", ">", "iter", "=", "artifacts", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Artifact", "artifact", "=", "(", "Artifact", ")", "iter", ".", "next", "(", ")", ";", "if", "(", "\"zip\"", ".", "equals", "(", "artifact", ".", "getType", "(", ")", ")", ")", "{", "if", "(", "\"framework\"", ".", "equals", "(", "artifact", ".", "getClassifier", "(", ")", ")", ")", "{", "result", "=", "artifact", ";", "if", "(", "!", "minVersionWins", ")", "{", "break", ";", "}", "// System.out.println( \"added framework: \" + artifact.getGroupId() + \":\" + artifact.getArtifactId()", "// );", "// don't break, maybe there is \"framework-min\" artifact too", "}", "// \"module-min\" overrides \"module\" (if present)", "else", "if", "(", "\"framework-min\"", ".", "equals", "(", "artifact", ".", "getClassifier", "(", ")", ")", ")", "{", "result", "=", "artifact", ";", "// System.out.println( \"added framework-min: \" + artifact.getGroupId() + \":\"", "// + artifact.getArtifactId() );", "if", "(", "minVersionWins", ")", "{", "break", ";", "}", "}", "}", "}", "return", "result", ";", "}" ]
used by "initialize", "dist" and "war" mojos
[ "used", "by", "initialize", "dist", "and", "war", "mojos" ]
d5b2c29f4eb911e605a41529bf0aa0f83ec0aded
https://github.com/play1-maven-plugin/play1-maven-plugin/blob/d5b2c29f4eb911e605a41529bf0aa0f83ec0aded/play-maven-plugin/src/main/java/com/google/code/play/AbstractPlayMojo.java#L180-L215
3,184
play1-maven-plugin/play1-maven-plugin
play-maven-plugin/src/main/java/com/google/code/play/AbstractPlayMojo.java
AbstractPlayMojo.filterWebXml
protected File filterWebXml( File webXml, File outputDirectory, String applicationName, String playWarId ) throws IOException { if ( !outputDirectory.exists() ) { if ( !outputDirectory.mkdirs() ) { throw new IOException( String.format( "Cannot create \"%s\" directory", outputDirectory.getCanonicalPath() ) ); } } File result = new File( outputDirectory, "filtered-web.xml" ); BufferedReader reader = createBufferedFileReader( webXml, "UTF-8" ); try { BufferedWriter writer = createBufferedFileWriter( result, "UTF-8" ); try { getLog().debug( "web.xml file:" ); String line = reader.readLine(); while ( line != null ) { getLog().debug( " " + line ); if ( line.indexOf( "%APPLICATION_NAME%" ) >= 0 ) { line = line.replace( "%APPLICATION_NAME%", applicationName/* configParser.getApplicationName() */ ); } if ( line.indexOf( "%PLAY_ID%" ) >= 0 ) { line = line.replace( "%PLAY_ID%", playWarId ); } writer.write( line ); writer.newLine(); line = reader.readLine(); } } finally { writer.close(); } } finally { reader.close(); } return result; }
java
protected File filterWebXml( File webXml, File outputDirectory, String applicationName, String playWarId ) throws IOException { if ( !outputDirectory.exists() ) { if ( !outputDirectory.mkdirs() ) { throw new IOException( String.format( "Cannot create \"%s\" directory", outputDirectory.getCanonicalPath() ) ); } } File result = new File( outputDirectory, "filtered-web.xml" ); BufferedReader reader = createBufferedFileReader( webXml, "UTF-8" ); try { BufferedWriter writer = createBufferedFileWriter( result, "UTF-8" ); try { getLog().debug( "web.xml file:" ); String line = reader.readLine(); while ( line != null ) { getLog().debug( " " + line ); if ( line.indexOf( "%APPLICATION_NAME%" ) >= 0 ) { line = line.replace( "%APPLICATION_NAME%", applicationName/* configParser.getApplicationName() */ ); } if ( line.indexOf( "%PLAY_ID%" ) >= 0 ) { line = line.replace( "%PLAY_ID%", playWarId ); } writer.write( line ); writer.newLine(); line = reader.readLine(); } } finally { writer.close(); } } finally { reader.close(); } return result; }
[ "protected", "File", "filterWebXml", "(", "File", "webXml", ",", "File", "outputDirectory", ",", "String", "applicationName", ",", "String", "playWarId", ")", "throws", "IOException", "{", "if", "(", "!", "outputDirectory", ".", "exists", "(", ")", ")", "{", "if", "(", "!", "outputDirectory", ".", "mkdirs", "(", ")", ")", "{", "throw", "new", "IOException", "(", "String", ".", "format", "(", "\"Cannot create \\\"%s\\\" directory\"", ",", "outputDirectory", ".", "getCanonicalPath", "(", ")", ")", ")", ";", "}", "}", "File", "result", "=", "new", "File", "(", "outputDirectory", ",", "\"filtered-web.xml\"", ")", ";", "BufferedReader", "reader", "=", "createBufferedFileReader", "(", "webXml", ",", "\"UTF-8\"", ")", ";", "try", "{", "BufferedWriter", "writer", "=", "createBufferedFileWriter", "(", "result", ",", "\"UTF-8\"", ")", ";", "try", "{", "getLog", "(", ")", ".", "debug", "(", "\"web.xml file:\"", ")", ";", "String", "line", "=", "reader", ".", "readLine", "(", ")", ";", "while", "(", "line", "!=", "null", ")", "{", "getLog", "(", ")", ".", "debug", "(", "\" \"", "+", "line", ")", ";", "if", "(", "line", ".", "indexOf", "(", "\"%APPLICATION_NAME%\"", ")", ">=", "0", ")", "{", "line", "=", "line", ".", "replace", "(", "\"%APPLICATION_NAME%\"", ",", "applicationName", "/* configParser.getApplicationName() */", ")", ";", "}", "if", "(", "line", ".", "indexOf", "(", "\"%PLAY_ID%\"", ")", ">=", "0", ")", "{", "line", "=", "line", ".", "replace", "(", "\"%PLAY_ID%\"", ",", "playWarId", ")", ";", "}", "writer", ".", "write", "(", "line", ")", ";", "writer", ".", "newLine", "(", ")", ";", "line", "=", "reader", ".", "readLine", "(", ")", ";", "}", "}", "finally", "{", "writer", ".", "close", "(", ")", ";", "}", "}", "finally", "{", "reader", ".", "close", "(", ")", ";", "}", "return", "result", ";", "}" ]
used by "war" and "war-support" mojos
[ "used", "by", "war", "and", "war", "-", "support", "mojos" ]
d5b2c29f4eb911e605a41529bf0aa0f83ec0aded
https://github.com/play1-maven-plugin/play1-maven-plugin/blob/d5b2c29f4eb911e605a41529bf0aa0f83ec0aded/play-maven-plugin/src/main/java/com/google/code/play/AbstractPlayMojo.java#L266-L313
3,185
play1-maven-plugin/play1-maven-plugin
surefire-play-junit4/src/main/java/com/google/code/play/surefire/junit4/PlayJUnit4Provider.java
PlayJUnit4Provider.executeInPlayContext
private static void executeInPlayContext( Runner runner, RunNotifier notifier ) throws TestSetFailedException { try { Invoker.invokeInThread( new TestInvocation( runner, notifier ) ); } catch ( Throwable e ) { throw new TestSetFailedException( e ); } }
java
private static void executeInPlayContext( Runner runner, RunNotifier notifier ) throws TestSetFailedException { try { Invoker.invokeInThread( new TestInvocation( runner, notifier ) ); } catch ( Throwable e ) { throw new TestSetFailedException( e ); } }
[ "private", "static", "void", "executeInPlayContext", "(", "Runner", "runner", ",", "RunNotifier", "notifier", ")", "throws", "TestSetFailedException", "{", "try", "{", "Invoker", ".", "invokeInThread", "(", "new", "TestInvocation", "(", "runner", ",", "notifier", ")", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "TestSetFailedException", "(", "e", ")", ";", "}", "}" ]
Play! Framework specific methods
[ "Play!", "Framework", "specific", "methods" ]
d5b2c29f4eb911e605a41529bf0aa0f83ec0aded
https://github.com/play1-maven-plugin/play1-maven-plugin/blob/d5b2c29f4eb911e605a41529bf0aa0f83ec0aded/surefire-play-junit4/src/main/java/com/google/code/play/surefire/junit4/PlayJUnit4Provider.java#L587-L598
3,186
play1-maven-plugin/play1-maven-plugin
play-maven-plugin/src/main/java/com/google/code/play/AbstractPlayStopServerMojo.java
AbstractPlayStopServerMojo.kill
protected void kill( String pid ) throws IOException, InterruptedException { String os = System.getProperty( "os.name" ); String command = ( os.startsWith( "Windows" ) ) ? "taskkill /F /PID " + pid : "kill " + pid; Runtime.getRuntime().exec( command ).waitFor(); }
java
protected void kill( String pid ) throws IOException, InterruptedException { String os = System.getProperty( "os.name" ); String command = ( os.startsWith( "Windows" ) ) ? "taskkill /F /PID " + pid : "kill " + pid; Runtime.getRuntime().exec( command ).waitFor(); }
[ "protected", "void", "kill", "(", "String", "pid", ")", "throws", "IOException", ",", "InterruptedException", "{", "String", "os", "=", "System", ".", "getProperty", "(", "\"os.name\"", ")", ";", "String", "command", "=", "(", "os", ".", "startsWith", "(", "\"Windows\"", ")", ")", "?", "\"taskkill /F /PID \"", "+", "pid", ":", "\"kill \"", "+", "pid", ";", "Runtime", ".", "getRuntime", "(", ")", ".", "exec", "(", "command", ")", ".", "waitFor", "(", ")", ";", "}" ]
copied from Play! Framework's "play.utils.Utils" Java class
[ "copied", "from", "Play!", "Framework", "s", "play", ".", "utils", ".", "Utils", "Java", "class" ]
d5b2c29f4eb911e605a41529bf0aa0f83ec0aded
https://github.com/play1-maven-plugin/play1-maven-plugin/blob/d5b2c29f4eb911e605a41529bf0aa0f83ec0aded/play-maven-plugin/src/main/java/com/google/code/play/AbstractPlayStopServerMojo.java#L70-L76
3,187
wuman/android-oauth-client
library/src/main/java/com/wuman/android/auth/OAuthManager.java
OAuthManager.authorize10a
public OAuthFuture<Credential> authorize10a(final String userId, final OAuthCallback<Credential> callback, Handler handler) { Preconditions.checkNotNull(userId); final Future2Task<Credential> task = new Future2Task<Credential>(handler, callback) { @Override public void doWork() throws Exception { try { LOGGER.info("authorize10a"); OAuthHmacCredential credential = mFlow.load10aCredential(userId); if (credential != null && credential.getAccessToken() != null && (credential.getRefreshToken() != null || credential.getExpiresInSeconds() == null || credential.getExpiresInSeconds() > 60)) { set(credential); return; } String redirectUri = mUIController.getRedirectUri(); OAuthCredentialsResponse tempCredentials = mFlow.new10aTemporaryTokenRequest(redirectUri); OAuthAuthorizeTemporaryTokenUrl authorizationUrl = mFlow.new10aAuthorizationUrl(tempCredentials.token); mUIController.requestAuthorization(authorizationUrl); String code = mUIController.waitForVerifierCode(); OAuthCredentialsResponse response = mFlow.new10aTokenRequest(tempCredentials, code).execute(); credential = mFlow.createAndStoreCredential(response, userId); set(credential); } finally { mUIController.stop(); } } }; // run the task in a background thread submitTaskToExecutor(task); return task; }
java
public OAuthFuture<Credential> authorize10a(final String userId, final OAuthCallback<Credential> callback, Handler handler) { Preconditions.checkNotNull(userId); final Future2Task<Credential> task = new Future2Task<Credential>(handler, callback) { @Override public void doWork() throws Exception { try { LOGGER.info("authorize10a"); OAuthHmacCredential credential = mFlow.load10aCredential(userId); if (credential != null && credential.getAccessToken() != null && (credential.getRefreshToken() != null || credential.getExpiresInSeconds() == null || credential.getExpiresInSeconds() > 60)) { set(credential); return; } String redirectUri = mUIController.getRedirectUri(); OAuthCredentialsResponse tempCredentials = mFlow.new10aTemporaryTokenRequest(redirectUri); OAuthAuthorizeTemporaryTokenUrl authorizationUrl = mFlow.new10aAuthorizationUrl(tempCredentials.token); mUIController.requestAuthorization(authorizationUrl); String code = mUIController.waitForVerifierCode(); OAuthCredentialsResponse response = mFlow.new10aTokenRequest(tempCredentials, code).execute(); credential = mFlow.createAndStoreCredential(response, userId); set(credential); } finally { mUIController.stop(); } } }; // run the task in a background thread submitTaskToExecutor(task); return task; }
[ "public", "OAuthFuture", "<", "Credential", ">", "authorize10a", "(", "final", "String", "userId", ",", "final", "OAuthCallback", "<", "Credential", ">", "callback", ",", "Handler", "handler", ")", "{", "Preconditions", ".", "checkNotNull", "(", "userId", ")", ";", "final", "Future2Task", "<", "Credential", ">", "task", "=", "new", "Future2Task", "<", "Credential", ">", "(", "handler", ",", "callback", ")", "{", "@", "Override", "public", "void", "doWork", "(", ")", "throws", "Exception", "{", "try", "{", "LOGGER", ".", "info", "(", "\"authorize10a\"", ")", ";", "OAuthHmacCredential", "credential", "=", "mFlow", ".", "load10aCredential", "(", "userId", ")", ";", "if", "(", "credential", "!=", "null", "&&", "credential", ".", "getAccessToken", "(", ")", "!=", "null", "&&", "(", "credential", ".", "getRefreshToken", "(", ")", "!=", "null", "||", "credential", ".", "getExpiresInSeconds", "(", ")", "==", "null", "||", "credential", ".", "getExpiresInSeconds", "(", ")", ">", "60", ")", ")", "{", "set", "(", "credential", ")", ";", "return", ";", "}", "String", "redirectUri", "=", "mUIController", ".", "getRedirectUri", "(", ")", ";", "OAuthCredentialsResponse", "tempCredentials", "=", "mFlow", ".", "new10aTemporaryTokenRequest", "(", "redirectUri", ")", ";", "OAuthAuthorizeTemporaryTokenUrl", "authorizationUrl", "=", "mFlow", ".", "new10aAuthorizationUrl", "(", "tempCredentials", ".", "token", ")", ";", "mUIController", ".", "requestAuthorization", "(", "authorizationUrl", ")", ";", "String", "code", "=", "mUIController", ".", "waitForVerifierCode", "(", ")", ";", "OAuthCredentialsResponse", "response", "=", "mFlow", ".", "new10aTokenRequest", "(", "tempCredentials", ",", "code", ")", ".", "execute", "(", ")", ";", "credential", "=", "mFlow", ".", "createAndStoreCredential", "(", "response", ",", "userId", ")", ";", "set", "(", "credential", ")", ";", "}", "finally", "{", "mUIController", ".", "stop", "(", ")", ";", "}", "}", "}", ";", "// run the task in a background thread", "submitTaskToExecutor", "(", "task", ")", ";", "return", "task", ";", "}" ]
Authorizes the Android application to access user's protected data using the authorization flow in OAuth 1.0a. @param userId user ID or {@code null} if not using a persisted credential store @param callback Callback to invoke when the request completes, {@code null} for no callback @param handler {@link Handler} identifying the callback thread, {@code null} for the main thread @return An {@link OAuthFuture} which resolves to a {@link Credential}
[ "Authorizes", "the", "Android", "application", "to", "access", "user", "s", "protected", "data", "using", "the", "authorization", "flow", "in", "OAuth", "1", ".", "0a", "." ]
6e01b81b7319a6954a1156e8b93c0b5cbeb61446
https://github.com/wuman/android-oauth-client/blob/6e01b81b7319a6954a1156e8b93c0b5cbeb61446/library/src/main/java/com/wuman/android/auth/OAuthManager.java#L122-L165
3,188
wuman/android-oauth-client
library/src/main/java/com/wuman/android/auth/OAuthManager.java
OAuthManager.authorizeExplicitly
public OAuthFuture<Credential> authorizeExplicitly(final String userId, final OAuthCallback<Credential> callback, Handler handler) { Preconditions.checkNotNull(userId); final Future2Task<Credential> task = new Future2Task<Credential>(handler, callback) { @Override public void doWork() throws Exception { try { Credential credential = mFlow.loadCredential(userId); LOGGER.info("authorizeExplicitly"); if (credential != null && credential.getAccessToken() != null && (credential.getRefreshToken() != null || credential.getExpiresInSeconds() == null || credential.getExpiresInSeconds() > 60)) { set(credential); return; } String redirectUri = mUIController.getRedirectUri(); AuthorizationCodeRequestUrl authorizationUrl = mFlow .newExplicitAuthorizationUrl() .setRedirectUri(redirectUri); mUIController.requestAuthorization(authorizationUrl); String code = mUIController.waitForExplicitCode(); TokenResponse response = mFlow.newTokenRequest(code) .setRedirectUri(redirectUri).execute(); credential = mFlow.createAndStoreCredential(response, userId); set(credential); } finally { mUIController.stop(); } } }; // run the task in a background thread submitTaskToExecutor(task); return task; }
java
public OAuthFuture<Credential> authorizeExplicitly(final String userId, final OAuthCallback<Credential> callback, Handler handler) { Preconditions.checkNotNull(userId); final Future2Task<Credential> task = new Future2Task<Credential>(handler, callback) { @Override public void doWork() throws Exception { try { Credential credential = mFlow.loadCredential(userId); LOGGER.info("authorizeExplicitly"); if (credential != null && credential.getAccessToken() != null && (credential.getRefreshToken() != null || credential.getExpiresInSeconds() == null || credential.getExpiresInSeconds() > 60)) { set(credential); return; } String redirectUri = mUIController.getRedirectUri(); AuthorizationCodeRequestUrl authorizationUrl = mFlow .newExplicitAuthorizationUrl() .setRedirectUri(redirectUri); mUIController.requestAuthorization(authorizationUrl); String code = mUIController.waitForExplicitCode(); TokenResponse response = mFlow.newTokenRequest(code) .setRedirectUri(redirectUri).execute(); credential = mFlow.createAndStoreCredential(response, userId); set(credential); } finally { mUIController.stop(); } } }; // run the task in a background thread submitTaskToExecutor(task); return task; }
[ "public", "OAuthFuture", "<", "Credential", ">", "authorizeExplicitly", "(", "final", "String", "userId", ",", "final", "OAuthCallback", "<", "Credential", ">", "callback", ",", "Handler", "handler", ")", "{", "Preconditions", ".", "checkNotNull", "(", "userId", ")", ";", "final", "Future2Task", "<", "Credential", ">", "task", "=", "new", "Future2Task", "<", "Credential", ">", "(", "handler", ",", "callback", ")", "{", "@", "Override", "public", "void", "doWork", "(", ")", "throws", "Exception", "{", "try", "{", "Credential", "credential", "=", "mFlow", ".", "loadCredential", "(", "userId", ")", ";", "LOGGER", ".", "info", "(", "\"authorizeExplicitly\"", ")", ";", "if", "(", "credential", "!=", "null", "&&", "credential", ".", "getAccessToken", "(", ")", "!=", "null", "&&", "(", "credential", ".", "getRefreshToken", "(", ")", "!=", "null", "||", "credential", ".", "getExpiresInSeconds", "(", ")", "==", "null", "||", "credential", ".", "getExpiresInSeconds", "(", ")", ">", "60", ")", ")", "{", "set", "(", "credential", ")", ";", "return", ";", "}", "String", "redirectUri", "=", "mUIController", ".", "getRedirectUri", "(", ")", ";", "AuthorizationCodeRequestUrl", "authorizationUrl", "=", "mFlow", ".", "newExplicitAuthorizationUrl", "(", ")", ".", "setRedirectUri", "(", "redirectUri", ")", ";", "mUIController", ".", "requestAuthorization", "(", "authorizationUrl", ")", ";", "String", "code", "=", "mUIController", ".", "waitForExplicitCode", "(", ")", ";", "TokenResponse", "response", "=", "mFlow", ".", "newTokenRequest", "(", "code", ")", ".", "setRedirectUri", "(", "redirectUri", ")", ".", "execute", "(", ")", ";", "credential", "=", "mFlow", ".", "createAndStoreCredential", "(", "response", ",", "userId", ")", ";", "set", "(", "credential", ")", ";", "}", "finally", "{", "mUIController", ".", "stop", "(", ")", ";", "}", "}", "}", ";", "// run the task in a background thread", "submitTaskToExecutor", "(", "task", ")", ";", "return", "task", ";", "}" ]
Authorizes the Android application to access user's protected data using the Explicit Authorization Code flow in OAuth 2.0. @param userId user ID or {@code null} if not using a persisted credential store @param callback Callback to invoke when the request completes, {@code null} for no callback @param handler {@link Handler} identifying the callback thread, {@code null} for the main thread @return An {@link OAuthFuture} which resolves to a {@link Credential}
[ "Authorizes", "the", "Android", "application", "to", "access", "user", "s", "protected", "data", "using", "the", "Explicit", "Authorization", "Code", "flow", "in", "OAuth", "2", ".", "0", "." ]
6e01b81b7319a6954a1156e8b93c0b5cbeb61446
https://github.com/wuman/android-oauth-client/blob/6e01b81b7319a6954a1156e8b93c0b5cbeb61446/library/src/main/java/com/wuman/android/auth/OAuthManager.java#L179-L221
3,189
wuman/android-oauth-client
library/src/main/java/com/wuman/android/auth/OAuthManager.java
OAuthManager.authorizeImplicitly
public OAuthFuture<Credential> authorizeImplicitly(final String userId, final OAuthCallback<Credential> callback, Handler handler) { Preconditions.checkNotNull(userId); final Future2Task<Credential> task = new Future2Task<Credential>(handler, callback) { @Override public void doWork() throws TokenResponseException, Exception { try { LOGGER.info("authorizeImplicitly"); Credential credential = mFlow.loadCredential(userId); if (credential != null && credential.getAccessToken() != null && (credential.getRefreshToken() != null || credential.getExpiresInSeconds() == null || credential.getExpiresInSeconds() > 60)) { set(credential); return; } String redirectUri = mUIController.getRedirectUri(); BrowserClientRequestUrl authorizationUrl = mFlow.newImplicitAuthorizationUrl() .setRedirectUri(redirectUri); mUIController.requestAuthorization(authorizationUrl); ImplicitResponseUrl implicitResponse = mUIController .waitForImplicitResponseUrl(); credential = mFlow.createAndStoreCredential(implicitResponse, userId); set(credential); } finally { mUIController.stop(); } } }; // run the task in a background thread submitTaskToExecutor(task); return task; }
java
public OAuthFuture<Credential> authorizeImplicitly(final String userId, final OAuthCallback<Credential> callback, Handler handler) { Preconditions.checkNotNull(userId); final Future2Task<Credential> task = new Future2Task<Credential>(handler, callback) { @Override public void doWork() throws TokenResponseException, Exception { try { LOGGER.info("authorizeImplicitly"); Credential credential = mFlow.loadCredential(userId); if (credential != null && credential.getAccessToken() != null && (credential.getRefreshToken() != null || credential.getExpiresInSeconds() == null || credential.getExpiresInSeconds() > 60)) { set(credential); return; } String redirectUri = mUIController.getRedirectUri(); BrowserClientRequestUrl authorizationUrl = mFlow.newImplicitAuthorizationUrl() .setRedirectUri(redirectUri); mUIController.requestAuthorization(authorizationUrl); ImplicitResponseUrl implicitResponse = mUIController .waitForImplicitResponseUrl(); credential = mFlow.createAndStoreCredential(implicitResponse, userId); set(credential); } finally { mUIController.stop(); } } }; // run the task in a background thread submitTaskToExecutor(task); return task; }
[ "public", "OAuthFuture", "<", "Credential", ">", "authorizeImplicitly", "(", "final", "String", "userId", ",", "final", "OAuthCallback", "<", "Credential", ">", "callback", ",", "Handler", "handler", ")", "{", "Preconditions", ".", "checkNotNull", "(", "userId", ")", ";", "final", "Future2Task", "<", "Credential", ">", "task", "=", "new", "Future2Task", "<", "Credential", ">", "(", "handler", ",", "callback", ")", "{", "@", "Override", "public", "void", "doWork", "(", ")", "throws", "TokenResponseException", ",", "Exception", "{", "try", "{", "LOGGER", ".", "info", "(", "\"authorizeImplicitly\"", ")", ";", "Credential", "credential", "=", "mFlow", ".", "loadCredential", "(", "userId", ")", ";", "if", "(", "credential", "!=", "null", "&&", "credential", ".", "getAccessToken", "(", ")", "!=", "null", "&&", "(", "credential", ".", "getRefreshToken", "(", ")", "!=", "null", "||", "credential", ".", "getExpiresInSeconds", "(", ")", "==", "null", "||", "credential", ".", "getExpiresInSeconds", "(", ")", ">", "60", ")", ")", "{", "set", "(", "credential", ")", ";", "return", ";", "}", "String", "redirectUri", "=", "mUIController", ".", "getRedirectUri", "(", ")", ";", "BrowserClientRequestUrl", "authorizationUrl", "=", "mFlow", ".", "newImplicitAuthorizationUrl", "(", ")", ".", "setRedirectUri", "(", "redirectUri", ")", ";", "mUIController", ".", "requestAuthorization", "(", "authorizationUrl", ")", ";", "ImplicitResponseUrl", "implicitResponse", "=", "mUIController", ".", "waitForImplicitResponseUrl", "(", ")", ";", "credential", "=", "mFlow", ".", "createAndStoreCredential", "(", "implicitResponse", ",", "userId", ")", ";", "set", "(", "credential", ")", ";", "}", "finally", "{", "mUIController", ".", "stop", "(", ")", ";", "}", "}", "}", ";", "// run the task in a background thread", "submitTaskToExecutor", "(", "task", ")", ";", "return", "task", ";", "}" ]
Authorizes the Android application to access user's protected data using the Implicit Authorization flow in OAuth 2.0. @param userId user ID or {@code null} if not using a persisted credential store @param callback Callback to invoke when the request completes, {@code null} for no callback @param handler {@link Handler} identifying the callback thread, {@code null} for the main thread @return An {@link OAuthFuture} which resolves to a {@link Credential}
[ "Authorizes", "the", "Android", "application", "to", "access", "user", "s", "protected", "data", "using", "the", "Implicit", "Authorization", "flow", "in", "OAuth", "2", ".", "0", "." ]
6e01b81b7319a6954a1156e8b93c0b5cbeb61446
https://github.com/wuman/android-oauth-client/blob/6e01b81b7319a6954a1156e8b93c0b5cbeb61446/library/src/main/java/com/wuman/android/auth/OAuthManager.java#L235-L275
3,190
wuman/android-oauth-client
library/src/main/java/com/wuman/android/auth/AuthorizationFlow.java
AuthorizationFlow.load10aCredential
public OAuthHmacCredential load10aCredential(String userId) throws IOException { if (getCredentialStore() == null) { return null; } OAuthHmacCredential credential = new10aCredential(userId); if (!getCredentialStore().load(userId, credential)) { return null; } return credential; }
java
public OAuthHmacCredential load10aCredential(String userId) throws IOException { if (getCredentialStore() == null) { return null; } OAuthHmacCredential credential = new10aCredential(userId); if (!getCredentialStore().load(userId, credential)) { return null; } return credential; }
[ "public", "OAuthHmacCredential", "load10aCredential", "(", "String", "userId", ")", "throws", "IOException", "{", "if", "(", "getCredentialStore", "(", ")", "==", "null", ")", "{", "return", "null", ";", "}", "OAuthHmacCredential", "credential", "=", "new10aCredential", "(", "userId", ")", ";", "if", "(", "!", "getCredentialStore", "(", ")", ".", "load", "(", "userId", ",", "credential", ")", ")", "{", "return", "null", ";", "}", "return", "credential", ";", "}" ]
Loads the OAuth 1.0a credential of the given user ID from the credential store. @param userId user ID or {@code null} if not using a persisted credential store @return OAuth 1.0a credential found in the credential store of the given user ID or {@code null} for none found
[ "Loads", "the", "OAuth", "1", ".", "0a", "credential", "of", "the", "given", "user", "ID", "from", "the", "credential", "store", "." ]
6e01b81b7319a6954a1156e8b93c0b5cbeb61446
https://github.com/wuman/android-oauth-client/blob/6e01b81b7319a6954a1156e8b93c0b5cbeb61446/library/src/main/java/com/wuman/android/auth/AuthorizationFlow.java#L140-L149
3,191
wuman/android-oauth-client
library/src/main/java/com/wuman/android/auth/AuthorizationFlow.java
AuthorizationFlow.new10aCredential
private OAuthHmacCredential new10aCredential(String userId) { ClientParametersAuthentication clientAuthentication = (ClientParametersAuthentication) getClientAuthentication(); OAuthHmacCredential.Builder builder = new OAuthHmacCredential.Builder(getMethod(), clientAuthentication.getClientId(), clientAuthentication.getClientSecret()) .setTransport(getTransport()) .setJsonFactory(getJsonFactory()) .setTokenServerEncodedUrl(getTokenServerEncodedUrl()) .setClientAuthentication(getClientAuthentication()) .setRequestInitializer(getRequestInitializer()) .setClock(getClock()); if (getCredentialStore() != null) { builder.addRefreshListener( new CredentialStoreRefreshListener(userId, getCredentialStore())); } builder.getRefreshListeners().addAll(getRefreshListeners()); return builder.build(); }
java
private OAuthHmacCredential new10aCredential(String userId) { ClientParametersAuthentication clientAuthentication = (ClientParametersAuthentication) getClientAuthentication(); OAuthHmacCredential.Builder builder = new OAuthHmacCredential.Builder(getMethod(), clientAuthentication.getClientId(), clientAuthentication.getClientSecret()) .setTransport(getTransport()) .setJsonFactory(getJsonFactory()) .setTokenServerEncodedUrl(getTokenServerEncodedUrl()) .setClientAuthentication(getClientAuthentication()) .setRequestInitializer(getRequestInitializer()) .setClock(getClock()); if (getCredentialStore() != null) { builder.addRefreshListener( new CredentialStoreRefreshListener(userId, getCredentialStore())); } builder.getRefreshListeners().addAll(getRefreshListeners()); return builder.build(); }
[ "private", "OAuthHmacCredential", "new10aCredential", "(", "String", "userId", ")", "{", "ClientParametersAuthentication", "clientAuthentication", "=", "(", "ClientParametersAuthentication", ")", "getClientAuthentication", "(", ")", ";", "OAuthHmacCredential", ".", "Builder", "builder", "=", "new", "OAuthHmacCredential", ".", "Builder", "(", "getMethod", "(", ")", ",", "clientAuthentication", ".", "getClientId", "(", ")", ",", "clientAuthentication", ".", "getClientSecret", "(", ")", ")", ".", "setTransport", "(", "getTransport", "(", ")", ")", ".", "setJsonFactory", "(", "getJsonFactory", "(", ")", ")", ".", "setTokenServerEncodedUrl", "(", "getTokenServerEncodedUrl", "(", ")", ")", ".", "setClientAuthentication", "(", "getClientAuthentication", "(", ")", ")", ".", "setRequestInitializer", "(", "getRequestInitializer", "(", ")", ")", ".", "setClock", "(", "getClock", "(", ")", ")", ";", "if", "(", "getCredentialStore", "(", ")", "!=", "null", ")", "{", "builder", ".", "addRefreshListener", "(", "new", "CredentialStoreRefreshListener", "(", "userId", ",", "getCredentialStore", "(", ")", ")", ")", ";", "}", "builder", ".", "getRefreshListeners", "(", ")", ".", "addAll", "(", "getRefreshListeners", "(", ")", ")", ";", "return", "builder", ".", "build", "(", ")", ";", "}" ]
Returns a new OAuth 1.0a credential instance based on the given user ID. @param userId user ID or {@code null} if not using a persisted credential store
[ "Returns", "a", "new", "OAuth", "1", ".", "0a", "credential", "instance", "based", "on", "the", "given", "user", "ID", "." ]
6e01b81b7319a6954a1156e8b93c0b5cbeb61446
https://github.com/wuman/android-oauth-client/blob/6e01b81b7319a6954a1156e8b93c0b5cbeb61446/library/src/main/java/com/wuman/android/auth/AuthorizationFlow.java#L345-L364
3,192
wuman/android-oauth-client
library/src/main/java/com/wuman/android/auth/AuthorizationFlow.java
AuthorizationFlow.newCredential
private Credential newCredential(String userId) { Credential.Builder builder = new Credential.Builder(getMethod()) .setTransport(getTransport()) .setJsonFactory(getJsonFactory()) .setTokenServerEncodedUrl(getTokenServerEncodedUrl()) .setClientAuthentication(getClientAuthentication()) .setRequestInitializer(getRequestInitializer()) .setClock(getClock()); if (getCredentialStore() != null) { builder.addRefreshListener( new CredentialStoreRefreshListener(userId, getCredentialStore())); } builder.getRefreshListeners().addAll(getRefreshListeners()); return builder.build(); }
java
private Credential newCredential(String userId) { Credential.Builder builder = new Credential.Builder(getMethod()) .setTransport(getTransport()) .setJsonFactory(getJsonFactory()) .setTokenServerEncodedUrl(getTokenServerEncodedUrl()) .setClientAuthentication(getClientAuthentication()) .setRequestInitializer(getRequestInitializer()) .setClock(getClock()); if (getCredentialStore() != null) { builder.addRefreshListener( new CredentialStoreRefreshListener(userId, getCredentialStore())); } builder.getRefreshListeners().addAll(getRefreshListeners()); return builder.build(); }
[ "private", "Credential", "newCredential", "(", "String", "userId", ")", "{", "Credential", ".", "Builder", "builder", "=", "new", "Credential", ".", "Builder", "(", "getMethod", "(", ")", ")", ".", "setTransport", "(", "getTransport", "(", ")", ")", ".", "setJsonFactory", "(", "getJsonFactory", "(", ")", ")", ".", "setTokenServerEncodedUrl", "(", "getTokenServerEncodedUrl", "(", ")", ")", ".", "setClientAuthentication", "(", "getClientAuthentication", "(", ")", ")", ".", "setRequestInitializer", "(", "getRequestInitializer", "(", ")", ")", ".", "setClock", "(", "getClock", "(", ")", ")", ";", "if", "(", "getCredentialStore", "(", ")", "!=", "null", ")", "{", "builder", ".", "addRefreshListener", "(", "new", "CredentialStoreRefreshListener", "(", "userId", ",", "getCredentialStore", "(", ")", ")", ")", ";", "}", "builder", ".", "getRefreshListeners", "(", ")", ".", "addAll", "(", "getRefreshListeners", "(", ")", ")", ";", "return", "builder", ".", "build", "(", ")", ";", "}" ]
Returns a new OAuth 2.0 credential instance based on the given user ID. @param userId user ID or {@code null} if not using a persisted credential store
[ "Returns", "a", "new", "OAuth", "2", ".", "0", "credential", "instance", "based", "on", "the", "given", "user", "ID", "." ]
6e01b81b7319a6954a1156e8b93c0b5cbeb61446
https://github.com/wuman/android-oauth-client/blob/6e01b81b7319a6954a1156e8b93c0b5cbeb61446/library/src/main/java/com/wuman/android/auth/AuthorizationFlow.java#L372-L388
3,193
ef-labs/vertx-jersey
vertx-jersey/src/main/java/com/englishtown/vertx/jersey/impl/DefaultJerseyServer.java
DefaultJerseyServer.stop
@Override public void stop() { // Run jersey shutdown lifecycle if (container != null) { container.stop(); container = null; } // Destroy the jersey service locator if (jerseyHandler != null && jerseyHandler.getDelegate() != null) { ServiceLocatorFactory.getInstance().destroy(jerseyHandler.getDelegate().getServiceLocator()); jerseyHandler = null; } if (server != null) { server.close(); server = null; } }
java
@Override public void stop() { // Run jersey shutdown lifecycle if (container != null) { container.stop(); container = null; } // Destroy the jersey service locator if (jerseyHandler != null && jerseyHandler.getDelegate() != null) { ServiceLocatorFactory.getInstance().destroy(jerseyHandler.getDelegate().getServiceLocator()); jerseyHandler = null; } if (server != null) { server.close(); server = null; } }
[ "@", "Override", "public", "void", "stop", "(", ")", "{", "// Run jersey shutdown lifecycle", "if", "(", "container", "!=", "null", ")", "{", "container", ".", "stop", "(", ")", ";", "container", "=", "null", ";", "}", "// Destroy the jersey service locator", "if", "(", "jerseyHandler", "!=", "null", "&&", "jerseyHandler", ".", "getDelegate", "(", ")", "!=", "null", ")", "{", "ServiceLocatorFactory", ".", "getInstance", "(", ")", ".", "destroy", "(", "jerseyHandler", ".", "getDelegate", "(", ")", ".", "getServiceLocator", "(", ")", ")", ";", "jerseyHandler", "=", "null", ";", "}", "if", "(", "server", "!=", "null", ")", "{", "server", ".", "close", "(", ")", ";", "server", "=", "null", ";", "}", "}" ]
Shutdown jersey server and release resources
[ "Shutdown", "jersey", "server", "and", "release", "resources" ]
733482a8a5afb1fb257c682b3767655e56f7a0fe
https://github.com/ef-labs/vertx-jersey/blob/733482a8a5afb1fb257c682b3767655e56f7a0fe/vertx-jersey/src/main/java/com/englishtown/vertx/jersey/impl/DefaultJerseyServer.java#L155-L171
3,194
ef-labs/vertx-jersey
vertx-jersey/src/main/java/com/englishtown/vertx/jersey/impl/DefaultVertxContainer.java
DefaultVertxContainer.start
@Override public void start() { if (started) { return; } ApplicationHandler handler = getApplicationHandler(); if (handler == null) { throw new IllegalStateException("ApplicationHandler cannot be null"); } handler.onStartup(this); started = true; }
java
@Override public void start() { if (started) { return; } ApplicationHandler handler = getApplicationHandler(); if (handler == null) { throw new IllegalStateException("ApplicationHandler cannot be null"); } handler.onStartup(this); started = true; }
[ "@", "Override", "public", "void", "start", "(", ")", "{", "if", "(", "started", ")", "{", "return", ";", "}", "ApplicationHandler", "handler", "=", "getApplicationHandler", "(", ")", ";", "if", "(", "handler", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"ApplicationHandler cannot be null\"", ")", ";", "}", "handler", ".", "onStartup", "(", "this", ")", ";", "started", "=", "true", ";", "}" ]
Starts the container
[ "Starts", "the", "container" ]
733482a8a5afb1fb257c682b3767655e56f7a0fe
https://github.com/ef-labs/vertx-jersey/blob/733482a8a5afb1fb257c682b3767655e56f7a0fe/vertx-jersey/src/main/java/com/englishtown/vertx/jersey/impl/DefaultVertxContainer.java#L44-L55
3,195
ef-labs/vertx-jersey
vertx-jersey/src/main/java/com/englishtown/vertx/guice/GuiceJerseyServer.java
GuiceJerseyServer.initBridge
protected void initBridge(ServiceLocator locator, Injector injector) { // Set up bridge GuiceBridge.getGuiceBridge().initializeGuiceBridge(locator); GuiceIntoHK2Bridge guiceBridge = locator.getService(GuiceIntoHK2Bridge.class); guiceBridge.bridgeGuiceInjector(injector); injectMultibindings(locator, injector); // Bind guice scope context ServiceLocatorUtilities.bind(locator, new AbstractBinder() { @Override protected void configure() { bind(GuiceScopeContext.class).to(new TypeLiteral<Context<GuiceScope>>() { }).in(Singleton.class); } }); }
java
protected void initBridge(ServiceLocator locator, Injector injector) { // Set up bridge GuiceBridge.getGuiceBridge().initializeGuiceBridge(locator); GuiceIntoHK2Bridge guiceBridge = locator.getService(GuiceIntoHK2Bridge.class); guiceBridge.bridgeGuiceInjector(injector); injectMultibindings(locator, injector); // Bind guice scope context ServiceLocatorUtilities.bind(locator, new AbstractBinder() { @Override protected void configure() { bind(GuiceScopeContext.class).to(new TypeLiteral<Context<GuiceScope>>() { }).in(Singleton.class); } }); }
[ "protected", "void", "initBridge", "(", "ServiceLocator", "locator", ",", "Injector", "injector", ")", "{", "// Set up bridge", "GuiceBridge", ".", "getGuiceBridge", "(", ")", ".", "initializeGuiceBridge", "(", "locator", ")", ";", "GuiceIntoHK2Bridge", "guiceBridge", "=", "locator", ".", "getService", "(", "GuiceIntoHK2Bridge", ".", "class", ")", ";", "guiceBridge", ".", "bridgeGuiceInjector", "(", "injector", ")", ";", "injectMultibindings", "(", "locator", ",", "injector", ")", ";", "// Bind guice scope context", "ServiceLocatorUtilities", ".", "bind", "(", "locator", ",", "new", "AbstractBinder", "(", ")", "{", "@", "Override", "protected", "void", "configure", "(", ")", "{", "bind", "(", "GuiceScopeContext", ".", "class", ")", ".", "to", "(", "new", "TypeLiteral", "<", "Context", "<", "GuiceScope", ">", ">", "(", ")", "{", "}", ")", ".", "in", "(", "Singleton", ".", "class", ")", ";", "}", "}", ")", ";", "}" ]
Initialize the hk2 bridge @param locator the HK2 locator @param injector the Guice injector
[ "Initialize", "the", "hk2", "bridge" ]
733482a8a5afb1fb257c682b3767655e56f7a0fe
https://github.com/ef-labs/vertx-jersey/blob/733482a8a5afb1fb257c682b3767655e56f7a0fe/vertx-jersey/src/main/java/com/englishtown/vertx/guice/GuiceJerseyServer.java#L50-L66
3,196
ef-labs/vertx-jersey
vertx-jersey/src/main/java/com/englishtown/vertx/guice/GuiceJerseyServer.java
GuiceJerseyServer.injectMultibindings
protected void injectMultibindings(ServiceLocator locator, Injector injector) { injectMultiBindings(locator, injector, new Key<Set<ContainerRequestFilter>>() { }, ContainerRequestFilter.class); injectMultiBindings(locator, injector, new Key<Set<ContainerResponseFilter>>() { }, ContainerResponseFilter.class); injectMultiBindings(locator, injector, new Key<Set<ReaderInterceptor>>() { }, ReaderInterceptor.class); injectMultiBindings(locator, injector, new Key<Set<WriterInterceptor>>() { }, WriterInterceptor.class); injectMultiBindings(locator, injector, new Key<Set<ModelProcessor>>() { }, ModelProcessor.class); injectMultiBindings(locator, injector, new Key<Set<ContainerLifecycleListener>>() { }, ContainerLifecycleListener.class); injectMultiBindings(locator, injector, new Key<Set<ApplicationEventListener>>() { }, ApplicationEventListener.class); injectMultiBindings(locator, injector, new Key<Set<ExceptionMapper>>() { }, ExceptionMapper.class); }
java
protected void injectMultibindings(ServiceLocator locator, Injector injector) { injectMultiBindings(locator, injector, new Key<Set<ContainerRequestFilter>>() { }, ContainerRequestFilter.class); injectMultiBindings(locator, injector, new Key<Set<ContainerResponseFilter>>() { }, ContainerResponseFilter.class); injectMultiBindings(locator, injector, new Key<Set<ReaderInterceptor>>() { }, ReaderInterceptor.class); injectMultiBindings(locator, injector, new Key<Set<WriterInterceptor>>() { }, WriterInterceptor.class); injectMultiBindings(locator, injector, new Key<Set<ModelProcessor>>() { }, ModelProcessor.class); injectMultiBindings(locator, injector, new Key<Set<ContainerLifecycleListener>>() { }, ContainerLifecycleListener.class); injectMultiBindings(locator, injector, new Key<Set<ApplicationEventListener>>() { }, ApplicationEventListener.class); injectMultiBindings(locator, injector, new Key<Set<ExceptionMapper>>() { }, ExceptionMapper.class); }
[ "protected", "void", "injectMultibindings", "(", "ServiceLocator", "locator", ",", "Injector", "injector", ")", "{", "injectMultiBindings", "(", "locator", ",", "injector", ",", "new", "Key", "<", "Set", "<", "ContainerRequestFilter", ">", ">", "(", ")", "{", "}", ",", "ContainerRequestFilter", ".", "class", ")", ";", "injectMultiBindings", "(", "locator", ",", "injector", ",", "new", "Key", "<", "Set", "<", "ContainerResponseFilter", ">", ">", "(", ")", "{", "}", ",", "ContainerResponseFilter", ".", "class", ")", ";", "injectMultiBindings", "(", "locator", ",", "injector", ",", "new", "Key", "<", "Set", "<", "ReaderInterceptor", ">", ">", "(", ")", "{", "}", ",", "ReaderInterceptor", ".", "class", ")", ";", "injectMultiBindings", "(", "locator", ",", "injector", ",", "new", "Key", "<", "Set", "<", "WriterInterceptor", ">", ">", "(", ")", "{", "}", ",", "WriterInterceptor", ".", "class", ")", ";", "injectMultiBindings", "(", "locator", ",", "injector", ",", "new", "Key", "<", "Set", "<", "ModelProcessor", ">", ">", "(", ")", "{", "}", ",", "ModelProcessor", ".", "class", ")", ";", "injectMultiBindings", "(", "locator", ",", "injector", ",", "new", "Key", "<", "Set", "<", "ContainerLifecycleListener", ">", ">", "(", ")", "{", "}", ",", "ContainerLifecycleListener", ".", "class", ")", ";", "injectMultiBindings", "(", "locator", ",", "injector", ",", "new", "Key", "<", "Set", "<", "ApplicationEventListener", ">", ">", "(", ")", "{", "}", ",", "ApplicationEventListener", ".", "class", ")", ";", "injectMultiBindings", "(", "locator", ",", "injector", ",", "new", "Key", "<", "Set", "<", "ExceptionMapper", ">", ">", "(", ")", "{", "}", ",", "ExceptionMapper", ".", "class", ")", ";", "}" ]
This is a workaround for the hk2 bridge limitations @param locator the HK2 locator @param injector the Guice injector
[ "This", "is", "a", "workaround", "for", "the", "hk2", "bridge", "limitations" ]
733482a8a5afb1fb257c682b3767655e56f7a0fe
https://github.com/ef-labs/vertx-jersey/blob/733482a8a5afb1fb257c682b3767655e56f7a0fe/vertx-jersey/src/main/java/com/englishtown/vertx/guice/GuiceJerseyServer.java#L74-L93
3,197
ef-labs/vertx-jersey
vertx-jersey/src/main/java/com/englishtown/vertx/jersey/impl/DefaultJerseyOptions.java
DefaultJerseyOptions.getPackages
@Override public List<String> getPackages() { List<String> list = new ArrayList<>(); Consumer<JsonArray> reader = array -> { if ((array != null && !array.isEmpty())) { for (int i = 0; i < array.size(); i++) { list.add(array.getString(i)); } } }; JsonArray resources = config.getJsonArray(CONFIG_RESOURCES, null); JsonArray packages = config.getJsonArray(CONFIG_PACKAGES, null); reader.accept(resources); reader.accept(packages); return list; }
java
@Override public List<String> getPackages() { List<String> list = new ArrayList<>(); Consumer<JsonArray> reader = array -> { if ((array != null && !array.isEmpty())) { for (int i = 0; i < array.size(); i++) { list.add(array.getString(i)); } } }; JsonArray resources = config.getJsonArray(CONFIG_RESOURCES, null); JsonArray packages = config.getJsonArray(CONFIG_PACKAGES, null); reader.accept(resources); reader.accept(packages); return list; }
[ "@", "Override", "public", "List", "<", "String", ">", "getPackages", "(", ")", "{", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "Consumer", "<", "JsonArray", ">", "reader", "=", "array", "->", "{", "if", "(", "(", "array", "!=", "null", "&&", "!", "array", ".", "isEmpty", "(", ")", ")", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "size", "(", ")", ";", "i", "++", ")", "{", "list", ".", "add", "(", "array", ".", "getString", "(", "i", ")", ")", ";", "}", "}", "}", ";", "JsonArray", "resources", "=", "config", ".", "getJsonArray", "(", "CONFIG_RESOURCES", ",", "null", ")", ";", "JsonArray", "packages", "=", "config", ".", "getJsonArray", "(", "CONFIG_PACKAGES", ",", "null", ")", ";", "reader", ".", "accept", "(", "resources", ")", ";", "reader", ".", "accept", "(", "packages", ")", ";", "return", "list", ";", "}" ]
Returns a list of packages to be scanned for resources and components @return
[ "Returns", "a", "list", "of", "packages", "to", "be", "scanned", "for", "resources", "and", "components" ]
733482a8a5afb1fb257c682b3767655e56f7a0fe
https://github.com/ef-labs/vertx-jersey/blob/733482a8a5afb1fb257c682b3767655e56f7a0fe/vertx-jersey/src/main/java/com/englishtown/vertx/jersey/impl/DefaultJerseyOptions.java#L86-L105
3,198
ef-labs/vertx-jersey
vertx-jersey/src/main/java/com/englishtown/vertx/jersey/impl/DefaultJerseyOptions.java
DefaultJerseyOptions.getProperties
@Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); }
java
@Override public Map<String, Object> getProperties() { JsonObject json = null; JsonObject tmp; tmp = config.getJsonObject(CONFIG_PROPERTIES); if (tmp != null) { json = tmp; } tmp = config.getJsonObject(CONFIG_RESOURCE_CONFIG); if (tmp != null) { if (json == null) { json = tmp; } else { json.mergeIn(tmp); } } return json == null ? null : json.getMap(); }
[ "@", "Override", "public", "Map", "<", "String", ",", "Object", ">", "getProperties", "(", ")", "{", "JsonObject", "json", "=", "null", ";", "JsonObject", "tmp", ";", "tmp", "=", "config", ".", "getJsonObject", "(", "CONFIG_PROPERTIES", ")", ";", "if", "(", "tmp", "!=", "null", ")", "{", "json", "=", "tmp", ";", "}", "tmp", "=", "config", ".", "getJsonObject", "(", "CONFIG_RESOURCE_CONFIG", ")", ";", "if", "(", "tmp", "!=", "null", ")", "{", "if", "(", "json", "==", "null", ")", "{", "json", "=", "tmp", ";", "}", "else", "{", "json", ".", "mergeIn", "(", "tmp", ")", ";", "}", "}", "return", "json", "==", "null", "?", "null", ":", "json", ".", "getMap", "(", ")", ";", "}" ]
Optional additional properties to be applied to Jersey resource configuration @return
[ "Optional", "additional", "properties", "to", "be", "applied", "to", "Jersey", "resource", "configuration" ]
733482a8a5afb1fb257c682b3767655e56f7a0fe
https://github.com/ef-labs/vertx-jersey/blob/733482a8a5afb1fb257c682b3767655e56f7a0fe/vertx-jersey/src/main/java/com/englishtown/vertx/jersey/impl/DefaultJerseyOptions.java#L112-L132
3,199
ef-labs/vertx-jersey
vertx-jersey/src/main/java/com/englishtown/vertx/jersey/impl/DefaultJerseyOptions.java
DefaultJerseyOptions.getKeyStoreOptions
public JksOptions getKeyStoreOptions() { JsonObject json = config.getJsonObject(CONFIG_JKS_OPTIONS); return json == null ? null : new JksOptions(json); }
java
public JksOptions getKeyStoreOptions() { JsonObject json = config.getJsonObject(CONFIG_JKS_OPTIONS); return json == null ? null : new JksOptions(json); }
[ "public", "JksOptions", "getKeyStoreOptions", "(", ")", "{", "JsonObject", "json", "=", "config", ".", "getJsonObject", "(", "CONFIG_JKS_OPTIONS", ")", ";", "return", "json", "==", "null", "?", "null", ":", "new", "JksOptions", "(", "json", ")", ";", "}" ]
Vert.x http server key store options @return Java key store options
[ "Vert", ".", "x", "http", "server", "key", "store", "options" ]
733482a8a5afb1fb257c682b3767655e56f7a0fe
https://github.com/ef-labs/vertx-jersey/blob/733482a8a5afb1fb257c682b3767655e56f7a0fe/vertx-jersey/src/main/java/com/englishtown/vertx/jersey/impl/DefaultJerseyOptions.java#L229-L232