repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathScanner.java
XPathScanner.scanComment
private void scanComment() { final char input = mQuery.charAt(mPos + 1); if (mInput == ':') { // check if is end of comment, indicated by ':)' if (input == ')') { mCommentCount--; if (mCommentCount == 0) { mState = State.START; // increment position, because next digit has already been // processed mPos++; } } } else if (mInput == '(') { // check if start of new nested comment, indicated by '(:' if (input == ':') { mCommentCount++; } } mPos++; }
java
private void scanComment() { final char input = mQuery.charAt(mPos + 1); if (mInput == ':') { // check if is end of comment, indicated by ':)' if (input == ')') { mCommentCount--; if (mCommentCount == 0) { mState = State.START; // increment position, because next digit has already been // processed mPos++; } } } else if (mInput == '(') { // check if start of new nested comment, indicated by '(:' if (input == ':') { mCommentCount++; } } mPos++; }
[ "private", "void", "scanComment", "(", ")", "{", "final", "char", "input", "=", "mQuery", ".", "charAt", "(", "mPos", "+", "1", ")", ";", "if", "(", "mInput", "==", "'", "'", ")", "{", "// check if is end of comment, indicated by ':)'", "if", "(", "input",...
Scans comments.
[ "Scans", "comments", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathScanner.java#L438-L460
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathScanner.java
XPathScanner.isLetter
private boolean isLetter(final char paramInput) { return (paramInput >= '0' && paramInput <= '9') || (paramInput >= 'a' && paramInput <= 'z') || (paramInput >= 'A' && paramInput <= 'Z') || (paramInput == '_') || (paramInput == '-') || (paramInput == '.'); }
java
private boolean isLetter(final char paramInput) { return (paramInput >= '0' && paramInput <= '9') || (paramInput >= 'a' && paramInput <= 'z') || (paramInput >= 'A' && paramInput <= 'Z') || (paramInput == '_') || (paramInput == '-') || (paramInput == '.'); }
[ "private", "boolean", "isLetter", "(", "final", "char", "paramInput", ")", "{", "return", "(", "paramInput", ">=", "'", "'", "&&", "paramInput", "<=", "'", "'", ")", "||", "(", "paramInput", ">=", "'", "'", "&&", "paramInput", "<=", "'", "'", ")", "|...
Checks if the given character is a letter. @param paramInput The character to check. @return Returns true, if the character is a letter.
[ "Checks", "if", "the", "given", "character", "is", "a", "letter", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/parser/XPathScanner.java#L469-L475
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/NodeIdRepresentation.java
NodeIdRepresentation.getResource
public StreamingOutput getResource(final String resourceName, final long nodeId, final Map<QueryParameter, String> queryParams) throws JaxRxException { final StreamingOutput sOutput = new StreamingOutput() { @Override public void write(final OutputStream output) throws IOException, JaxRxException { // final String xPath = queryParams.get(QueryParameter.QUERY); final String revision = queryParams.get(QueryParameter.REVISION); final String wrap = queryParams.get(QueryParameter.WRAP); final String doNodeId = queryParams.get(QueryParameter.OUTPUT); final boolean wrapResult = (wrap == null) ? false : wrap.equalsIgnoreCase(YESSTRING); final boolean nodeid = (doNodeId == null) ? false : doNodeId.equalsIgnoreCase(YESSTRING); final Long rev = revision == null ? null : Long.valueOf(revision); serialize(resourceName, nodeId, rev, nodeid, output, wrapResult); } }; return sOutput; }
java
public StreamingOutput getResource(final String resourceName, final long nodeId, final Map<QueryParameter, String> queryParams) throws JaxRxException { final StreamingOutput sOutput = new StreamingOutput() { @Override public void write(final OutputStream output) throws IOException, JaxRxException { // final String xPath = queryParams.get(QueryParameter.QUERY); final String revision = queryParams.get(QueryParameter.REVISION); final String wrap = queryParams.get(QueryParameter.WRAP); final String doNodeId = queryParams.get(QueryParameter.OUTPUT); final boolean wrapResult = (wrap == null) ? false : wrap.equalsIgnoreCase(YESSTRING); final boolean nodeid = (doNodeId == null) ? false : doNodeId.equalsIgnoreCase(YESSTRING); final Long rev = revision == null ? null : Long.valueOf(revision); serialize(resourceName, nodeId, rev, nodeid, output, wrapResult); } }; return sOutput; }
[ "public", "StreamingOutput", "getResource", "(", "final", "String", "resourceName", ",", "final", "long", "nodeId", ",", "final", "Map", "<", "QueryParameter", ",", "String", ">", "queryParams", ")", "throws", "JaxRxException", "{", "final", "StreamingOutput", "sO...
This method is responsible to deliver the whole XML resource addressed by a unique node id. @param resourceName The name of the database, where the node id belongs. @param nodeId The unique node id of the requested resource. @param queryParams The optional query parameters. @return The whole XML resource addressed by a unique node id. @throws JaxRxException The exception occurred.
[ "This", "method", "is", "responsible", "to", "deliver", "the", "whole", "XML", "resource", "addressed", "by", "a", "unique", "node", "id", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/NodeIdRepresentation.java#L117-L135
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/NodeIdRepresentation.java
NodeIdRepresentation.performQueryOnResource
public StreamingOutput performQueryOnResource(final String resourceName, final long nodeId, final String query, final Map<QueryParameter, String> queryParams) { final StreamingOutput sOutput = new StreamingOutput() { @Override public void write(final OutputStream output) throws IOException, JaxRxException { final String revision = queryParams.get(QueryParameter.REVISION); final String wrap = queryParams.get(QueryParameter.WRAP); final String doNodeId = queryParams.get(QueryParameter.OUTPUT); final boolean wrapResult = (wrap == null) ? true : wrap.equalsIgnoreCase(YESSTRING); final boolean nodeid = (doNodeId == null) ? false : doNodeId.equalsIgnoreCase(YESSTRING); final Long rev = revision == null ? null : Long.valueOf(revision); final RestXPathProcessor xpathProcessor = new RestXPathProcessor(mDatabase); try { xpathProcessor.getXpathResource(resourceName, nodeId, query, nodeid, rev, output, wrapResult); } catch (final TTException exce) { throw new JaxRxException(exce); } } }; return sOutput; }
java
public StreamingOutput performQueryOnResource(final String resourceName, final long nodeId, final String query, final Map<QueryParameter, String> queryParams) { final StreamingOutput sOutput = new StreamingOutput() { @Override public void write(final OutputStream output) throws IOException, JaxRxException { final String revision = queryParams.get(QueryParameter.REVISION); final String wrap = queryParams.get(QueryParameter.WRAP); final String doNodeId = queryParams.get(QueryParameter.OUTPUT); final boolean wrapResult = (wrap == null) ? true : wrap.equalsIgnoreCase(YESSTRING); final boolean nodeid = (doNodeId == null) ? false : doNodeId.equalsIgnoreCase(YESSTRING); final Long rev = revision == null ? null : Long.valueOf(revision); final RestXPathProcessor xpathProcessor = new RestXPathProcessor(mDatabase); try { xpathProcessor.getXpathResource(resourceName, nodeId, query, nodeid, rev, output, wrapResult); } catch (final TTException exce) { throw new JaxRxException(exce); } } }; return sOutput; }
[ "public", "StreamingOutput", "performQueryOnResource", "(", "final", "String", "resourceName", ",", "final", "long", "nodeId", ",", "final", "String", "query", ",", "final", "Map", "<", "QueryParameter", ",", "String", ">", "queryParams", ")", "{", "final", "Str...
This method is responsible to perform a XPath query expression on the XML resource which is addressed through a unique node id. @param resourceName The name of the database, the node id belongs to. @param nodeId The node id of the requested resource. @param query The XPath expression. @param queryParams The optional query parameters (output, wrap, revision). @return The result of the XPath query expression.
[ "This", "method", "is", "responsible", "to", "perform", "a", "XPath", "query", "expression", "on", "the", "XML", "resource", "which", "is", "addressed", "through", "a", "unique", "node", "id", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/NodeIdRepresentation.java#L188-L212
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/NodeIdRepresentation.java
NodeIdRepresentation.modifyResource
public void modifyResource(final String resourceName, final long nodeId, final InputStream newValue) throws JaxRxException { synchronized (resourceName) { ISession session = null; INodeWriteTrx wtx = null; boolean abort = false; if (mDatabase.existsResource(resourceName)) { try { // Creating a new session session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); // Creating a write transaction wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); if (wtx.moveTo(nodeId)) { final long parentKey = wtx.getNode().getParentKey(); wtx.remove(); wtx.moveTo(parentKey); WorkerHelper.shredInputStream(wtx, newValue, EShredderInsert.ADDASFIRSTCHILD); } else { // workerHelper.closeWTX(abort, wtx, session, database); throw new JaxRxException(404, NOTFOUND); } } catch (final TTException exc) { abort = true; throw new JaxRxException(exc); } finally { try { WorkerHelper.closeWTX(abort, wtx, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } else { throw new JaxRxException(404, "Requested resource not found"); } } }
java
public void modifyResource(final String resourceName, final long nodeId, final InputStream newValue) throws JaxRxException { synchronized (resourceName) { ISession session = null; INodeWriteTrx wtx = null; boolean abort = false; if (mDatabase.existsResource(resourceName)) { try { // Creating a new session session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); // Creating a write transaction wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); if (wtx.moveTo(nodeId)) { final long parentKey = wtx.getNode().getParentKey(); wtx.remove(); wtx.moveTo(parentKey); WorkerHelper.shredInputStream(wtx, newValue, EShredderInsert.ADDASFIRSTCHILD); } else { // workerHelper.closeWTX(abort, wtx, session, database); throw new JaxRxException(404, NOTFOUND); } } catch (final TTException exc) { abort = true; throw new JaxRxException(exc); } finally { try { WorkerHelper.closeWTX(abort, wtx, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } else { throw new JaxRxException(404, "Requested resource not found"); } } }
[ "public", "void", "modifyResource", "(", "final", "String", "resourceName", ",", "final", "long", "nodeId", ",", "final", "InputStream", "newValue", ")", "throws", "JaxRxException", "{", "synchronized", "(", "resourceName", ")", "{", "ISession", "session", "=", ...
This method is responsible to modify the XML resource, which is addressed through a unique node id. @param resourceName The name of the database, where the node id belongs to. @param nodeId The node id. @param newValue The new value of the node that has to be replaced. @throws JaxRxException The exception occurred.
[ "This", "method", "is", "responsible", "to", "modify", "the", "XML", "resource", "which", "is", "addressed", "through", "a", "unique", "node", "id", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/NodeIdRepresentation.java#L274-L313
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/NodeIdRepresentation.java
NodeIdRepresentation.addSubResource
public void addSubResource(final String resourceName, final long nodeId, final InputStream input, final EIdAccessType type) throws JaxRxException { ISession session = null; INodeWriteTrx wtx = null; synchronized (resourceName) { boolean abort; if (mDatabase.existsResource(resourceName)) { abort = false; try { // Creating a new session session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); // Creating a write transaction wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); final boolean exist = wtx.moveTo(nodeId); if (exist) { if (type == EIdAccessType.FIRSTCHILD) { WorkerHelper.shredInputStream(wtx, input, EShredderInsert.ADDASFIRSTCHILD); } else if (type == EIdAccessType.RIGHTSIBLING) { WorkerHelper.shredInputStream(wtx, input, EShredderInsert.ADDASRIGHTSIBLING); } else if (type == EIdAccessType.LASTCHILD) { if (wtx.moveTo(((ITreeStructData)wtx.getNode()).getFirstChildKey())) { long last = wtx.getNode().getDataKey(); while (wtx.moveTo(((ITreeStructData)wtx.getNode()).getRightSiblingKey())) { last = wtx.getNode().getDataKey(); } wtx.moveTo(last); WorkerHelper.shredInputStream(wtx, input, EShredderInsert.ADDASRIGHTSIBLING); } else { throw new JaxRxException(404, NOTFOUND); } } else if (type == EIdAccessType.LEFTSIBLING && wtx.moveTo(((ITreeStructData)wtx.getNode()).getLeftSiblingKey())) { WorkerHelper.shredInputStream(wtx, input, EShredderInsert.ADDASRIGHTSIBLING); } } else { throw new JaxRxException(404, NOTFOUND); } } catch (final JaxRxException exce) { abort = true; throw exce; } catch (final Exception exce) { abort = true; throw new JaxRxException(exce); } finally { try { WorkerHelper.closeWTX(abort, wtx, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } } }
java
public void addSubResource(final String resourceName, final long nodeId, final InputStream input, final EIdAccessType type) throws JaxRxException { ISession session = null; INodeWriteTrx wtx = null; synchronized (resourceName) { boolean abort; if (mDatabase.existsResource(resourceName)) { abort = false; try { // Creating a new session session = mDatabase.getSession(new SessionConfiguration(resourceName, StandardSettings.KEY)); // Creating a write transaction wtx = new NodeWriteTrx(session, session.beginBucketWtx(), HashKind.Rolling); final boolean exist = wtx.moveTo(nodeId); if (exist) { if (type == EIdAccessType.FIRSTCHILD) { WorkerHelper.shredInputStream(wtx, input, EShredderInsert.ADDASFIRSTCHILD); } else if (type == EIdAccessType.RIGHTSIBLING) { WorkerHelper.shredInputStream(wtx, input, EShredderInsert.ADDASRIGHTSIBLING); } else if (type == EIdAccessType.LASTCHILD) { if (wtx.moveTo(((ITreeStructData)wtx.getNode()).getFirstChildKey())) { long last = wtx.getNode().getDataKey(); while (wtx.moveTo(((ITreeStructData)wtx.getNode()).getRightSiblingKey())) { last = wtx.getNode().getDataKey(); } wtx.moveTo(last); WorkerHelper.shredInputStream(wtx, input, EShredderInsert.ADDASRIGHTSIBLING); } else { throw new JaxRxException(404, NOTFOUND); } } else if (type == EIdAccessType.LEFTSIBLING && wtx.moveTo(((ITreeStructData)wtx.getNode()).getLeftSiblingKey())) { WorkerHelper.shredInputStream(wtx, input, EShredderInsert.ADDASRIGHTSIBLING); } } else { throw new JaxRxException(404, NOTFOUND); } } catch (final JaxRxException exce) { abort = true; throw exce; } catch (final Exception exce) { abort = true; throw new JaxRxException(exce); } finally { try { WorkerHelper.closeWTX(abort, wtx, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } } }
[ "public", "void", "addSubResource", "(", "final", "String", "resourceName", ",", "final", "long", "nodeId", ",", "final", "InputStream", "input", ",", "final", "EIdAccessType", "type", ")", "throws", "JaxRxException", "{", "ISession", "session", "=", "null", ";"...
This method is responsible to perform a POST request to a node id. This method adds a new XML subtree as first child or as right sibling to the node which is addressed through a node id. @param resourceName The name of the database, the node id belongs to. @param nodeId The node id. @param input The new XML subtree. @param type The type which indicates if the new subtree has to be inserted as right sibling or as first child. @throws JaxRxException The exception occurred.
[ "This", "method", "is", "responsible", "to", "perform", "a", "POST", "request", "to", "a", "node", "id", ".", "This", "method", "adds", "a", "new", "XML", "subtree", "as", "first", "child", "or", "as", "right", "sibling", "to", "the", "node", "which", ...
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/NodeIdRepresentation.java#L332-L389
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/NodeIdRepresentation.java
NodeIdRepresentation.serialize
private void serialize(final String resource, final long nodeId, final Long revision, final boolean doNodeId, final OutputStream output, final boolean wrapResult) { if (mDatabase.existsResource(resource)) { ISession session = null; try { session = mDatabase.getSession(new SessionConfiguration(resource, StandardSettings.KEY)); if (wrapResult) { output.write(BEGINRESULT); final XMLSerializerProperties props = new XMLSerializerProperties(); final XMLSerializerBuilder builder = new XMLSerializerBuilder(session, nodeId, output, props); builder.setREST(doNodeId); builder.setID(doNodeId); builder.setDeclaration(false); final XMLSerializer serializer = builder.build(); serializer.call(); output.write(ENDRESULT); } else { final XMLSerializerProperties props = new XMLSerializerProperties(); final XMLSerializerBuilder builder = new XMLSerializerBuilder(session, nodeId, output, props); builder.setREST(doNodeId); builder.setID(doNodeId); builder.setDeclaration(false); final XMLSerializer serializer = builder.build(); serializer.call(); } } catch (final TTException ttExcep) { throw new JaxRxException(ttExcep); } catch (final IOException ioExcep) { throw new JaxRxException(ioExcep); } catch (final Exception globExcep) { if (globExcep instanceof JaxRxException) { // NOPMD due // to // different // exception // types throw (JaxRxException)globExcep; } else { throw new JaxRxException(globExcep); } } finally { try { WorkerHelper.closeRTX(null, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } else { throw new JaxRxException(404, "Resource does not exist"); } }
java
private void serialize(final String resource, final long nodeId, final Long revision, final boolean doNodeId, final OutputStream output, final boolean wrapResult) { if (mDatabase.existsResource(resource)) { ISession session = null; try { session = mDatabase.getSession(new SessionConfiguration(resource, StandardSettings.KEY)); if (wrapResult) { output.write(BEGINRESULT); final XMLSerializerProperties props = new XMLSerializerProperties(); final XMLSerializerBuilder builder = new XMLSerializerBuilder(session, nodeId, output, props); builder.setREST(doNodeId); builder.setID(doNodeId); builder.setDeclaration(false); final XMLSerializer serializer = builder.build(); serializer.call(); output.write(ENDRESULT); } else { final XMLSerializerProperties props = new XMLSerializerProperties(); final XMLSerializerBuilder builder = new XMLSerializerBuilder(session, nodeId, output, props); builder.setREST(doNodeId); builder.setID(doNodeId); builder.setDeclaration(false); final XMLSerializer serializer = builder.build(); serializer.call(); } } catch (final TTException ttExcep) { throw new JaxRxException(ttExcep); } catch (final IOException ioExcep) { throw new JaxRxException(ioExcep); } catch (final Exception globExcep) { if (globExcep instanceof JaxRxException) { // NOPMD due // to // different // exception // types throw (JaxRxException)globExcep; } else { throw new JaxRxException(globExcep); } } finally { try { WorkerHelper.closeRTX(null, session); } catch (final TTException exce) { throw new JaxRxException(exce); } } } else { throw new JaxRxException(404, "Resource does not exist"); } }
[ "private", "void", "serialize", "(", "final", "String", "resource", ",", "final", "long", "nodeId", ",", "final", "Long", "revision", ",", "final", "boolean", "doNodeId", ",", "final", "OutputStream", "output", ",", "final", "boolean", "wrapResult", ")", "{", ...
This method serializes requested resource @param resource The requested resource @param nodeId The node id of the requested resource. @param revision The revision of the requested resource. @param doNodeId Specifies whether the node id's have to be shown in the result. @param output The output stream to be written. @param wrapResult Specifies whether the result has to be wrapped with a result element.
[ "This", "method", "serializes", "requested", "resource" ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/implementation/NodeIdRepresentation.java#L409-L463
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/comparators/AbsComparator.java
AbsComparator.getComparator
public static final AbsComparator getComparator(final INodeReadTrx paramRtx, final AbsAxis paramOperandOne, final AbsAxis paramOperandTwo, final CompKind paramKind, final String paramVal) { if ("eq".equals(paramVal) || "lt".equals(paramVal) || "le".equals(paramVal) || "gt".equals(paramVal) || "ge".equals(paramVal)) { return new ValueComp(paramRtx, paramOperandOne, paramOperandTwo, paramKind); } else if ("=".equals(paramVal) || "!=".equals(paramVal) || "<".equals(paramVal) || "<=".equals(paramVal) || ">".equals(paramVal) || ">=".equals(paramVal)) { return new GeneralComp(paramRtx, paramOperandOne, paramOperandTwo, paramKind); } else if ("is".equals(paramVal) || "<<".equals(paramVal) || ">>".equals(paramVal)) { return new NodeComp(paramRtx, paramOperandOne, paramOperandTwo, paramKind); } throw new IllegalStateException(paramVal + " is not a valid comparison."); }
java
public static final AbsComparator getComparator(final INodeReadTrx paramRtx, final AbsAxis paramOperandOne, final AbsAxis paramOperandTwo, final CompKind paramKind, final String paramVal) { if ("eq".equals(paramVal) || "lt".equals(paramVal) || "le".equals(paramVal) || "gt".equals(paramVal) || "ge".equals(paramVal)) { return new ValueComp(paramRtx, paramOperandOne, paramOperandTwo, paramKind); } else if ("=".equals(paramVal) || "!=".equals(paramVal) || "<".equals(paramVal) || "<=".equals(paramVal) || ">".equals(paramVal) || ">=".equals(paramVal)) { return new GeneralComp(paramRtx, paramOperandOne, paramOperandTwo, paramKind); } else if ("is".equals(paramVal) || "<<".equals(paramVal) || ">>".equals(paramVal)) { return new NodeComp(paramRtx, paramOperandOne, paramOperandTwo, paramKind); } throw new IllegalStateException(paramVal + " is not a valid comparison."); }
[ "public", "static", "final", "AbsComparator", "getComparator", "(", "final", "INodeReadTrx", "paramRtx", ",", "final", "AbsAxis", "paramOperandOne", ",", "final", "AbsAxis", "paramOperandTwo", ",", "final", "CompKind", "paramKind", ",", "final", "String", "paramVal", ...
Factory method to implement the comparator. @param paramRtx rtx for accessing data @param paramOperandOne operand one to be compared @param paramOperandTwo operand two to be compared @param paramKind kind of comparison @param paramVal string value to estimate @return AbsComparator the comparator of two axis
[ "Factory", "method", "to", "implement", "the", "comparator", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/comparators/AbsComparator.java#L227-L240
train
Bedework/bw-util
bw-util-struts/src/main/java/org/bedework/util/struts/Request.java
Request.getIntReqPar
public Integer getIntReqPar(final String name, final String errProp) throws Throwable { try { return super.getIntReqPar(name); } catch (final Throwable t) { getErr().emit(errProp, getReqPar(name)); return null; } }
java
public Integer getIntReqPar(final String name, final String errProp) throws Throwable { try { return super.getIntReqPar(name); } catch (final Throwable t) { getErr().emit(errProp, getReqPar(name)); return null; } }
[ "public", "Integer", "getIntReqPar", "(", "final", "String", "name", ",", "final", "String", "errProp", ")", "throws", "Throwable", "{", "try", "{", "return", "super", ".", "getIntReqPar", "(", "name", ")", ";", "}", "catch", "(", "final", "Throwable", "t"...
Get an Integer request parameter or null. Emit error for non-null and non integer @param name name of parameter @param errProp error to emit @return Integer value or null @throws Throwable on error
[ "Get", "an", "Integer", "request", "parameter", "or", "null", ".", "Emit", "error", "for", "non", "-", "null", "and", "non", "integer" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/Request.java#L267-L275
train
centic9/commons-dost
src/main/java/org/dstadler/commons/net/UrlUtils.java
UrlUtils.retrieveData
public static String retrieveData(String sUrl, int timeout) throws IOException { return retrieveData(sUrl, null, timeout); }
java
public static String retrieveData(String sUrl, int timeout) throws IOException { return retrieveData(sUrl, null, timeout); }
[ "public", "static", "String", "retrieveData", "(", "String", "sUrl", ",", "int", "timeout", ")", "throws", "IOException", "{", "return", "retrieveData", "(", "sUrl", ",", "null", ",", "timeout", ")", ";", "}" ]
Download data from an URL. @param sUrl The full URL used to download the content. @param timeout The timeout in milliseconds that is used for both connection timeout and read timeout. @return The resulting data, e.g. a HTML string. @throws IOException If accessing the resource fails.
[ "Download", "data", "from", "an", "URL", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/net/UrlUtils.java#L48-L50
train
centic9/commons-dost
src/main/java/org/dstadler/commons/net/UrlUtils.java
UrlUtils.retrieveData
public static String retrieveData(String sUrl, String encoding, int timeout, SSLSocketFactory sslFactory) throws IOException { byte[] rawData = retrieveRawData(sUrl, timeout, sslFactory); if(encoding == null) { return new String(rawData); // NOSONAR } return new String(rawData, encoding); }
java
public static String retrieveData(String sUrl, String encoding, int timeout, SSLSocketFactory sslFactory) throws IOException { byte[] rawData = retrieveRawData(sUrl, timeout, sslFactory); if(encoding == null) { return new String(rawData); // NOSONAR } return new String(rawData, encoding); }
[ "public", "static", "String", "retrieveData", "(", "String", "sUrl", ",", "String", "encoding", ",", "int", "timeout", ",", "SSLSocketFactory", "sslFactory", ")", "throws", "IOException", "{", "byte", "[", "]", "rawData", "=", "retrieveRawData", "(", "sUrl", "...
Download data from an URL, if necessary converting from a character encoding. @param sUrl The full URL used to download the content. @param encoding An encoding, e.g. UTF-8, ISO-8859-15. Can be null. @param timeout The timeout in milliseconds that is used for both connection timeout and read timeout. @param sslFactory The SSLFactory to use for the connection, this allows to support custom SSL certificates @return The resulting data, e.g. a HTML string. @throws IOException If accessing the resource fails.
[ "Download", "data", "from", "an", "URL", "if", "necessary", "converting", "from", "a", "character", "encoding", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/net/UrlUtils.java#L81-L88
train
centic9/commons-dost
src/main/java/org/dstadler/commons/net/UrlUtils.java
UrlUtils.retrieveRawData
public static byte[] retrieveRawData(String sUrl, int timeout, SSLSocketFactory sslFactory) throws IOException { URL url = new URL(sUrl); LOGGER.fine("Using the following URL for retrieving the data: " + url.toString()); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); // set specified timeout if non-zero if(timeout != 0) { conn.setConnectTimeout(timeout); conn.setReadTimeout(timeout); } try { conn.setDoOutput(false); conn.setDoInput(true); if(conn instanceof HttpsURLConnection && sslFactory != null) { ((HttpsURLConnection)conn).setSSLSocketFactory(sslFactory); } conn.connect(); int code = conn.getResponseCode(); if (code != HttpURLConnection.HTTP_OK && code != HttpURLConnection.HTTP_CREATED && code != HttpURLConnection.HTTP_ACCEPTED) { String msg = "Error " + code + " returned while retrieving response for url '" + url + "' message from client: " + conn.getResponseMessage(); LOGGER.warning(msg); throw new IOException(msg); } try (InputStream strm = conn.getInputStream()) { return IOUtils.toByteArray(strm); } // actually read the contents, even if we are not using it to simulate a full download of the data /*ByteArrayOutputStream memStream = new ByteArrayOutputStream(conn.getContentLength() == -1 ? 40000 : conn.getContentLength()); try { byte b[] = new byte[4096]; int len; while ((len = strm.read(b)) > 0) { memStream.write(b, 0, len); } } finally { memStream.close(); } if(LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Received data, size: " + memStream.size() + "(" + conn.getContentLength() + ") first bytes: " + replaceInvalidChar(memStream.toString().substring(0, Math.min(memStream.size(), REPORT_PEEK_COUNT)))); } return memStream.toByteArray();*/ } finally { conn.disconnect(); } }
java
public static byte[] retrieveRawData(String sUrl, int timeout, SSLSocketFactory sslFactory) throws IOException { URL url = new URL(sUrl); LOGGER.fine("Using the following URL for retrieving the data: " + url.toString()); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); // set specified timeout if non-zero if(timeout != 0) { conn.setConnectTimeout(timeout); conn.setReadTimeout(timeout); } try { conn.setDoOutput(false); conn.setDoInput(true); if(conn instanceof HttpsURLConnection && sslFactory != null) { ((HttpsURLConnection)conn).setSSLSocketFactory(sslFactory); } conn.connect(); int code = conn.getResponseCode(); if (code != HttpURLConnection.HTTP_OK && code != HttpURLConnection.HTTP_CREATED && code != HttpURLConnection.HTTP_ACCEPTED) { String msg = "Error " + code + " returned while retrieving response for url '" + url + "' message from client: " + conn.getResponseMessage(); LOGGER.warning(msg); throw new IOException(msg); } try (InputStream strm = conn.getInputStream()) { return IOUtils.toByteArray(strm); } // actually read the contents, even if we are not using it to simulate a full download of the data /*ByteArrayOutputStream memStream = new ByteArrayOutputStream(conn.getContentLength() == -1 ? 40000 : conn.getContentLength()); try { byte b[] = new byte[4096]; int len; while ((len = strm.read(b)) > 0) { memStream.write(b, 0, len); } } finally { memStream.close(); } if(LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Received data, size: " + memStream.size() + "(" + conn.getContentLength() + ") first bytes: " + replaceInvalidChar(memStream.toString().substring(0, Math.min(memStream.size(), REPORT_PEEK_COUNT)))); } return memStream.toByteArray();*/ } finally { conn.disconnect(); } }
[ "public", "static", "byte", "[", "]", "retrieveRawData", "(", "String", "sUrl", ",", "int", "timeout", ",", "SSLSocketFactory", "sslFactory", ")", "throws", "IOException", "{", "URL", "url", "=", "new", "URL", "(", "sUrl", ")", ";", "LOGGER", ".", "fine", ...
Download data from an URL and return the raw bytes. @param sUrl The full URL used to download the content. @param timeout The timeout in milliseconds that is used for both connection timeout and read timeout. @param sslFactory The SSLFactory to use for the connection, this allows to support custom SSL certificates @return The resulting data, e.g. a HTML string as byte array. @throws IOException If accessing the resource fails.
[ "Download", "data", "from", "an", "URL", "and", "return", "the", "raw", "bytes", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/net/UrlUtils.java#L117-L175
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/operators/AbsObAxis.java
AbsObAxis.atomize
private AtomicValue atomize(final AbsAxis mOperand) { int type = getNode().getTypeKey(); AtomicValue atom; if (XPATH_10_COMP) { atom = new AtomicValue(((ITreeValData)getNode()).getRawValue(), getNode().getTypeKey()); } else { // unatomicType is cast to double if (type == NamePageHash.generateHashForString("xs:untypedAtomic")) { type = NamePageHash.generateHashForString("xs:double"); // TODO: throw error, of cast fails } atom = new AtomicValue(((ITreeValData)getNode()).getRawValue(), getNode().getTypeKey()); } // if (!XPATH_10_COMP && operand.hasNext()) { // throw new XPathError(ErrorType.XPTY0004); // } return atom; }
java
private AtomicValue atomize(final AbsAxis mOperand) { int type = getNode().getTypeKey(); AtomicValue atom; if (XPATH_10_COMP) { atom = new AtomicValue(((ITreeValData)getNode()).getRawValue(), getNode().getTypeKey()); } else { // unatomicType is cast to double if (type == NamePageHash.generateHashForString("xs:untypedAtomic")) { type = NamePageHash.generateHashForString("xs:double"); // TODO: throw error, of cast fails } atom = new AtomicValue(((ITreeValData)getNode()).getRawValue(), getNode().getTypeKey()); } // if (!XPATH_10_COMP && operand.hasNext()) { // throw new XPathError(ErrorType.XPTY0004); // } return atom; }
[ "private", "AtomicValue", "atomize", "(", "final", "AbsAxis", "mOperand", ")", "{", "int", "type", "=", "getNode", "(", ")", ".", "getTypeKey", "(", ")", ";", "AtomicValue", "atom", ";", "if", "(", "XPATH_10_COMP", ")", "{", "atom", "=", "new", "AtomicVa...
Atomizes an operand according to the rules specified in the XPath specification. @param mOperand the operand to atomize @return the atomized operand. (always an atomic value)
[ "Atomizes", "an", "operand", "according", "to", "the", "rules", "specified", "in", "the", "XPath", "specification", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/operators/AbsObAxis.java#L152-L175
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/ldap/LdapDirectory.java
LdapDirectory.checkProp
public String checkProp(final Properties pr, final String name, final String defaultVal) { String val = pr.getProperty(name); if (val == null) { pr.put(name, defaultVal); val = defaultVal; } return val; }
java
public String checkProp(final Properties pr, final String name, final String defaultVal) { String val = pr.getProperty(name); if (val == null) { pr.put(name, defaultVal); val = defaultVal; } return val; }
[ "public", "String", "checkProp", "(", "final", "Properties", "pr", ",", "final", "String", "name", ",", "final", "String", "defaultVal", ")", "{", "String", "val", "=", "pr", ".", "getProperty", "(", "name", ")", ";", "if", "(", "val", "==", "null", ")...
If the named property is present and has a value use that. Otherwise, set the value to the given default and use that. @param pr @param name @param defaultVal @return String
[ "If", "the", "named", "property", "is", "present", "and", "has", "a", "value", "use", "that", ".", "Otherwise", "set", "the", "value", "to", "the", "given", "default", "and", "use", "that", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/ldap/LdapDirectory.java#L305-L314
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.finishExpr
public void finishExpr(final INodeReadTrx mTransaction, final int mNum) { // all singleExpression that are on the stack will be combined in the // sequence, so the number of singleExpressions in the sequence and the // size // of the stack containing these SingleExpressions have to be the same. if (getPipeStack().size() != mNum) { // this should never happen throw new IllegalStateException("The query has not been processed correctly"); } int no = mNum; AbsAxis[] axis; if (no > 1) { axis = new AbsAxis[no]; // add all SingleExpression to a list while (no-- > 0) { axis[no] = getPipeStack().pop().getExpr(); } if (mExprStack.size() > 1) { assert mExprStack.peek().empty(); mExprStack.pop(); } if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(new SequenceAxis(mTransaction, axis)); } else if (no == 1) { // only one expression does not need to be capsled by a seq axis = new AbsAxis[1]; axis[0] = getPipeStack().pop().getExpr(); if (mExprStack.size() > 1) { assert mExprStack.peek().empty(); mExprStack.pop(); } if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } final AbsAxis iAxis; if (mExprStack.size() == 1 && getPipeStack().size() == 1 && getExpression().getSize() == 0) { iAxis = new SequenceAxis(mTransaction, axis); } else { iAxis = axis[0]; } getExpression().add(iAxis); } else { mExprStack.pop(); } }
java
public void finishExpr(final INodeReadTrx mTransaction, final int mNum) { // all singleExpression that are on the stack will be combined in the // sequence, so the number of singleExpressions in the sequence and the // size // of the stack containing these SingleExpressions have to be the same. if (getPipeStack().size() != mNum) { // this should never happen throw new IllegalStateException("The query has not been processed correctly"); } int no = mNum; AbsAxis[] axis; if (no > 1) { axis = new AbsAxis[no]; // add all SingleExpression to a list while (no-- > 0) { axis[no] = getPipeStack().pop().getExpr(); } if (mExprStack.size() > 1) { assert mExprStack.peek().empty(); mExprStack.pop(); } if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(new SequenceAxis(mTransaction, axis)); } else if (no == 1) { // only one expression does not need to be capsled by a seq axis = new AbsAxis[1]; axis[0] = getPipeStack().pop().getExpr(); if (mExprStack.size() > 1) { assert mExprStack.peek().empty(); mExprStack.pop(); } if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } final AbsAxis iAxis; if (mExprStack.size() == 1 && getPipeStack().size() == 1 && getExpression().getSize() == 0) { iAxis = new SequenceAxis(mTransaction, axis); } else { iAxis = axis[0]; } getExpression().add(iAxis); } else { mExprStack.pop(); } }
[ "public", "void", "finishExpr", "(", "final", "INodeReadTrx", "mTransaction", ",", "final", "int", "mNum", ")", "{", "// all singleExpression that are on the stack will be combined in the", "// sequence, so the number of singleExpressions in the sequence and the", "// size", "// of t...
Ends an expression. This means that the currently used pipeline stack will be emptied and the singleExpressions that were on the stack are combined by a sequence expression, which is lated added to the next pipeline stack. @param mTransaction transaction to operate on @param mNum number of singleExpressions that will be added to the sequence
[ "Ends", "an", "expression", ".", "This", "means", "that", "the", "currently", "used", "pipeline", "stack", "will", "be", "emptied", "and", "the", "singleExpressions", "that", "were", "on", "the", "stack", "are", "combined", "by", "a", "sequence", "expression",...
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L131-L190
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addIfExpression
public void addIfExpression(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 3; final INodeReadTrx rtx = mTransaction; final AbsAxis elseExpr = getPipeStack().pop().getExpr(); final AbsAxis thenExpr = getPipeStack().pop().getExpr(); final AbsAxis ifExpr = getPipeStack().pop().getExpr(); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(new IfAxis(rtx, ifExpr, thenExpr, elseExpr)); }
java
public void addIfExpression(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 3; final INodeReadTrx rtx = mTransaction; final AbsAxis elseExpr = getPipeStack().pop().getExpr(); final AbsAxis thenExpr = getPipeStack().pop().getExpr(); final AbsAxis ifExpr = getPipeStack().pop().getExpr(); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(new IfAxis(rtx, ifExpr, thenExpr, elseExpr)); }
[ "public", "void", "addIfExpression", "(", "final", "INodeReadTrx", "mTransaction", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "3", ";", "final", "INodeReadTrx", "rtx", "=", "mTransaction", ";", "final", "AbsAxis", "elseExpr", ...
Adds a if expression to the pipeline. @param mTransaction Transaction to operate with.
[ "Adds", "a", "if", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L250-L265
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addCompExpression
public void addCompExpression(final INodeReadTrx mTransaction, final String mComp) { assert getPipeStack().size() >= 2; final INodeReadTrx rtx = mTransaction; final AbsAxis paramOperandTwo = getPipeStack().pop().getExpr(); final AbsAxis paramOperandOne = getPipeStack().pop().getExpr(); final CompKind kind = CompKind.fromString(mComp); final AbsAxis axis = AbsComparator.getComparator(rtx, paramOperandOne, paramOperandTwo, kind, mComp); // // TODO: use typeswitch of JAVA 7 // if (mComp.equals("eq")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("ne")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("lt")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("le")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("gt")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("ge")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // // } else if (mComp.equals("=")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("!=")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("<")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("<=")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals(">")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals(">=")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // // } else if (mComp.equals("is")) { // // axis = new NodeComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("<<")) { // // axis = new NodeComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals(">>")) { // // axis = new NodeComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else { // throw new IllegalStateException(mComp + // " is not a valid comparison."); // // } if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
java
public void addCompExpression(final INodeReadTrx mTransaction, final String mComp) { assert getPipeStack().size() >= 2; final INodeReadTrx rtx = mTransaction; final AbsAxis paramOperandTwo = getPipeStack().pop().getExpr(); final AbsAxis paramOperandOne = getPipeStack().pop().getExpr(); final CompKind kind = CompKind.fromString(mComp); final AbsAxis axis = AbsComparator.getComparator(rtx, paramOperandOne, paramOperandTwo, kind, mComp); // // TODO: use typeswitch of JAVA 7 // if (mComp.equals("eq")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("ne")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("lt")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("le")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("gt")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("ge")) { // // axis = new ValueComp(rtx, paramOperandOne, paramOperandTwo, kind); // // } else if (mComp.equals("=")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("!=")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("<")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("<=")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals(">")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals(">=")) { // // axis = new GeneralComp(rtx, paramOperandOne, paramOperandTwo, kind); // // } else if (mComp.equals("is")) { // // axis = new NodeComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals("<<")) { // // axis = new NodeComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else if (mComp.equals(">>")) { // // axis = new NodeComp(rtx, paramOperandOne, paramOperandTwo, kind); // } else { // throw new IllegalStateException(mComp + // " is not a valid comparison."); // // } if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
[ "public", "void", "addCompExpression", "(", "final", "INodeReadTrx", "mTransaction", ",", "final", "String", "mComp", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "2", ";", "final", "INodeReadTrx", "rtx", "=", "mTransaction", ";...
Adds a comparison expression to the pipeline. @param mTransaction Transaction to operate with. @param mComp Comparator type.
[ "Adds", "a", "comparison", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L275-L346
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addOperatorExpression
public void addOperatorExpression(final INodeReadTrx mTransaction, final String mOperator) { assert getPipeStack().size() >= 1; final INodeReadTrx rtx = mTransaction; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); // the unary operation only has one operator final AbsAxis mOperand1 = getPipeStack().pop().getExpr(); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } final AbsAxis axis; // TODO: use typeswitch of JAVA 7 if (mOperator.equals("+")) { axis = new AddOpAxis(rtx, mOperand1, mOperand2); } else if (mOperator.equals("-")) { axis = new SubOpAxis(rtx, mOperand1, mOperand2); } else if (mOperator.equals("*")) { axis = new MulOpAxis(rtx, mOperand1, mOperand2); } else if (mOperator.equals("div")) { axis = new DivOpAxis(rtx, mOperand1, mOperand2); } else if (mOperator.equals("idiv")) { axis = new IDivOpAxis(rtx, mOperand1, mOperand2); } else if (mOperator.equals("mod")) { axis = new ModOpAxis(rtx, mOperand1, mOperand2); } else { // TODO: unary operator throw new IllegalStateException(mOperator + " is not a valid operator."); } getExpression().add(axis); }
java
public void addOperatorExpression(final INodeReadTrx mTransaction, final String mOperator) { assert getPipeStack().size() >= 1; final INodeReadTrx rtx = mTransaction; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); // the unary operation only has one operator final AbsAxis mOperand1 = getPipeStack().pop().getExpr(); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } final AbsAxis axis; // TODO: use typeswitch of JAVA 7 if (mOperator.equals("+")) { axis = new AddOpAxis(rtx, mOperand1, mOperand2); } else if (mOperator.equals("-")) { axis = new SubOpAxis(rtx, mOperand1, mOperand2); } else if (mOperator.equals("*")) { axis = new MulOpAxis(rtx, mOperand1, mOperand2); } else if (mOperator.equals("div")) { axis = new DivOpAxis(rtx, mOperand1, mOperand2); } else if (mOperator.equals("idiv")) { axis = new IDivOpAxis(rtx, mOperand1, mOperand2); } else if (mOperator.equals("mod")) { axis = new ModOpAxis(rtx, mOperand1, mOperand2); } else { // TODO: unary operator throw new IllegalStateException(mOperator + " is not a valid operator."); } getExpression().add(axis); }
[ "public", "void", "addOperatorExpression", "(", "final", "INodeReadTrx", "mTransaction", ",", "final", "String", "mOperator", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "1", ";", "final", "INodeReadTrx", "rtx", "=", "mTransactio...
Adds an operator expression to the pipeline. @param mTransaction Transaction to operate with. @param mOperator Operator type.
[ "Adds", "an", "operator", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L356-L393
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addUnionExpression
public void addUnionExpression(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 2; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); final AbsAxis mOperand1 = getPipeStack().pop().getExpr(); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add( new DupFilterAxis(mTransaction, new UnionAxis(mTransaction, mOperand1, mOperand2))); }
java
public void addUnionExpression(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 2; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); final AbsAxis mOperand1 = getPipeStack().pop().getExpr(); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add( new DupFilterAxis(mTransaction, new UnionAxis(mTransaction, mOperand1, mOperand2))); }
[ "public", "void", "addUnionExpression", "(", "final", "INodeReadTrx", "mTransaction", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "2", ";", "final", "AbsAxis", "mOperand2", "=", "getPipeStack", "(", ")", ".", "pop", "(", ")",...
Adds a union expression to the pipeline. @param mTransaction Transaction to operate with.
[ "Adds", "a", "union", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L401-L412
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addAndExpression
public void addAndExpression(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 2; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); final AbsAxis operand1 = getPipeStack().pop().getExpr(); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(new AndExpr(mTransaction, operand1, mOperand2)); }
java
public void addAndExpression(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 2; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); final AbsAxis operand1 = getPipeStack().pop().getExpr(); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(new AndExpr(mTransaction, operand1, mOperand2)); }
[ "public", "void", "addAndExpression", "(", "final", "INodeReadTrx", "mTransaction", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "2", ";", "final", "AbsAxis", "mOperand2", "=", "getPipeStack", "(", ")", ".", "pop", "(", ")", ...
Adds a and expression to the pipeline. @param mTransaction Transaction to operate with.
[ "Adds", "a", "and", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L420-L429
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addOrExpression
public void addOrExpression(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 2; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); final AbsAxis mOperand1 = getPipeStack().pop().getExpr(); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(new OrExpr(mTransaction, mOperand1, mOperand2)); }
java
public void addOrExpression(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 2; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); final AbsAxis mOperand1 = getPipeStack().pop().getExpr(); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(new OrExpr(mTransaction, mOperand1, mOperand2)); }
[ "public", "void", "addOrExpression", "(", "final", "INodeReadTrx", "mTransaction", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "2", ";", "final", "AbsAxis", "mOperand2", "=", "getPipeStack", "(", ")", ".", "pop", "(", ")", ...
Adds a or expression to the pipeline. @param mTransaction Transaction to operate with.
[ "Adds", "a", "or", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L437-L448
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addIntExcExpression
public void addIntExcExpression(final INodeReadTrx mTransaction, final boolean mIsIntersect) { assert getPipeStack().size() >= 2; final INodeReadTrx rtx = mTransaction; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); final AbsAxis mOperand1 = getPipeStack().pop().getExpr(); final AbsAxis axis = mIsIntersect ? new IntersectAxis(rtx, mOperand1, mOperand2) : new ExceptAxis(rtx, mOperand1, mOperand2); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
java
public void addIntExcExpression(final INodeReadTrx mTransaction, final boolean mIsIntersect) { assert getPipeStack().size() >= 2; final INodeReadTrx rtx = mTransaction; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); final AbsAxis mOperand1 = getPipeStack().pop().getExpr(); final AbsAxis axis = mIsIntersect ? new IntersectAxis(rtx, mOperand1, mOperand2) : new ExceptAxis(rtx, mOperand1, mOperand2); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
[ "public", "void", "addIntExcExpression", "(", "final", "INodeReadTrx", "mTransaction", ",", "final", "boolean", "mIsIntersect", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "2", ";", "final", "INodeReadTrx", "rtx", "=", "mTransact...
Adds a intersect or a exception expression to the pipeline. @param mTransaction Transaction to operate with. @param mIsIntersect true, if expression is an intersection
[ "Adds", "a", "intersect", "or", "a", "exception", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L458-L475
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addLiteral
public void addLiteral(final INodeReadTrx pTrans, final AtomicValue pVal) { getExpression().add(new LiteralExpr(pTrans, AbsAxis.addAtomicToItemList(pTrans, pVal))); }
java
public void addLiteral(final INodeReadTrx pTrans, final AtomicValue pVal) { getExpression().add(new LiteralExpr(pTrans, AbsAxis.addAtomicToItemList(pTrans, pVal))); }
[ "public", "void", "addLiteral", "(", "final", "INodeReadTrx", "pTrans", ",", "final", "AtomicValue", "pVal", ")", "{", "getExpression", "(", ")", ".", "add", "(", "new", "LiteralExpr", "(", "pTrans", ",", "AbsAxis", ".", "addAtomicToItemList", "(", "pTrans", ...
Adds a literal expression to the pipeline. @param pTrans Transaction to operate with. @param pVal key of the literal expression.
[ "Adds", "a", "literal", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L485-L487
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addStep
public void addStep(final AbsAxis axis, final AbsFilter mFilter) { getExpression().add(new FilterAxis(axis, mRtx, mFilter)); }
java
public void addStep(final AbsAxis axis, final AbsFilter mFilter) { getExpression().add(new FilterAxis(axis, mRtx, mFilter)); }
[ "public", "void", "addStep", "(", "final", "AbsAxis", "axis", ",", "final", "AbsFilter", "mFilter", ")", "{", "getExpression", "(", ")", ".", "add", "(", "new", "FilterAxis", "(", "axis", ",", "mRtx", ",", "mFilter", ")", ")", ";", "}" ]
Adds a step to the pipeline. @param axis the axis step to add to the pipeline. @param mFilter the node test to add to the pipeline.
[ "Adds", "a", "step", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L508-L511
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.getPipeline
public AbsAxis getPipeline() { assert getPipeStack().size() <= 1; if (getPipeStack().size() == 1 && mExprStack.size() == 1) { return getPipeStack().pop().getExpr(); } else { throw new IllegalStateException("Query was not build correctly."); } }
java
public AbsAxis getPipeline() { assert getPipeStack().size() <= 1; if (getPipeStack().size() == 1 && mExprStack.size() == 1) { return getPipeStack().pop().getExpr(); } else { throw new IllegalStateException("Query was not build correctly."); } }
[ "public", "AbsAxis", "getPipeline", "(", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", "<=", "1", ";", "if", "(", "getPipeStack", "(", ")", ".", "size", "(", ")", "==", "1", "&&", "mExprStack", ".", "size", "(", ")", "==", ...
Returns a queue of all pipelines build so far and empties the pipeline stack. @return all build pipelines
[ "Returns", "a", "queue", "of", "all", "pipelines", "build", "so", "far", "and", "empties", "the", "pipeline", "stack", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L519-L529
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addPredicate
public void addPredicate(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 2; final AbsAxis mPredicate = getPipeStack().pop().getExpr(); if (mPredicate instanceof LiteralExpr) { mPredicate.hasNext(); // if is numeric literal -> abbrev for position() final int type = mTransaction.getNode().getTypeKey(); if (type == NamePageHash.generateHashForString("xs:integer") || type == NamePageHash.generateHashForString("xs:double") || type == NamePageHash.generateHashForString("xs:float") || type == NamePageHash.generateHashForString("xs:decimal")) { throw new IllegalStateException("function fn:position() is not implemented yet."); // getExpression().add( // new PosFilter(transaction, (int) // Double.parseDouble(transaction // .getValue()))); // return; // TODO: YES! it is dirty! // AtomicValue pos = // new AtomicValue(mTransaction.getNode().getRawValue(), // mTransaction // .keyForName("xs:integer")); // long position = mTransaction.getItemList().addItem(pos); // mPredicate.reset(mTransaction.getNode().getNodeKey()); // IAxis function = // new FNPosition(mTransaction, new ArrayList<IAxis>(), // FuncDef.POS.getMin(), FuncDef.POS // .getMax(), // mTransaction.keyForName(FuncDef.POS.getReturnType())); // IAxis expectedPos = new LiteralExpr(mTransaction, position); // // mPredicate = new ValueComp(mTransaction, function, // expectedPos, CompKind.EQ); } } getExpression().add(new PredicateFilterAxis(mTransaction, mPredicate)); }
java
public void addPredicate(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 2; final AbsAxis mPredicate = getPipeStack().pop().getExpr(); if (mPredicate instanceof LiteralExpr) { mPredicate.hasNext(); // if is numeric literal -> abbrev for position() final int type = mTransaction.getNode().getTypeKey(); if (type == NamePageHash.generateHashForString("xs:integer") || type == NamePageHash.generateHashForString("xs:double") || type == NamePageHash.generateHashForString("xs:float") || type == NamePageHash.generateHashForString("xs:decimal")) { throw new IllegalStateException("function fn:position() is not implemented yet."); // getExpression().add( // new PosFilter(transaction, (int) // Double.parseDouble(transaction // .getValue()))); // return; // TODO: YES! it is dirty! // AtomicValue pos = // new AtomicValue(mTransaction.getNode().getRawValue(), // mTransaction // .keyForName("xs:integer")); // long position = mTransaction.getItemList().addItem(pos); // mPredicate.reset(mTransaction.getNode().getNodeKey()); // IAxis function = // new FNPosition(mTransaction, new ArrayList<IAxis>(), // FuncDef.POS.getMin(), FuncDef.POS // .getMax(), // mTransaction.keyForName(FuncDef.POS.getReturnType())); // IAxis expectedPos = new LiteralExpr(mTransaction, position); // // mPredicate = new ValueComp(mTransaction, function, // expectedPos, CompKind.EQ); } } getExpression().add(new PredicateFilterAxis(mTransaction, mPredicate)); }
[ "public", "void", "addPredicate", "(", "final", "INodeReadTrx", "mTransaction", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "2", ";", "final", "AbsAxis", "mPredicate", "=", "getPipeStack", "(", ")", ".", "pop", "(", ")", "....
Adds a predicate to the pipeline. @param mTransaction Transaction to operate with.
[ "Adds", "a", "predicate", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L537-L582
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addQuantifierExpr
public void addQuantifierExpr(final INodeReadTrx mTransaction, final boolean mIsSome, final int mVarNum) { assert getPipeStack().size() >= (mVarNum + 1); final AbsAxis satisfy = getPipeStack().pop().getExpr(); final List<AbsAxis> vars = new ArrayList<AbsAxis>(); int num = mVarNum; while (num-- > 0) { // invert current order of variables to get original variable order vars.add(num, getPipeStack().pop().getExpr()); } final AbsAxis mAxis = mIsSome ? new SomeExpr(mTransaction, vars, satisfy) : new EveryExpr(mTransaction, vars, satisfy); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(mAxis); }
java
public void addQuantifierExpr(final INodeReadTrx mTransaction, final boolean mIsSome, final int mVarNum) { assert getPipeStack().size() >= (mVarNum + 1); final AbsAxis satisfy = getPipeStack().pop().getExpr(); final List<AbsAxis> vars = new ArrayList<AbsAxis>(); int num = mVarNum; while (num-- > 0) { // invert current order of variables to get original variable order vars.add(num, getPipeStack().pop().getExpr()); } final AbsAxis mAxis = mIsSome ? new SomeExpr(mTransaction, vars, satisfy) : new EveryExpr(mTransaction, vars, satisfy); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(mAxis); }
[ "public", "void", "addQuantifierExpr", "(", "final", "INodeReadTrx", "mTransaction", ",", "final", "boolean", "mIsSome", ",", "final", "int", "mVarNum", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "(", "mVarNum", "+", "1", ")...
Adds a SomeExpression or an EveryExpression to the pipeline, depending on the parameter isSome. @param mTransaction Transaction to operate with. @param mIsSome defines whether a some- or an EveryExpression is used. @param mVarNum number of binding variables
[ "Adds", "a", "SomeExpression", "or", "an", "EveryExpression", "to", "the", "pipeline", "depending", "on", "the", "parameter", "isSome", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L595-L615
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addCastableExpr
public void addCastableExpr(final INodeReadTrx mTransaction, final SingleType mSingleType) { assert getPipeStack().size() >= 1; final AbsAxis candidate = getPipeStack().pop().getExpr(); final AbsAxis axis = new CastableExpr(mTransaction, candidate, mSingleType); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
java
public void addCastableExpr(final INodeReadTrx mTransaction, final SingleType mSingleType) { assert getPipeStack().size() >= 1; final AbsAxis candidate = getPipeStack().pop().getExpr(); final AbsAxis axis = new CastableExpr(mTransaction, candidate, mSingleType); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
[ "public", "void", "addCastableExpr", "(", "final", "INodeReadTrx", "mTransaction", ",", "final", "SingleType", "mSingleType", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "1", ";", "final", "AbsAxis", "candidate", "=", "getPipeSta...
Adds a castable expression to the pipeline. @param mTransaction Transaction to operate with. @param mSingleType single type the context item will be casted to.
[ "Adds", "a", "castable", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L625-L637
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addRangeExpr
public void addRangeExpr(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 2; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); final AbsAxis mOperand1 = getPipeStack().pop().getExpr(); final AbsAxis axis = new RangeAxis(mTransaction, mOperand1, mOperand2); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
java
public void addRangeExpr(final INodeReadTrx mTransaction) { assert getPipeStack().size() >= 2; final AbsAxis mOperand2 = getPipeStack().pop().getExpr(); final AbsAxis mOperand1 = getPipeStack().pop().getExpr(); final AbsAxis axis = new RangeAxis(mTransaction, mOperand1, mOperand2); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
[ "public", "void", "addRangeExpr", "(", "final", "INodeReadTrx", "mTransaction", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "2", ";", "final", "AbsAxis", "mOperand2", "=", "getPipeStack", "(", ")", ".", "pop", "(", ")", "."...
Adds a range expression to the pipeline. @param mTransaction Transaction to operate with.
[ "Adds", "a", "range", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L645-L658
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addInstanceOfExpr
public void addInstanceOfExpr(final INodeReadTrx mTransaction, final SequenceType mSequenceType) { assert getPipeStack().size() >= 1; final AbsAxis candidate = getPipeStack().pop().getExpr(); final AbsAxis axis = new InstanceOfExpr(mTransaction, candidate, mSequenceType); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
java
public void addInstanceOfExpr(final INodeReadTrx mTransaction, final SequenceType mSequenceType) { assert getPipeStack().size() >= 1; final AbsAxis candidate = getPipeStack().pop().getExpr(); final AbsAxis axis = new InstanceOfExpr(mTransaction, candidate, mSequenceType); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
[ "public", "void", "addInstanceOfExpr", "(", "final", "INodeReadTrx", "mTransaction", ",", "final", "SequenceType", "mSequenceType", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "1", ";", "final", "AbsAxis", "candidate", "=", "getP...
Adds a instance of expression to the pipeline. @param mTransaction Transaction to operate with. @param mSequenceType sequence type the context item should match.
[ "Adds", "a", "instance", "of", "expression", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L668-L680
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addVariableExpr
public void addVariableExpr(final INodeReadTrx mTransaction, final String mVarName) { assert getPipeStack().size() >= 1; final AbsAxis bindingSeq = getPipeStack().pop().getExpr(); final AbsAxis axis = new VariableAxis(mTransaction, bindingSeq); mVarRefMap.put(mVarName, axis); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
java
public void addVariableExpr(final INodeReadTrx mTransaction, final String mVarName) { assert getPipeStack().size() >= 1; final AbsAxis bindingSeq = getPipeStack().pop().getExpr(); final AbsAxis axis = new VariableAxis(mTransaction, bindingSeq); mVarRefMap.put(mVarName, axis); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); }
[ "public", "void", "addVariableExpr", "(", "final", "INodeReadTrx", "mTransaction", ",", "final", "String", "mVarName", ")", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "1", ";", "final", "AbsAxis", "bindingSeq", "=", "getPipeStack", ...
Adds a variable expression to the pipeline. Adds the expression that will evaluate the results the variable holds. @param mTransaction Transaction to operate with. @param mVarName name of the variable
[ "Adds", "a", "variable", "expression", "to", "the", "pipeline", ".", "Adds", "the", "expression", "that", "will", "evaluate", "the", "results", "the", "variable", "holds", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L705-L718
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addFunction
public void addFunction(final INodeReadTrx mTransaction, final String mFuncName, final int mNum) throws TTXPathException { assert getPipeStack().size() >= mNum; final List<AbsAxis> args = new ArrayList<AbsAxis>(mNum); // arguments are stored on the stack in reverse order -> invert arg // order for (int i = 0; i < mNum; i++) { args.add(getPipeStack().pop().getExpr()); } // get right function type final FuncDef func; try { func = FuncDef.fromString(mFuncName); } catch (final NullPointerException e) { throw EXPathError.XPST0017.getEncapsulatedException(); } // get function class final Class<? extends AbsFunction> function = func.getFunc(); final Integer min = func.getMin(); final Integer max = func.getMax(); final Integer returnType = NamePageHash.generateHashForString(func.getReturnType()); // parameter types of the function's constructor final Class<?>[] paramTypes = { INodeReadTrx.class, List.class, Integer.TYPE, Integer.TYPE, Integer.TYPE }; try { // instantiate function class with right constructor final Constructor<?> cons = function.getConstructor(paramTypes); final AbsAxis axis = (AbsAxis)cons.newInstance(mTransaction, args, min, max, returnType); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); } catch (final NoSuchMethodException e) { throw EXPathError.XPST0017.getEncapsulatedException(); } catch (final IllegalArgumentException e) { throw EXPathError.XPST0017.getEncapsulatedException(); } catch (final InstantiationException e) { throw new IllegalStateException("Function not implemented yet."); } catch (final IllegalAccessException e) { throw EXPathError.XPST0017.getEncapsulatedException(); } catch (final InvocationTargetException e) { throw EXPathError.XPST0017.getEncapsulatedException(); } }
java
public void addFunction(final INodeReadTrx mTransaction, final String mFuncName, final int mNum) throws TTXPathException { assert getPipeStack().size() >= mNum; final List<AbsAxis> args = new ArrayList<AbsAxis>(mNum); // arguments are stored on the stack in reverse order -> invert arg // order for (int i = 0; i < mNum; i++) { args.add(getPipeStack().pop().getExpr()); } // get right function type final FuncDef func; try { func = FuncDef.fromString(mFuncName); } catch (final NullPointerException e) { throw EXPathError.XPST0017.getEncapsulatedException(); } // get function class final Class<? extends AbsFunction> function = func.getFunc(); final Integer min = func.getMin(); final Integer max = func.getMax(); final Integer returnType = NamePageHash.generateHashForString(func.getReturnType()); // parameter types of the function's constructor final Class<?>[] paramTypes = { INodeReadTrx.class, List.class, Integer.TYPE, Integer.TYPE, Integer.TYPE }; try { // instantiate function class with right constructor final Constructor<?> cons = function.getConstructor(paramTypes); final AbsAxis axis = (AbsAxis)cons.newInstance(mTransaction, args, min, max, returnType); if (getPipeStack().empty() || getExpression().getSize() != 0) { addExpressionSingle(); } getExpression().add(axis); } catch (final NoSuchMethodException e) { throw EXPathError.XPST0017.getEncapsulatedException(); } catch (final IllegalArgumentException e) { throw EXPathError.XPST0017.getEncapsulatedException(); } catch (final InstantiationException e) { throw new IllegalStateException("Function not implemented yet."); } catch (final IllegalAccessException e) { throw EXPathError.XPST0017.getEncapsulatedException(); } catch (final InvocationTargetException e) { throw EXPathError.XPST0017.getEncapsulatedException(); } }
[ "public", "void", "addFunction", "(", "final", "INodeReadTrx", "mTransaction", ",", "final", "String", "mFuncName", ",", "final", "int", "mNum", ")", "throws", "TTXPathException", "{", "assert", "getPipeStack", "(", ")", ".", "size", "(", ")", ">=", "mNum", ...
Adds a function to the pipeline. @param mTransaction Transaction to operate with. @param mFuncName The name of the function @param mNum The number of arguments that are passed to the function @throws TTXPathException if function can't be added
[ "Adds", "a", "function", "to", "the", "pipeline", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L732-L785
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java
PipelineBuilder.addVarRefExpr
public void addVarRefExpr(final INodeReadTrx mTransaction, final String mVarName) { final VariableAxis axis = (VariableAxis)mVarRefMap.get(mVarName); if (axis != null) { getExpression().add(new VarRefExpr(mTransaction, axis)); } else { throw new IllegalStateException("Variable " + mVarName + " unkown."); } }
java
public void addVarRefExpr(final INodeReadTrx mTransaction, final String mVarName) { final VariableAxis axis = (VariableAxis)mVarRefMap.get(mVarName); if (axis != null) { getExpression().add(new VarRefExpr(mTransaction, axis)); } else { throw new IllegalStateException("Variable " + mVarName + " unkown."); } }
[ "public", "void", "addVarRefExpr", "(", "final", "INodeReadTrx", "mTransaction", ",", "final", "String", "mVarName", ")", "{", "final", "VariableAxis", "axis", "=", "(", "VariableAxis", ")", "mVarRefMap", ".", "get", "(", "mVarName", ")", ";", "if", "(", "ax...
Adds a VarRefExpr to the pipeline. This Expression holds a reference to the current context item of the specified variable. @param mTransaction the transaction to operate on. @param mVarName the name of the variable
[ "Adds", "a", "VarRefExpr", "to", "the", "pipeline", ".", "This", "Expression", "holds", "a", "reference", "to", "the", "current", "context", "item", "of", "the", "specified", "variable", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/PipelineBuilder.java#L796-L805
train
Bedework/bw-util
bw-util-misc/src/main/java/org/bedework/util/misc/AbstractProcessorThread.java
AbstractProcessorThread.stopProcess
public static boolean stopProcess(final AbstractProcessorThread proc) { proc.info("************************************************************"); proc.info(" * Stopping " + proc.getName()); proc.info("************************************************************"); proc.setRunning(false); proc.interrupt(); boolean ok = true; try { proc.join(20 * 1000); } catch (final InterruptedException ignored) { } catch (final Throwable t) { proc.error("Error waiting for processor termination"); proc.error(t); ok = false; } proc.info("************************************************************"); proc.info(" * " + proc.getName() + " terminated"); proc.info("************************************************************"); return ok; }
java
public static boolean stopProcess(final AbstractProcessorThread proc) { proc.info("************************************************************"); proc.info(" * Stopping " + proc.getName()); proc.info("************************************************************"); proc.setRunning(false); proc.interrupt(); boolean ok = true; try { proc.join(20 * 1000); } catch (final InterruptedException ignored) { } catch (final Throwable t) { proc.error("Error waiting for processor termination"); proc.error(t); ok = false; } proc.info("************************************************************"); proc.info(" * " + proc.getName() + " terminated"); proc.info("************************************************************"); return ok; }
[ "public", "static", "boolean", "stopProcess", "(", "final", "AbstractProcessorThread", "proc", ")", "{", "proc", ".", "info", "(", "\"************************************************************\"", ")", ";", "proc", ".", "info", "(", "\" * Stopping \"", "+", "proc", ...
Shut down a running process. @param proc the thread process @return false for exception or timeout
[ "Shut", "down", "a", "running", "process", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-misc/src/main/java/org/bedework/util/misc/AbstractProcessorThread.java#L140-L165
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/axis/AbsAxis.java
AbsAxis.reset
public void reset(final long paramNodeKey) { mStartKey = paramNodeKey; mKey = paramNodeKey; mNext = false; lastPointer.remove(mRTX); }
java
public void reset(final long paramNodeKey) { mStartKey = paramNodeKey; mKey = paramNodeKey; mNext = false; lastPointer.remove(mRTX); }
[ "public", "void", "reset", "(", "final", "long", "paramNodeKey", ")", "{", "mStartKey", "=", "paramNodeKey", ";", "mKey", "=", "paramNodeKey", ";", "mNext", "=", "false", ";", "lastPointer", ".", "remove", "(", "mRTX", ")", ";", "}" ]
Resetting the nodekey of this axis to a given nodekey. @param paramNodeKey the nodekey where the reset should occur to.
[ "Resetting", "the", "nodekey", "of", "this", "axis", "to", "a", "given", "nodekey", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/axis/AbsAxis.java#L140-L145
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/axis/AbsAxis.java
AbsAxis.moveTo
public boolean moveTo(final long pKey) { try { if (pKey < 0 || mRTX.moveTo(pKey)) { lastPointer.put(mRTX, pKey); return true; } else { return false; } } catch (TTIOException exc) { throw new RuntimeException(exc); } }
java
public boolean moveTo(final long pKey) { try { if (pKey < 0 || mRTX.moveTo(pKey)) { lastPointer.put(mRTX, pKey); return true; } else { return false; } } catch (TTIOException exc) { throw new RuntimeException(exc); } }
[ "public", "boolean", "moveTo", "(", "final", "long", "pKey", ")", "{", "try", "{", "if", "(", "pKey", "<", "0", "||", "mRTX", ".", "moveTo", "(", "pKey", ")", ")", "{", "lastPointer", ".", "put", "(", "mRTX", ",", "pKey", ")", ";", "return", "tru...
Move cursor to a node by its node key. @param pKey Key of node to select. @return True if the node with the given node key is selected.
[ "Move", "cursor", "to", "a", "node", "by", "its", "node", "key", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/axis/AbsAxis.java#L154-L165
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/axis/AbsAxis.java
AbsAxis.close
public void close() throws TTException { atomics.remove(mRTX); lastPointer.remove(mRTX); mRTX.close(); }
java
public void close() throws TTException { atomics.remove(mRTX); lastPointer.remove(mRTX); mRTX.close(); }
[ "public", "void", "close", "(", ")", "throws", "TTException", "{", "atomics", ".", "remove", "(", "mRTX", ")", ";", "lastPointer", ".", "remove", "(", "mRTX", ")", ";", "mRTX", ".", "close", "(", ")", ";", "}" ]
Closing the Transaction @throws TTException
[ "Closing", "the", "Transaction" ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/axis/AbsAxis.java#L172-L176
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/axis/AbsAxis.java
AbsAxis.getItemList
public ItemList getItemList() { if (!atomics.containsKey(mRTX)) { atomics.put(mRTX, new ItemList()); } return atomics.get(mRTX); }
java
public ItemList getItemList() { if (!atomics.containsKey(mRTX)) { atomics.put(mRTX, new ItemList()); } return atomics.get(mRTX); }
[ "public", "ItemList", "getItemList", "(", ")", "{", "if", "(", "!", "atomics", ".", "containsKey", "(", "mRTX", ")", ")", "{", "atomics", ".", "put", "(", "mRTX", ",", "new", "ItemList", "(", ")", ")", ";", "}", "return", "atomics", ".", "get", "("...
Getting the ItemList. @return the Itemlist
[ "Getting", "the", "ItemList", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/axis/AbsAxis.java#L248-L253
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/axis/AbsAxis.java
AbsAxis.addAtomicToItemList
public static int addAtomicToItemList(final INodeReadTrx pRtx, final AtomicValue pVal) { if (!atomics.containsKey(pRtx)) { atomics.put(pRtx, new ItemList()); } return atomics.get(pRtx).addItem(pVal); }
java
public static int addAtomicToItemList(final INodeReadTrx pRtx, final AtomicValue pVal) { if (!atomics.containsKey(pRtx)) { atomics.put(pRtx, new ItemList()); } return atomics.get(pRtx).addItem(pVal); }
[ "public", "static", "int", "addAtomicToItemList", "(", "final", "INodeReadTrx", "pRtx", ",", "final", "AtomicValue", "pVal", ")", "{", "if", "(", "!", "atomics", ".", "containsKey", "(", "pRtx", ")", ")", "{", "atomics", ".", "put", "(", "pRtx", ",", "ne...
Adding any AtomicVal to any ItemList staticly. @param pRtx as key @param pVal to be added @return the index in the ItemList
[ "Adding", "any", "AtomicVal", "to", "any", "ItemList", "staticly", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/axis/AbsAxis.java#L264-L270
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/ldif/Ldif.java
Ldif.nextRecord
public DirRecord nextRecord() throws NamingException { if (inp == null) { if (in == null) { throw new NamingException("No ldif input stream"); } inp = new LdifRecord.Input(); inp.init(new InputStreamReader(in)); } else if (inp.eof) { return null; } LdifRecord ldr = new LdifRecord(); if (!ldr.read(inp)) { return null; } return ldr; }
java
public DirRecord nextRecord() throws NamingException { if (inp == null) { if (in == null) { throw new NamingException("No ldif input stream"); } inp = new LdifRecord.Input(); inp.init(new InputStreamReader(in)); } else if (inp.eof) { return null; } LdifRecord ldr = new LdifRecord(); if (!ldr.read(inp)) { return null; } return ldr; }
[ "public", "DirRecord", "nextRecord", "(", ")", "throws", "NamingException", "{", "if", "(", "inp", "==", "null", ")", "{", "if", "(", "in", "==", "null", ")", "{", "throw", "new", "NamingException", "(", "\"No ldif input stream\"", ")", ";", "}", "inp", ...
Return the next record in the input stream.
[ "Return", "the", "next", "record", "in", "the", "input", "stream", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/ldif/Ldif.java#L90-L109
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/ldif/Ldif.java
Ldif.dumpLdif
public static void dumpLdif(LdifOut lo, DirRecord rec) throws NamingException { if (rec == null) { throw new NamingException("dumpLdif: No record supplied"); } String dn = rec.getDn(); if (dn == null) { throw new NamingException("Unable to get dn"); } lo.out("dn: " + dn); int ctype = rec.getChangeType(); if (!rec.getIsContent()) { // Emit a changetype attribute lo.out("changeType: " + LdifRecord.changeTypes[ctype]); } if ((rec.getIsContent()) || (ctype == DirRecord.changeTypeAdd)) { Attributes as = rec.getAttributes(); if (as == null) throw new NamingException("No attributes"); Enumeration e = as.getAll(); while (e.hasMoreElements()) { dumpAttr(lo, (Attribute)e.nextElement()); } // while } else if (ctype == DirRecord.changeTypeDelete) { lo.out("changetype: delete"); } else { lo.out("changetype: modify"); // Dump changes ModificationItem[] mods = rec.getMods(); if (mods == null) { lo.out("# Invalid record - no mods"); } else { for (int i = 0; i < mods.length; i ++) { ModificationItem m = mods[i]; int op = m.getModificationOp(); Attribute a = m.getAttribute(); String aid = a.getID(); if (op == DirContext.ADD_ATTRIBUTE) { lo.out("add: " + aid); } else if (op == DirContext.REPLACE_ATTRIBUTE) { lo.out("replace: " + aid); } else if (op == DirContext.REMOVE_ATTRIBUTE) { lo.out("delete: " + aid); } else { lo.out("# Invalid record - bad mod op " + op); } dumpAttr(lo, a); } } lo.out("-"); } lo.out(""); // null terminator }
java
public static void dumpLdif(LdifOut lo, DirRecord rec) throws NamingException { if (rec == null) { throw new NamingException("dumpLdif: No record supplied"); } String dn = rec.getDn(); if (dn == null) { throw new NamingException("Unable to get dn"); } lo.out("dn: " + dn); int ctype = rec.getChangeType(); if (!rec.getIsContent()) { // Emit a changetype attribute lo.out("changeType: " + LdifRecord.changeTypes[ctype]); } if ((rec.getIsContent()) || (ctype == DirRecord.changeTypeAdd)) { Attributes as = rec.getAttributes(); if (as == null) throw new NamingException("No attributes"); Enumeration e = as.getAll(); while (e.hasMoreElements()) { dumpAttr(lo, (Attribute)e.nextElement()); } // while } else if (ctype == DirRecord.changeTypeDelete) { lo.out("changetype: delete"); } else { lo.out("changetype: modify"); // Dump changes ModificationItem[] mods = rec.getMods(); if (mods == null) { lo.out("# Invalid record - no mods"); } else { for (int i = 0; i < mods.length; i ++) { ModificationItem m = mods[i]; int op = m.getModificationOp(); Attribute a = m.getAttribute(); String aid = a.getID(); if (op == DirContext.ADD_ATTRIBUTE) { lo.out("add: " + aid); } else if (op == DirContext.REPLACE_ATTRIBUTE) { lo.out("replace: " + aid); } else if (op == DirContext.REMOVE_ATTRIBUTE) { lo.out("delete: " + aid); } else { lo.out("# Invalid record - bad mod op " + op); } dumpAttr(lo, a); } } lo.out("-"); } lo.out(""); // null terminator }
[ "public", "static", "void", "dumpLdif", "(", "LdifOut", "lo", ",", "DirRecord", "rec", ")", "throws", "NamingException", "{", "if", "(", "rec", "==", "null", ")", "{", "throw", "new", "NamingException", "(", "\"dumpLdif: No record supplied\"", ")", ";", "}", ...
dumpLdif write the entire record as ldif.
[ "dumpLdif", "write", "the", "entire", "record", "as", "ldif", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/ldif/Ldif.java#L135-L197
train
Bedework/bw-util
bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/XSLTFilterConfigInfo.java
XSLTFilterConfigInfo.makeLocale
public static String makeLocale(String lang, String country) { if ((lang == null) || (lang.length() == 0)) { return localeInfoDefaultDefault; } if ((country == null) || (country.length() == 0)) { return localeInfoDefaultDefault; } return lang + "_" + country; }
java
public static String makeLocale(String lang, String country) { if ((lang == null) || (lang.length() == 0)) { return localeInfoDefaultDefault; } if ((country == null) || (country.length() == 0)) { return localeInfoDefaultDefault; } return lang + "_" + country; }
[ "public", "static", "String", "makeLocale", "(", "String", "lang", ",", "String", "country", ")", "{", "if", "(", "(", "lang", "==", "null", ")", "||", "(", "lang", ".", "length", "(", ")", "==", "0", ")", ")", "{", "return", "localeInfoDefaultDefault"...
If either the lang or country is null we provide a default value for the whole locale. Otherwise we construct one. @param lang @param country @return locale
[ "If", "either", "the", "lang", "or", "country", "is", "null", "we", "provide", "a", "default", "value", "for", "the", "whole", "locale", ".", "Otherwise", "we", "construct", "one", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-servlet-filters/src/main/java/org/bedework/util/servlet/filters/XSLTFilterConfigInfo.java#L355-L365
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/jaxrx/resource/AResource.java
AResource.createOutput
private StreamingOutput createOutput(final JaxRx impl, final ResourcePath path) { // check for command parameter String qu = path.getValue(QueryParameter.COMMAND); if (qu != null) { return impl.command(qu, path); } // check for run parameter qu = path.getValue(QueryParameter.RUN); if (qu != null) { return impl.run(qu, path); } // check for query parameter qu = path.getValue(QueryParameter.QUERY); if (qu != null) { return impl.query(qu, path); } // no parameter found return impl.get(path); }
java
private StreamingOutput createOutput(final JaxRx impl, final ResourcePath path) { // check for command parameter String qu = path.getValue(QueryParameter.COMMAND); if (qu != null) { return impl.command(qu, path); } // check for run parameter qu = path.getValue(QueryParameter.RUN); if (qu != null) { return impl.run(qu, path); } // check for query parameter qu = path.getValue(QueryParameter.QUERY); if (qu != null) { return impl.query(qu, path); } // no parameter found return impl.get(path); }
[ "private", "StreamingOutput", "createOutput", "(", "final", "JaxRx", "impl", ",", "final", "ResourcePath", "path", ")", "{", "// check for command parameter\r", "String", "qu", "=", "path", ".", "getValue", "(", "QueryParameter", ".", "COMMAND", ")", ";", "if", ...
Returns a stream output, depending on the query parameters. @param impl implementation @param path path info @return parameter map
[ "Returns", "a", "stream", "output", "depending", "on", "the", "query", "parameters", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/jaxrx/resource/AResource.java#L81-L103
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/jaxrx/resource/AResource.java
AResource.createResponse
Response createResponse(final JaxRx impl, final ResourcePath path) { final StreamingOutput out = createOutput(impl, path); // change media type, dependent on WRAP value final boolean wrap = path.getValue(QueryParameter.WRAP) == null || path.getValue(QueryParameter.WRAP).equals("yes"); String type = wrap ? MediaType.APPLICATION_XML : MediaType.TEXT_PLAIN; // overwrite type if METHOD or MEDIA-TYPE parameters are specified final String op = path.getValue(QueryParameter.OUTPUT); if (op != null) { final Scanner sc = new Scanner(op); sc.useDelimiter(","); while (sc.hasNext()) { final String[] sp = sc.next().split("=", 2); if (sp.length == 1) continue; if (sp[0].equals(METHOD)) { for (final String[] m : METHODS) if (sp[1].equals(m[0])) type = m[1]; } else if (sp[0].equals(MEDIATYPE)) { type = sp[1]; } } } // check validity of media type MediaType mt = null; try { mt = MediaType.valueOf(type); } catch (final IllegalArgumentException ex) { throw new JaxRxException(400, ex.getMessage()); } return Response.ok(out, mt).build(); }
java
Response createResponse(final JaxRx impl, final ResourcePath path) { final StreamingOutput out = createOutput(impl, path); // change media type, dependent on WRAP value final boolean wrap = path.getValue(QueryParameter.WRAP) == null || path.getValue(QueryParameter.WRAP).equals("yes"); String type = wrap ? MediaType.APPLICATION_XML : MediaType.TEXT_PLAIN; // overwrite type if METHOD or MEDIA-TYPE parameters are specified final String op = path.getValue(QueryParameter.OUTPUT); if (op != null) { final Scanner sc = new Scanner(op); sc.useDelimiter(","); while (sc.hasNext()) { final String[] sp = sc.next().split("=", 2); if (sp.length == 1) continue; if (sp[0].equals(METHOD)) { for (final String[] m : METHODS) if (sp[1].equals(m[0])) type = m[1]; } else if (sp[0].equals(MEDIATYPE)) { type = sp[1]; } } } // check validity of media type MediaType mt = null; try { mt = MediaType.valueOf(type); } catch (final IllegalArgumentException ex) { throw new JaxRxException(400, ex.getMessage()); } return Response.ok(out, mt).build(); }
[ "Response", "createResponse", "(", "final", "JaxRx", "impl", ",", "final", "ResourcePath", "path", ")", "{", "final", "StreamingOutput", "out", "=", "createOutput", "(", "impl", ",", "path", ")", ";", "// change media type, dependent on WRAP value\r", "final", "bool...
Returns a result, depending on the query parameters. @param impl implementation @param path path info @return parameter map
[ "Returns", "a", "result", "depending", "on", "the", "query", "parameters", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/jaxrx/resource/AResource.java#L115-L151
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/jaxrx/resource/AResource.java
AResource.getParameters
protected Map<QueryParameter, String> getParameters(final UriInfo uri, final JaxRx jaxrx) { final MultivaluedMap<String, String> params = uri.getQueryParameters(); final Map<QueryParameter, String> newParam = createMap(); final Set<QueryParameter> impl = jaxrx.getParameters(); for (final String key : params.keySet()) { for (final String s : params.get(key)) { addParameter(key, s, newParam, impl); } } return newParam; }
java
protected Map<QueryParameter, String> getParameters(final UriInfo uri, final JaxRx jaxrx) { final MultivaluedMap<String, String> params = uri.getQueryParameters(); final Map<QueryParameter, String> newParam = createMap(); final Set<QueryParameter> impl = jaxrx.getParameters(); for (final String key : params.keySet()) { for (final String s : params.get(key)) { addParameter(key, s, newParam, impl); } } return newParam; }
[ "protected", "Map", "<", "QueryParameter", ",", "String", ">", "getParameters", "(", "final", "UriInfo", "uri", ",", "final", "JaxRx", "jaxrx", ")", "{", "final", "MultivaluedMap", "<", "String", ",", "String", ">", "params", "=", "uri", ".", "getQueryParame...
Extracts and returns query parameters from the specified map. If a parameter is specified multiple times, its values will be separated with tab characters. @param uri uri info with query parameters @param jaxrx JAX-RX implementation @return The parameters as {@link Map}.
[ "Extracts", "and", "returns", "query", "parameters", "from", "the", "specified", "map", ".", "If", "a", "parameter", "is", "specified", "multiple", "times", "its", "values", "will", "be", "separated", "with", "tab", "characters", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/jaxrx/resource/AResource.java#L164-L176
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/jaxrx/resource/AResource.java
AResource.createMap
private Map<QueryParameter, String> createMap() { final Map<QueryParameter, String> params = new HashMap<QueryParameter, String>(); final Properties props = System.getProperties(); for (final Map.Entry<Object, Object> set : props.entrySet()) { final String key = set.getKey().toString(); final String up = key.replace("org.jaxrx.parameter.", ""); if (key.equals(up)) continue; try { params.put(QueryParameter.valueOf(up.toUpperCase()), set.getValue().toString()); } catch (final IllegalArgumentException ex) { /* ignore */ } } return params; }
java
private Map<QueryParameter, String> createMap() { final Map<QueryParameter, String> params = new HashMap<QueryParameter, String>(); final Properties props = System.getProperties(); for (final Map.Entry<Object, Object> set : props.entrySet()) { final String key = set.getKey().toString(); final String up = key.replace("org.jaxrx.parameter.", ""); if (key.equals(up)) continue; try { params.put(QueryParameter.valueOf(up.toUpperCase()), set.getValue().toString()); } catch (final IllegalArgumentException ex) { /* ignore */ } } return params; }
[ "private", "Map", "<", "QueryParameter", ",", "String", ">", "createMap", "(", ")", "{", "final", "Map", "<", "QueryParameter", ",", "String", ">", "params", "=", "new", "HashMap", "<", "QueryParameter", ",", "String", ">", "(", ")", ";", "final", "Prope...
Returns a fresh parameter map. This map contains all parameters as defaults which have been specified by the user via system properties with the pattern "org.jaxrx.parameter.KEY" as key. @return parameter map
[ "Returns", "a", "fresh", "parameter", "map", ".", "This", "map", "contains", "all", "parameters", "as", "defaults", "which", "have", "been", "specified", "by", "the", "user", "via", "system", "properties", "with", "the", "pattern", "org", ".", "jaxrx", ".", ...
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/jaxrx/resource/AResource.java#L274-L290
train
sebastiangraf/treetank
interfacemodules/iscsi/src/main/java/org/treetank/iscsi/jscsi/TreetankStorageModule.java
TreetankStorageModule.prefetch
private void prefetch(long storageIndex) { long startIndex = storageIndex / BYTES_IN_DATA; // Inc to next bucket startIndex += 128; if (mPrefetchedBuckets.contains(startIndex)) { mPrefetchedBuckets.remove(startIndex); return; } for (int i = 0; i < BUCKETS_TO_PREFETCH; i++) { if ((startIndex + i) > (mNodeNumbers / 128)) { return; } mRtx.moveTo(startIndex); startIndex += 128; } }
java
private void prefetch(long storageIndex) { long startIndex = storageIndex / BYTES_IN_DATA; // Inc to next bucket startIndex += 128; if (mPrefetchedBuckets.contains(startIndex)) { mPrefetchedBuckets.remove(startIndex); return; } for (int i = 0; i < BUCKETS_TO_PREFETCH; i++) { if ((startIndex + i) > (mNodeNumbers / 128)) { return; } mRtx.moveTo(startIndex); startIndex += 128; } }
[ "private", "void", "prefetch", "(", "long", "storageIndex", ")", "{", "long", "startIndex", "=", "storageIndex", "/", "BYTES_IN_DATA", ";", "// Inc to next bucket\r", "startIndex", "+=", "128", ";", "if", "(", "mPrefetchedBuckets", ".", "contains", "(", "startInde...
Prefetch buckets if necessary
[ "Prefetch", "buckets", "if", "necessary" ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/iscsi/src/main/java/org/treetank/iscsi/jscsi/TreetankStorageModule.java#L310-L328
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/jaxrx/core/SchemaChecker.java
SchemaChecker.check
public Document check(final InputStream input) { Document document; try { final DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); document = docBuilder.parse(input); final InputStream is = getClass().getResourceAsStream(xslSchema); final Source source = new SAXSource(new InputSource(is)); checkIsValid(document, source); } catch (final SAXException exce) { throw new JaxRxException(400, exce.getMessage()); } catch (final ParserConfigurationException exce) { throw new JaxRxException(exce); } catch (final IOException exce) { throw new JaxRxException(exce); } return document; }
java
public Document check(final InputStream input) { Document document; try { final DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); document = docBuilder.parse(input); final InputStream is = getClass().getResourceAsStream(xslSchema); final Source source = new SAXSource(new InputSource(is)); checkIsValid(document, source); } catch (final SAXException exce) { throw new JaxRxException(400, exce.getMessage()); } catch (final ParserConfigurationException exce) { throw new JaxRxException(exce); } catch (final IOException exce) { throw new JaxRxException(exce); } return document; }
[ "public", "Document", "check", "(", "final", "InputStream", "input", ")", "{", "Document", "document", ";", "try", "{", "final", "DocumentBuilder", "docBuilder", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ".", "newDocumentBuilder", "(", ")", ";...
This method parses an XML input with a W3C DOM implementation and validates it then with the available XML schema. @param input The input stream containing the XML query. @return The parsed XML source as {@link Document}.
[ "This", "method", "parses", "an", "XML", "input", "with", "a", "W3C", "DOM", "implementation", "and", "validates", "it", "then", "with", "the", "available", "XML", "schema", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/jaxrx/core/SchemaChecker.java#L77-L94
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/jaxrx/core/SchemaChecker.java
SchemaChecker.checkIsValid
private void checkIsValid(final Document document, final Source source) throws SAXException, IOException { final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); final Schema schema = schemaFactory.newSchema(source); final Validator validator = schema.newValidator(); validator.validate(new DOMSource(document)); }
java
private void checkIsValid(final Document document, final Source source) throws SAXException, IOException { final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); final Schema schema = schemaFactory.newSchema(source); final Validator validator = schema.newValidator(); validator.validate(new DOMSource(document)); }
[ "private", "void", "checkIsValid", "(", "final", "Document", "document", ",", "final", "Source", "source", ")", "throws", "SAXException", ",", "IOException", "{", "final", "SchemaFactory", "schemaFactory", "=", "SchemaFactory", ".", "newInstance", "(", "XMLConstants...
This method checks the parsed document if it is valid to a given XML schema. If not, an exception is thrown @param document The parsed document. @param source The {@link String} representation of the XML schema file. @throws SAXException if the document is invalid @throws IOException if the input cannot be read
[ "This", "method", "checks", "the", "parsed", "document", "if", "it", "is", "valid", "to", "a", "given", "XML", "schema", ".", "If", "not", "an", "exception", "is", "thrown" ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/jaxrx/core/SchemaChecker.java#L109-L115
train
Bedework/bw-util
bw-util-misc/src/main/java/org/bedework/util/misc/Uid.java
Uid.getUid
public static String getUid() { /* Unique down to millisecond */ short hiTime = (short)(System.currentTimeMillis() >>> 32); int loTime = (int)System.currentTimeMillis(); int ct; synchronized(Uid.class) { if (counter < 0) { counter = 0; } ct = counter++; } return new StringBuilder(36). append(format(IP)).append(sep). append(format(JVM)).append(sep). append(format(hiTime)).append(sep). append(format(loTime)).append(sep). append(format(ct)). toString(); }
java
public static String getUid() { /* Unique down to millisecond */ short hiTime = (short)(System.currentTimeMillis() >>> 32); int loTime = (int)System.currentTimeMillis(); int ct; synchronized(Uid.class) { if (counter < 0) { counter = 0; } ct = counter++; } return new StringBuilder(36). append(format(IP)).append(sep). append(format(JVM)).append(sep). append(format(hiTime)).append(sep). append(format(loTime)).append(sep). append(format(ct)). toString(); }
[ "public", "static", "String", "getUid", "(", ")", "{", "/* Unique down to millisecond */", "short", "hiTime", "=", "(", "short", ")", "(", "System", ".", "currentTimeMillis", "(", ")", ">>>", "32", ")", ";", "int", "loTime", "=", "(", "int", ")", "System",...
Code copied and modified from hibernate UUIDHexGenerator. Generates a unique 36 character key of hex + separators. @return String uid.
[ "Code", "copied", "and", "modified", "from", "hibernate", "UUIDHexGenerator", ".", "Generates", "a", "unique", "36", "character", "key", "of", "hex", "+", "separators", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-misc/src/main/java/org/bedework/util/misc/Uid.java#L57-L80
train
Bedework/bw-util
bw-util-misc/src/main/java/org/bedework/util/misc/Uid.java
Uid.toInt
public static int toInt(byte[] bytes ) { int result = 0; for (int i = 0; i < 4; i++) { result = (result << 8) - Byte.MIN_VALUE + (int)bytes[i]; } return result; }
java
public static int toInt(byte[] bytes ) { int result = 0; for (int i = 0; i < 4; i++) { result = (result << 8) - Byte.MIN_VALUE + (int)bytes[i]; } return result; }
[ "public", "static", "int", "toInt", "(", "byte", "[", "]", "bytes", ")", "{", "int", "result", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "result", "=", "(", "result", "<<", "8", ")", "-",...
From hibernate.util @param bytes @return int
[ "From", "hibernate", ".", "util" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-misc/src/main/java/org/bedework/util/misc/Uid.java#L103-L110
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/common/Directory.java
Directory.search
public boolean search(String base, String filter) throws NamingException { return search(base, filter, scopeSub); }
java
public boolean search(String base, String filter) throws NamingException { return search(base, filter, scopeSub); }
[ "public", "boolean", "search", "(", "String", "base", ",", "String", "filter", ")", "throws", "NamingException", "{", "return", "search", "(", "base", ",", "filter", ",", "scopeSub", ")", ";", "}" ]
Carry out a subtree search @param base @param filter @return DirSearchResult @throws NamingException
[ "Carry", "out", "a", "subtree", "search" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/Directory.java#L84-L86
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/common/Directory.java
Directory.searchBase
public boolean searchBase(String base, String filter) throws NamingException { return search(base, filter, scopeBase); }
java
public boolean searchBase(String base, String filter) throws NamingException { return search(base, filter, scopeBase); }
[ "public", "boolean", "searchBase", "(", "String", "base", ",", "String", "filter", ")", "throws", "NamingException", "{", "return", "search", "(", "base", ",", "filter", ",", "scopeBase", ")", ";", "}" ]
Carry out a base level search. This should be the default if the scope is not specified. @param base @param filter @return DirSearchResult or null @throws NamingException
[ "Carry", "out", "a", "base", "level", "search", ".", "This", "should", "be", "the", "default", "if", "the", "scope", "is", "not", "specified", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/Directory.java#L96-L98
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/common/Directory.java
Directory.searchOne
public boolean searchOne(String base, String filter) throws NamingException { return search(base, filter, scopeOne); }
java
public boolean searchOne(String base, String filter) throws NamingException { return search(base, filter, scopeOne); }
[ "public", "boolean", "searchOne", "(", "String", "base", ",", "String", "filter", ")", "throws", "NamingException", "{", "return", "search", "(", "base", ",", "filter", ",", "scopeOne", ")", ";", "}" ]
Carry out a one level search @param base @param filter @return DirSearchResult @throws NamingException
[ "Carry", "out", "a", "one", "level", "search" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/Directory.java#L107-L109
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/common/Directory.java
Directory.newRecord
public DirRecord newRecord(String entryDn) throws NamingException { DirRecord rec = new BasicDirRecord(); rec.setDn(entryDn); return rec; }
java
public DirRecord newRecord(String entryDn) throws NamingException { DirRecord rec = new BasicDirRecord(); rec.setDn(entryDn); return rec; }
[ "public", "DirRecord", "newRecord", "(", "String", "entryDn", ")", "throws", "NamingException", "{", "DirRecord", "rec", "=", "new", "BasicDirRecord", "(", ")", ";", "rec", ".", "setDn", "(", "entryDn", ")", ";", "return", "rec", ";", "}" ]
newRecord - Return a record which can have attribute values added. create should be called to create the directory entry. @param entryDn @return DirRecord @throws NamingException
[ "newRecord", "-", "Return", "a", "record", "which", "can", "have", "attribute", "values", "added", ".", "create", "should", "be", "called", "to", "create", "the", "directory", "entry", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/Directory.java#L131-L135
train
sebastiangraf/treetank
coremodules/core/src/main/java/org/treetank/io/LRULog.java
LRULog.getIterator
public LogIterator getIterator() { Set<Entry<LogKey, LogValue>> entries = mCache.asMap().entrySet(); for (Entry<LogKey, LogValue> entry : entries) { insertIntoBDB(entry.getKey(), entry.getValue()); } return new LogIterator(); }
java
public LogIterator getIterator() { Set<Entry<LogKey, LogValue>> entries = mCache.asMap().entrySet(); for (Entry<LogKey, LogValue> entry : entries) { insertIntoBDB(entry.getKey(), entry.getValue()); } return new LogIterator(); }
[ "public", "LogIterator", "getIterator", "(", ")", "{", "Set", "<", "Entry", "<", "LogKey", ",", "LogValue", ">", ">", "entries", "=", "mCache", ".", "asMap", "(", ")", ".", "entrySet", "(", ")", ";", "for", "(", "Entry", "<", "LogKey", ",", "LogValue...
Returning all elements as Iterator. @return new LogIterator-instance
[ "Returning", "all", "elements", "as", "Iterator", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/core/src/main/java/org/treetank/io/LRULog.java#L254-L261
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/ldif/LdifRecord.java
LdifRecord.read
public boolean read(Input in) throws NamingException { clear(); this.in = in; // somedata = false; haveControls = false; crec = null; for (;;) { int alen = -1; try { crec = in.readFullLine(); } catch (Exception e) { throwmsg(e.getMessage()); } int inLen = 0; if (crec != null) { inLen = crec.length(); } /* System.out.println("ldifrec len=" + inLen + " data=" + crec + " state=" + state); */ if (crec != null) { ldifData.addElement(crec); alen = crec.indexOf(':'); } // Null terminator means we're done if (inLen == 0) { // There are some state we should not be in here if (state == stateModSpec) { // Any others? invalid(); } break; } if ((inLen > 0) && (crec.startsWith("#"))) { // Comment line. Ignore it. } else if (alen > 0) { /** We have something of the form <name> : <val> or <name> :: <encoded-val> or for base-64 encoded data <name> :< <url> for the url of an inclusion */ String attr = null; StringBuffer val = null; boolean encoded = false; boolean url = false; int valStart; valStart = alen + 1; if (valStart == inLen) { throw new NamingException("Bad input value \"" + crec + "\""); } else if ((alen < inLen) && (crec.charAt(valStart) == ':')) { valStart++; encoded = true; } else if ((alen < inLen) && (crec.charAt(valStart) == '<')) { valStart++; url = true; } while ((valStart < inLen) && (crec.charAt(valStart) == ' ')) { valStart++; } attr = crec.substring(0, alen).toLowerCase(); val = new StringBuffer(crec.substring(valStart)); addAttrVal(attr, val.toString(), encoded, url); } else if ((state == stateModSpec) && (inLen == 1) && (crec.equals("-"))) { // We have a current change to add to the change vector. if (changes == null) { changes = new Vector(); } changes.addElement(curChange); curChange = null; state = stateModify; } else if (inLen > 0) { invalid(); } } return somedata; }
java
public boolean read(Input in) throws NamingException { clear(); this.in = in; // somedata = false; haveControls = false; crec = null; for (;;) { int alen = -1; try { crec = in.readFullLine(); } catch (Exception e) { throwmsg(e.getMessage()); } int inLen = 0; if (crec != null) { inLen = crec.length(); } /* System.out.println("ldifrec len=" + inLen + " data=" + crec + " state=" + state); */ if (crec != null) { ldifData.addElement(crec); alen = crec.indexOf(':'); } // Null terminator means we're done if (inLen == 0) { // There are some state we should not be in here if (state == stateModSpec) { // Any others? invalid(); } break; } if ((inLen > 0) && (crec.startsWith("#"))) { // Comment line. Ignore it. } else if (alen > 0) { /** We have something of the form <name> : <val> or <name> :: <encoded-val> or for base-64 encoded data <name> :< <url> for the url of an inclusion */ String attr = null; StringBuffer val = null; boolean encoded = false; boolean url = false; int valStart; valStart = alen + 1; if (valStart == inLen) { throw new NamingException("Bad input value \"" + crec + "\""); } else if ((alen < inLen) && (crec.charAt(valStart) == ':')) { valStart++; encoded = true; } else if ((alen < inLen) && (crec.charAt(valStart) == '<')) { valStart++; url = true; } while ((valStart < inLen) && (crec.charAt(valStart) == ' ')) { valStart++; } attr = crec.substring(0, alen).toLowerCase(); val = new StringBuffer(crec.substring(valStart)); addAttrVal(attr, val.toString(), encoded, url); } else if ((state == stateModSpec) && (inLen == 1) && (crec.equals("-"))) { // We have a current change to add to the change vector. if (changes == null) { changes = new Vector(); } changes.addElement(curChange); curChange = null; state = stateModify; } else if (inLen > 0) { invalid(); } } return somedata; }
[ "public", "boolean", "read", "(", "Input", "in", ")", "throws", "NamingException", "{", "clear", "(", ")", ";", "this", ".", "in", "=", "in", ";", "// somedata = false;", "haveControls", "=", "false", ";", "crec", "=", "null", ";", "for", "(", ";", ...
Read an entire ldif record from an input stream @param in Input object to read from input stream @return boolean true if we read some ldif data. false if there was no data
[ "Read", "an", "entire", "ldif", "record", "from", "an", "input", "stream" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/ldif/LdifRecord.java#L228-L317
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/ldif/LdifRecord.java
LdifRecord.writeInputData
public boolean writeInputData(Writer wtr) throws Throwable { if ((ldifData == null) || (ldifData.size() == 0)) { return false; } synchronized (wtr) { for (int i = 0; i < ldifData.size(); i++) { String str = (String)ldifData.elementAt(i); wtr.write(str); wtr.write('\n'); } // terminate with null wtr.write('\n'); wtr.flush(); } return true; }
java
public boolean writeInputData(Writer wtr) throws Throwable { if ((ldifData == null) || (ldifData.size() == 0)) { return false; } synchronized (wtr) { for (int i = 0; i < ldifData.size(); i++) { String str = (String)ldifData.elementAt(i); wtr.write(str); wtr.write('\n'); } // terminate with null wtr.write('\n'); wtr.flush(); } return true; }
[ "public", "boolean", "writeInputData", "(", "Writer", "wtr", ")", "throws", "Throwable", "{", "if", "(", "(", "ldifData", "==", "null", ")", "||", "(", "ldifData", ".", "size", "(", ")", "==", "0", ")", ")", "{", "return", "false", ";", "}", "synchro...
Write the data we built this from @param wtr Writer to write to @return boolean false for no data
[ "Write", "the", "data", "we", "built", "this", "from" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/ldif/LdifRecord.java#L358-L377
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/ldif/LdifRecord.java
LdifRecord.write
public void write(Writer wtr) throws Throwable { // First we need the dn wtr.write(getDn()); wtr.write('\n'); throw new Exception("Incomplete"); }
java
public void write(Writer wtr) throws Throwable { // First we need the dn wtr.write(getDn()); wtr.write('\n'); throw new Exception("Incomplete"); }
[ "public", "void", "write", "(", "Writer", "wtr", ")", "throws", "Throwable", "{", "// First we need the dn", "wtr", ".", "write", "(", "getDn", "(", ")", ")", ";", "wtr", ".", "write", "(", "'", "'", ")", ";", "throw", "new", "Exception", "(", "\"Incom...
Write an ldif record representing this object @param wtr Writer to write to
[ "Write", "an", "ldif", "record", "representing", "this", "object" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/ldif/LdifRecord.java#L383-L390
train
Bedework/bw-util
bw-util-directory/src/main/java/org/bedework/util/directory/ldif/LdifRecord.java
LdifRecord.addAttrVal
private void addAttrVal(String attr, String val, boolean encoded, boolean url) throws NamingException { // System.out.println("addAttr " + attr + " = " + val); if (state == stateNeedDn) { // Only version or dn here if (attr.equals("version")) { if (version != null) throwmsg("Repeated version record"); // Should probably parse this. if (!(val.equals("1"))) throwmsg("Invalid LDIF version " + val.toString()); version = val; } else if (attr.equals("dn")) { setDn(makeVal(val, encoded, url)); state = stateHadDn; } else { invalid(); } } else if (state == stateHadDn) { // We might see a control or changetype here if (attr.equals("control")) { /** control records occur as an optional part of change records. We should not have seen any changesrecords yet. Flag this as a change record. */ setIsContent(false); throwmsg("controls unimplemented"); } else if (attr.equals("changetype")) { setIsContent(false); doChangeType(val); } else { // We presume that we have an attribute value. If we had control records // then we expected a changetype. if (haveControls) throwmsg("Missing changetype"); state = stateNotModRec; // Recurse to process the attribute addAttrVal(attr, val, encoded, url); } } else if (state == stateDeleteRec) { throwmsg("Should have no values for delete"); } else if (state == stateNotModRec) { /** add or content. Just some attribute and its value. Add the attribute name and val to the table. */ addAttr(attr, makeVal(val, encoded, url)); } else if (state == stateModrdn) { /** We expect up to 3 attributes newrdn: <rdn-val> deleteoldrdn: 0|1 newsuperior: <dn-val> ; optional */ throwmsg("changetype: mod(r)dn unimplemented"); } else if (state == stateModify) { // We expect ("add"|"delete"|"replace"): <attr-desc> if (encoded || url) { throwmsg("Invalid LDIF mod-spec"); } curChange = new Change(); if (attr.equals("add")) { curChange.changeType = DirContext.ADD_ATTRIBUTE; } else if (attr.equals("replace")) { curChange.changeType = DirContext.REPLACE_ATTRIBUTE; } else if (attr.equals("delete")) { curChange.changeType = DirContext.REMOVE_ATTRIBUTE; } else { throwmsg("Invalid LDIF mod-spec changetype"); } curChange.name = val; // ???????? options state = stateModSpec; } else if (state == stateModSpec) { // Attribute + value to add to current change if ((curChange == null) || (curChange.name == null)) { throwmsg("LDIF software error: No current change"); } if (!curChange.name.equalsIgnoreCase(attr)) { throwmsg("Invalid LDIF mod-spec: attribute name mismatch"); } // Add the value to the change if (curChange.vals == null) { curChange.vals = new Vector(); } curChange.vals.addElement(makeVal(val, encoded, url)); } else { throwmsg("LDIF software error: invalid state " + state); } somedata = true; }
java
private void addAttrVal(String attr, String val, boolean encoded, boolean url) throws NamingException { // System.out.println("addAttr " + attr + " = " + val); if (state == stateNeedDn) { // Only version or dn here if (attr.equals("version")) { if (version != null) throwmsg("Repeated version record"); // Should probably parse this. if (!(val.equals("1"))) throwmsg("Invalid LDIF version " + val.toString()); version = val; } else if (attr.equals("dn")) { setDn(makeVal(val, encoded, url)); state = stateHadDn; } else { invalid(); } } else if (state == stateHadDn) { // We might see a control or changetype here if (attr.equals("control")) { /** control records occur as an optional part of change records. We should not have seen any changesrecords yet. Flag this as a change record. */ setIsContent(false); throwmsg("controls unimplemented"); } else if (attr.equals("changetype")) { setIsContent(false); doChangeType(val); } else { // We presume that we have an attribute value. If we had control records // then we expected a changetype. if (haveControls) throwmsg("Missing changetype"); state = stateNotModRec; // Recurse to process the attribute addAttrVal(attr, val, encoded, url); } } else if (state == stateDeleteRec) { throwmsg("Should have no values for delete"); } else if (state == stateNotModRec) { /** add or content. Just some attribute and its value. Add the attribute name and val to the table. */ addAttr(attr, makeVal(val, encoded, url)); } else if (state == stateModrdn) { /** We expect up to 3 attributes newrdn: <rdn-val> deleteoldrdn: 0|1 newsuperior: <dn-val> ; optional */ throwmsg("changetype: mod(r)dn unimplemented"); } else if (state == stateModify) { // We expect ("add"|"delete"|"replace"): <attr-desc> if (encoded || url) { throwmsg("Invalid LDIF mod-spec"); } curChange = new Change(); if (attr.equals("add")) { curChange.changeType = DirContext.ADD_ATTRIBUTE; } else if (attr.equals("replace")) { curChange.changeType = DirContext.REPLACE_ATTRIBUTE; } else if (attr.equals("delete")) { curChange.changeType = DirContext.REMOVE_ATTRIBUTE; } else { throwmsg("Invalid LDIF mod-spec changetype"); } curChange.name = val; // ???????? options state = stateModSpec; } else if (state == stateModSpec) { // Attribute + value to add to current change if ((curChange == null) || (curChange.name == null)) { throwmsg("LDIF software error: No current change"); } if (!curChange.name.equalsIgnoreCase(attr)) { throwmsg("Invalid LDIF mod-spec: attribute name mismatch"); } // Add the value to the change if (curChange.vals == null) { curChange.vals = new Vector(); } curChange.vals.addElement(makeVal(val, encoded, url)); } else { throwmsg("LDIF software error: invalid state " + state); } somedata = true; }
[ "private", "void", "addAttrVal", "(", "String", "attr", ",", "String", "val", ",", "boolean", "encoded", ",", "boolean", "url", ")", "throws", "NamingException", "{", "// System.out.println(\"addAttr \" + attr + \" = \" + val);", "if", "(", "state", "==", "stateNeedD...
For all record types we expect an optional version spec first. After that comes the dn. After that, for content records we expect attrval-spec. for change record we have optional controls followed by changes.
[ "For", "all", "record", "types", "we", "expect", "an", "optional", "version", "spec", "first", ".", "After", "that", "comes", "the", "dn", ".", "After", "that", "for", "content", "records", "we", "expect", "attrval", "-", "spec", ".", "for", "change", "r...
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/ldif/LdifRecord.java#L410-L505
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/ExpressionSingle.java
ExpressionSingle.add
public void add(final AbsAxis mAx) { AbsAxis axis = mAx; if (isDupOrd(axis)) { axis = new DupFilterAxis(mRtx, axis); DupState.nodup = true; } switch (mNumber) { case 0: mFirstAxis = axis; mNumber++; break; case 1: mExpr = new NestedAxis(mFirstAxis, axis, mRtx); mNumber++; break; default: final AbsAxis cache = mExpr; mExpr = new NestedAxis(cache, axis, mRtx); } }
java
public void add(final AbsAxis mAx) { AbsAxis axis = mAx; if (isDupOrd(axis)) { axis = new DupFilterAxis(mRtx, axis); DupState.nodup = true; } switch (mNumber) { case 0: mFirstAxis = axis; mNumber++; break; case 1: mExpr = new NestedAxis(mFirstAxis, axis, mRtx); mNumber++; break; default: final AbsAxis cache = mExpr; mExpr = new NestedAxis(cache, axis, mRtx); } }
[ "public", "void", "add", "(", "final", "AbsAxis", "mAx", ")", "{", "AbsAxis", "axis", "=", "mAx", ";", "if", "(", "isDupOrd", "(", "axis", ")", ")", "{", "axis", "=", "new", "DupFilterAxis", "(", "mRtx", ",", "axis", ")", ";", "DupState", ".", "nod...
Adds a new Axis to the expression chain. The first axis that is added has to be stored till a second axis is added. When the second axis is added, it is nested with the first one and builds the execution chain. @param mAx ach The axis to add.
[ "Adds", "a", "new", "Axis", "to", "the", "expression", "chain", ".", "The", "first", "axis", "that", "is", "added", "has", "to", "be", "stored", "till", "a", "second", "axis", "is", "added", ".", "When", "the", "second", "axis", "is", "added", "it", ...
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/xpath/ExpressionSingle.java#L96-L118
train
danielnorberg/rut
rut/src/main/java/io/norberg/rut/Encoding.java
Encoding.decodePercent
private static int decodePercent(final CharSequence s, final int length, final int i) { if (i + 2 >= length) { return INVALID; } final char n1 = s.charAt(i + 1); final char n2 = s.charAt(i + 2); return decodeNibbles(n1, n2); }
java
private static int decodePercent(final CharSequence s, final int length, final int i) { if (i + 2 >= length) { return INVALID; } final char n1 = s.charAt(i + 1); final char n2 = s.charAt(i + 2); return decodeNibbles(n1, n2); }
[ "private", "static", "int", "decodePercent", "(", "final", "CharSequence", "s", ",", "final", "int", "length", ",", "final", "int", "i", ")", "{", "if", "(", "i", "+", "2", ">=", "length", ")", "{", "return", "INVALID", ";", "}", "final", "char", "n1...
Decode a percent encoded byte. E.g. "%3F" -> 63.
[ "Decode", "a", "percent", "encoded", "byte", ".", "E", ".", "g", ".", "%3F", "-", ">", "63", "." ]
6cd99e0d464da934d446b554ab5bbecaf294fcdc
https://github.com/danielnorberg/rut/blob/6cd99e0d464da934d446b554ab5bbecaf294fcdc/rut/src/main/java/io/norberg/rut/Encoding.java#L121-L128
train
danielnorberg/rut
rut/src/main/java/io/norberg/rut/Encoding.java
Encoding.decodeNibbles
private static int decodeNibbles(final char c1, final char c2) { final int n1 = decodeHex(c1); if (n1 == INVALID) { return INVALID; } final int n2 = decodeHex(c2); if (n2 == INVALID) { return INVALID; } return (((n1 & 0xf) << 4) | (n2 & 0xf)); }
java
private static int decodeNibbles(final char c1, final char c2) { final int n1 = decodeHex(c1); if (n1 == INVALID) { return INVALID; } final int n2 = decodeHex(c2); if (n2 == INVALID) { return INVALID; } return (((n1 & 0xf) << 4) | (n2 & 0xf)); }
[ "private", "static", "int", "decodeNibbles", "(", "final", "char", "c1", ",", "final", "char", "c2", ")", "{", "final", "int", "n1", "=", "decodeHex", "(", "c1", ")", ";", "if", "(", "n1", "==", "INVALID", ")", "{", "return", "INVALID", ";", "}", "...
Decode two hex nibbles to a byte. E.g. '3' and 'F' -> 63.
[ "Decode", "two", "hex", "nibbles", "to", "a", "byte", ".", "E", ".", "g", ".", "3", "and", "F", "-", ">", "63", "." ]
6cd99e0d464da934d446b554ab5bbecaf294fcdc
https://github.com/danielnorberg/rut/blob/6cd99e0d464da934d446b554ab5bbecaf294fcdc/rut/src/main/java/io/norberg/rut/Encoding.java#L133-L143
train
danielnorberg/rut
rut/src/main/java/io/norberg/rut/Encoding.java
Encoding.decodeHex
private static int decodeHex(final char c) { if (c < '0') { return INVALID; } if (c <= '9') { return c - '0'; } if (c < 'A') { return INVALID; } if (c <= 'F') { return c - 'A' + 10; } if (c < 'a') { return INVALID; } if (c <= 'f') { return c - 'a' + 10; } return INVALID; }
java
private static int decodeHex(final char c) { if (c < '0') { return INVALID; } if (c <= '9') { return c - '0'; } if (c < 'A') { return INVALID; } if (c <= 'F') { return c - 'A' + 10; } if (c < 'a') { return INVALID; } if (c <= 'f') { return c - 'a' + 10; } return INVALID; }
[ "private", "static", "int", "decodeHex", "(", "final", "char", "c", ")", "{", "if", "(", "c", "<", "'", "'", ")", "{", "return", "INVALID", ";", "}", "if", "(", "c", "<=", "'", "'", ")", "{", "return", "c", "-", "'", "'", ";", "}", "if", "(...
Decode a hex nibble. E.g. '3' -> 3 and 'F' -> 15.
[ "Decode", "a", "hex", "nibble", ".", "E", ".", "g", ".", "3", "-", ">", "3", "and", "F", "-", ">", "15", "." ]
6cd99e0d464da934d446b554ab5bbecaf294fcdc
https://github.com/danielnorberg/rut/blob/6cd99e0d464da934d446b554ab5bbecaf294fcdc/rut/src/main/java/io/norberg/rut/Encoding.java#L148-L168
train
danielnorberg/rut
rut/src/main/java/io/norberg/rut/Encoding.java
Encoding.utf8Read3
private static int utf8Read3(int cu1, int cu2, int cu3) { if ((cu2 & 0xC0) != 0x80) { return INVALID; } if (cu1 == 0xE0 && cu2 < 0xA0) { // overlong return INVALID; } if ((cu3 & 0xC0) != 0x80) { return INVALID; } return (cu1 << 12) + (cu2 << 6) + cu3 - 0xE2080; }
java
private static int utf8Read3(int cu1, int cu2, int cu3) { if ((cu2 & 0xC0) != 0x80) { return INVALID; } if (cu1 == 0xE0 && cu2 < 0xA0) { // overlong return INVALID; } if ((cu3 & 0xC0) != 0x80) { return INVALID; } return (cu1 << 12) + (cu2 << 6) + cu3 - 0xE2080; }
[ "private", "static", "int", "utf8Read3", "(", "int", "cu1", ",", "int", "cu2", ",", "int", "cu3", ")", "{", "if", "(", "(", "cu2", "&", "0xC0", ")", "!=", "0x80", ")", "{", "return", "INVALID", ";", "}", "if", "(", "cu1", "==", "0xE0", "&&", "c...
Read a 3 byte UTF8 sequence. @return the resulting code point or {@link #INVALID} if invalid.
[ "Read", "a", "3", "byte", "UTF8", "sequence", "." ]
6cd99e0d464da934d446b554ab5bbecaf294fcdc
https://github.com/danielnorberg/rut/blob/6cd99e0d464da934d446b554ab5bbecaf294fcdc/rut/src/main/java/io/norberg/rut/Encoding.java#L224-L236
train
danielnorberg/rut
rut/src/main/java/io/norberg/rut/Encoding.java
Encoding.utf8Read4
private static int utf8Read4(int cu1, int cu2, int cu3, int cu4) { if ((cu2 & 0xC0) != 0x80) { return INVALID; } if (cu1 == 0xF0 && cu2 < 0x90) { return INVALID; // overlong } if (cu1 == 0xF4 && cu2 >= 0x90) { return INVALID; // > U+10FFFF } if ((cu3 & 0xC0) != 0x80) { return INVALID; } if ((cu4 & 0xC0) != 0x80) { return INVALID; } return (cu1 << 18) + (cu2 << 12) + (cu3 << 6) + cu4 - 0x3C82080; }
java
private static int utf8Read4(int cu1, int cu2, int cu3, int cu4) { if ((cu2 & 0xC0) != 0x80) { return INVALID; } if (cu1 == 0xF0 && cu2 < 0x90) { return INVALID; // overlong } if (cu1 == 0xF4 && cu2 >= 0x90) { return INVALID; // > U+10FFFF } if ((cu3 & 0xC0) != 0x80) { return INVALID; } if ((cu4 & 0xC0) != 0x80) { return INVALID; } return (cu1 << 18) + (cu2 << 12) + (cu3 << 6) + cu4 - 0x3C82080; }
[ "private", "static", "int", "utf8Read4", "(", "int", "cu1", ",", "int", "cu2", ",", "int", "cu3", ",", "int", "cu4", ")", "{", "if", "(", "(", "cu2", "&", "0xC0", ")", "!=", "0x80", ")", "{", "return", "INVALID", ";", "}", "if", "(", "cu1", "==...
Read a 4 byte UTF8 sequence. @return the resulting code point or {@link #INVALID} if invalid.
[ "Read", "a", "4", "byte", "UTF8", "sequence", "." ]
6cd99e0d464da934d446b554ab5bbecaf294fcdc
https://github.com/danielnorberg/rut/blob/6cd99e0d464da934d446b554ab5bbecaf294fcdc/rut/src/main/java/io/norberg/rut/Encoding.java#L243-L260
train
Bedework/bw-util
bw-util-jms/src/main/java/org/bedework/util/jms/listeners/JmsSysEventListener.java
JmsSysEventListener.close
public void close() { if (consumer != null) { try { consumer.close(); } catch (Throwable t) { warn(t.getMessage()); } } conn.close(); }
java
public void close() { if (consumer != null) { try { consumer.close(); } catch (Throwable t) { warn(t.getMessage()); } } conn.close(); }
[ "public", "void", "close", "(", ")", "{", "if", "(", "consumer", "!=", "null", ")", "{", "try", "{", "consumer", ".", "close", "(", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "warn", "(", "t", ".", "getMessage", "(", ")", ")", ";"...
Close and release resources.
[ "Close", "and", "release", "resources", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-jms/src/main/java/org/bedework/util/jms/listeners/JmsSysEventListener.java#L66-L76
train
Bedework/bw-util
bw-util-jms/src/main/java/org/bedework/util/jms/listeners/JmsSysEventListener.java
JmsSysEventListener.process
public void process(final boolean asynch) throws NotificationException { if (asynch) { try { consumer.setMessageListener(this); return; } catch (final JMSException je) { throw new NotificationException(je); } } while (running) { final Message m = conn.receive(); if (m == null) { running = false; return; } onMessage(m); } }
java
public void process(final boolean asynch) throws NotificationException { if (asynch) { try { consumer.setMessageListener(this); return; } catch (final JMSException je) { throw new NotificationException(je); } } while (running) { final Message m = conn.receive(); if (m == null) { running = false; return; } onMessage(m); } }
[ "public", "void", "process", "(", "final", "boolean", "asynch", ")", "throws", "NotificationException", "{", "if", "(", "asynch", ")", "{", "try", "{", "consumer", ".", "setMessageListener", "(", "this", ")", ";", "return", ";", "}", "catch", "(", "final",...
For asynch we do the onMessage listener style. Otherwise we wait synchronously for incoming messages. @param asynch true if we just want to set the listener @throws NotificationException
[ "For", "asynch", "we", "do", "the", "onMessage", "listener", "style", ".", "Otherwise", "we", "wait", "synchronously", "for", "incoming", "messages", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-jms/src/main/java/org/bedework/util/jms/listeners/JmsSysEventListener.java#L85-L105
train
centic9/commons-dost
src/main/java/org/dstadler/commons/http/Utils.java
Utils.getURL
public static boolean getURL(final String sUrl, final AtomicInteger gCount, long start) { int count = gCount.incrementAndGet(); if(count % 100 == 0) { long diff = (System.currentTimeMillis() - start)/1000; logger.info("Count: " + count + " IPS: " + count/diff); } final URL url; try { url = new URL(sUrl); } catch (MalformedURLException e) { logger.info("URL-Failed(" + count + "): " + e.toString()); return false; } logger.log(Level.FINE, "Testing(" + count + "): " + url); final URLConnection con; try { con = url.openConnection(); con.setConnectTimeout(10000); con.setReadTimeout(10000); if(-1 == con.getInputStream().read()) { return false; } } catch (IOException e) { // don't print out time out as it is expected here if(Utils.isIgnorableException(e)) { return false; } logger.log(Level.WARNING, "Failed (" + url + ")(" + count + ")", e); return false; } //logger.info(con); // logger.info("Date : " + new Date(con.getDate())); logger.info("Last Modified (" + url + ")(" + count + "): " + new Date(con.getLastModified())); // logger.info( "Content encoding: " + con.getContentEncoding() // ); // logger.info( "Content type : " + con.getContentType() ); // logger.info( "Content length : " + con.getContentLength() ); return true; }
java
public static boolean getURL(final String sUrl, final AtomicInteger gCount, long start) { int count = gCount.incrementAndGet(); if(count % 100 == 0) { long diff = (System.currentTimeMillis() - start)/1000; logger.info("Count: " + count + " IPS: " + count/diff); } final URL url; try { url = new URL(sUrl); } catch (MalformedURLException e) { logger.info("URL-Failed(" + count + "): " + e.toString()); return false; } logger.log(Level.FINE, "Testing(" + count + "): " + url); final URLConnection con; try { con = url.openConnection(); con.setConnectTimeout(10000); con.setReadTimeout(10000); if(-1 == con.getInputStream().read()) { return false; } } catch (IOException e) { // don't print out time out as it is expected here if(Utils.isIgnorableException(e)) { return false; } logger.log(Level.WARNING, "Failed (" + url + ")(" + count + ")", e); return false; } //logger.info(con); // logger.info("Date : " + new Date(con.getDate())); logger.info("Last Modified (" + url + ")(" + count + "): " + new Date(con.getLastModified())); // logger.info( "Content encoding: " + con.getContentEncoding() // ); // logger.info( "Content type : " + con.getContentType() ); // logger.info( "Content length : " + con.getContentLength() ); return true; }
[ "public", "static", "boolean", "getURL", "(", "final", "String", "sUrl", ",", "final", "AtomicInteger", "gCount", ",", "long", "start", ")", "{", "int", "count", "=", "gCount", ".", "incrementAndGet", "(", ")", ";", "if", "(", "count", "%", "100", "==", ...
Test URL and report if it can be read. @param sUrl The URL to test @param gCount A counter which is incremented for each call and is used for reporting rate of calls @param start Start-timestamp for reporting rate of calls. @return true if the URL is valid and can be read, false if an error occurs when reading from it.
[ "Test", "URL", "and", "report", "if", "it", "can", "be", "read", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/http/Utils.java#L159-L202
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/FMESVisitor.java
FMESVisitor.fillDataStructures
private void fillDataStructures() { final ITreeData treeData = mRtx.getNode(); mInOrder.put(treeData, true); mDescendants.put(treeData, 1L); }
java
private void fillDataStructures() { final ITreeData treeData = mRtx.getNode(); mInOrder.put(treeData, true); mDescendants.put(treeData, 1L); }
[ "private", "void", "fillDataStructures", "(", ")", "{", "final", "ITreeData", "treeData", "=", "mRtx", ".", "getNode", "(", ")", ";", "mInOrder", ".", "put", "(", "treeData", ",", "true", ")", ";", "mDescendants", ".", "put", "(", "treeData", ",", "1L", ...
Fill data structures.
[ "Fill", "data", "structures", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/algorithm/fmes/FMESVisitor.java#L106-L110
train
centic9/commons-dost
src/main/java/org/dstadler/commons/net/SocketUtils.java
SocketUtils.getNextFreePort
@SuppressForbidden(reason = "We want to bind to any address here when checking for free ports") public static int getNextFreePort(int portRangeStart, int portRangeEnd) throws IOException { for (int port = portRangeStart; port <= portRangeEnd; port++) { try (ServerSocket sock = new ServerSocket()) { sock.setReuseAddress(true); sock.bind(new InetSocketAddress(port)); return port; } catch (IOException e) { // seems to be taken, try next one log.warning("Port " + port + " seems to be used already, trying next one..."); } } throw new IOException("No free port found in the range of [" + portRangeStart + " - " + portRangeEnd + "]"); }
java
@SuppressForbidden(reason = "We want to bind to any address here when checking for free ports") public static int getNextFreePort(int portRangeStart, int portRangeEnd) throws IOException { for (int port = portRangeStart; port <= portRangeEnd; port++) { try (ServerSocket sock = new ServerSocket()) { sock.setReuseAddress(true); sock.bind(new InetSocketAddress(port)); return port; } catch (IOException e) { // seems to be taken, try next one log.warning("Port " + port + " seems to be used already, trying next one..."); } } throw new IOException("No free port found in the range of [" + portRangeStart + " - " + portRangeEnd + "]"); }
[ "@", "SuppressForbidden", "(", "reason", "=", "\"We want to bind to any address here when checking for free ports\"", ")", "public", "static", "int", "getNextFreePort", "(", "int", "portRangeStart", ",", "int", "portRangeEnd", ")", "throws", "IOException", "{", "for", "("...
Method that is used to find the next available port. It used the two constants PORT_RANGE_START and PORT_RANGE_END defined above to limit the range of ports that are tried. @param portRangeStart The first port that is tried @param portRangeEnd The last port that is tried @return A port number that can be used. @throws IOException If no available port is found.
[ "Method", "that", "is", "used", "to", "find", "the", "next", "available", "port", ".", "It", "used", "the", "two", "constants", "PORT_RANGE_START", "and", "PORT_RANGE_END", "defined", "above", "to", "limit", "the", "range", "of", "ports", "that", "are", "tri...
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/net/SocketUtils.java#L34-L49
train
Bedework/bw-util
bw-util-timezones/src/main/java/org/bedework/util/timezones/TimezonesImpl.java
TimezonesImpl.fetchTimeZone
protected TimeZone fetchTimeZone(final String id) throws TimezonesException { final TaggedTimeZone ttz = fetchTimeZone(id, null); if (ttz == null) { return null; } register(id, ttz.tz); return ttz.tz; }
java
protected TimeZone fetchTimeZone(final String id) throws TimezonesException { final TaggedTimeZone ttz = fetchTimeZone(id, null); if (ttz == null) { return null; } register(id, ttz.tz); return ttz.tz; }
[ "protected", "TimeZone", "fetchTimeZone", "(", "final", "String", "id", ")", "throws", "TimezonesException", "{", "final", "TaggedTimeZone", "ttz", "=", "fetchTimeZone", "(", "id", ",", "null", ")", ";", "if", "(", "ttz", "==", "null", ")", "{", "return", ...
Fetch a timezone object from the server given the id. @param id the tzid @return TimeZone with id or null @throws TimezonesException on error
[ "Fetch", "a", "timezone", "object", "from", "the", "server", "given", "the", "id", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-timezones/src/main/java/org/bedework/util/timezones/TimezonesImpl.java#L400-L410
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java
AbsDiff.diffMovement
void diffMovement() throws TTException { assert mHashKind != null; assert mNewRtx != null; assert mOldRtx != null; assert mDiff != null; assert mDiffKind != null; // Check first nodes. if (mNewRtx.getNode().getKind() != ROOT) { if (mHashKind == HashKind.None || mDiffKind == EDiffOptimized.NO) { mDiff = diff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } else { mDiff = optimizedDiff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } } // Iterate over new revision. while ((mOldRtx.getNode().getKind() != ROOT && mDiff == EDiff.DELETED) || moveCursor(mNewRtx, ERevision.NEW)) { if (mDiff != EDiff.INSERTED) { moveCursor(mOldRtx, ERevision.OLD); } if (mNewRtx.getNode().getKind() != ROOT || mOldRtx.getNode().getKind() != ROOT) { if (mHashKind == HashKind.None || mDiffKind == EDiffOptimized.NO) { mDiff = diff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } else { mDiff = optimizedDiff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } } } // Nodes deleted in old rev at the end of the tree. if (mOldRtx.getNode().getKind() != ROOT) { // First time it might be EDiff.INSERTED where the cursor doesn't // move. while (mDiff == EDiff.INSERTED || moveCursor(mOldRtx, ERevision.OLD)) { if (mHashKind == HashKind.None || mDiffKind == EDiffOptimized.NO) { mDiff = diff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } else { mDiff = optimizedDiff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } } } done(); }
java
void diffMovement() throws TTException { assert mHashKind != null; assert mNewRtx != null; assert mOldRtx != null; assert mDiff != null; assert mDiffKind != null; // Check first nodes. if (mNewRtx.getNode().getKind() != ROOT) { if (mHashKind == HashKind.None || mDiffKind == EDiffOptimized.NO) { mDiff = diff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } else { mDiff = optimizedDiff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } } // Iterate over new revision. while ((mOldRtx.getNode().getKind() != ROOT && mDiff == EDiff.DELETED) || moveCursor(mNewRtx, ERevision.NEW)) { if (mDiff != EDiff.INSERTED) { moveCursor(mOldRtx, ERevision.OLD); } if (mNewRtx.getNode().getKind() != ROOT || mOldRtx.getNode().getKind() != ROOT) { if (mHashKind == HashKind.None || mDiffKind == EDiffOptimized.NO) { mDiff = diff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } else { mDiff = optimizedDiff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } } } // Nodes deleted in old rev at the end of the tree. if (mOldRtx.getNode().getKind() != ROOT) { // First time it might be EDiff.INSERTED where the cursor doesn't // move. while (mDiff == EDiff.INSERTED || moveCursor(mOldRtx, ERevision.OLD)) { if (mHashKind == HashKind.None || mDiffKind == EDiffOptimized.NO) { mDiff = diff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } else { mDiff = optimizedDiff(mNewRtx, mOldRtx, mDepth, EFireDiff.TRUE); } } } done(); }
[ "void", "diffMovement", "(", ")", "throws", "TTException", "{", "assert", "mHashKind", "!=", "null", ";", "assert", "mNewRtx", "!=", "null", ";", "assert", "mOldRtx", "!=", "null", ";", "assert", "mDiff", "!=", "null", ";", "assert", "mDiffKind", "!=", "nu...
Do the diff. @throws TTException if setting up transactions failes
[ "Do", "the", "diff", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java#L137-L183
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java
AbsDiff.moveCursor
boolean moveCursor(final INodeReadTrx paramRtx, final ERevision paramRevision) throws TTIOException { assert paramRtx != null; boolean moved = false; final ITreeStructData node = ((ITreeStructData)paramRtx.getNode()); if (node.hasFirstChild()) { if (node.getKind() != ROOT && mDiffKind == EDiffOptimized.HASHED && mHashKind != HashKind.None && (mDiff == EDiff.SAMEHASH || mDiff == EDiff.DELETED)) { moved = paramRtx.moveTo(((ITreeStructData)paramRtx.getNode()).getRightSiblingKey()); if (!moved) { moved = moveToFollowingNode(paramRtx, paramRevision); } } else { moved = paramRtx.moveTo(((ITreeStructData)paramRtx.getNode()).getFirstChildKey()); if (moved) { switch (paramRevision) { case NEW: mDepth.incrementNewDepth(); break; case OLD: mDepth.incrementOldDepth(); break; } } } } else if (node.hasRightSibling()) { if (paramRtx.getNode().getDataKey() == mRootKey) { paramRtx.moveTo(ROOT_NODE); } else { moved = paramRtx.moveTo(((ITreeStructData)paramRtx.getNode()).getRightSiblingKey()); } } else { moved = moveToFollowingNode(paramRtx, paramRevision); } return moved; }
java
boolean moveCursor(final INodeReadTrx paramRtx, final ERevision paramRevision) throws TTIOException { assert paramRtx != null; boolean moved = false; final ITreeStructData node = ((ITreeStructData)paramRtx.getNode()); if (node.hasFirstChild()) { if (node.getKind() != ROOT && mDiffKind == EDiffOptimized.HASHED && mHashKind != HashKind.None && (mDiff == EDiff.SAMEHASH || mDiff == EDiff.DELETED)) { moved = paramRtx.moveTo(((ITreeStructData)paramRtx.getNode()).getRightSiblingKey()); if (!moved) { moved = moveToFollowingNode(paramRtx, paramRevision); } } else { moved = paramRtx.moveTo(((ITreeStructData)paramRtx.getNode()).getFirstChildKey()); if (moved) { switch (paramRevision) { case NEW: mDepth.incrementNewDepth(); break; case OLD: mDepth.incrementOldDepth(); break; } } } } else if (node.hasRightSibling()) { if (paramRtx.getNode().getDataKey() == mRootKey) { paramRtx.moveTo(ROOT_NODE); } else { moved = paramRtx.moveTo(((ITreeStructData)paramRtx.getNode()).getRightSiblingKey()); } } else { moved = moveToFollowingNode(paramRtx, paramRevision); } return moved; }
[ "boolean", "moveCursor", "(", "final", "INodeReadTrx", "paramRtx", ",", "final", "ERevision", "paramRevision", ")", "throws", "TTIOException", "{", "assert", "paramRtx", "!=", "null", ";", "boolean", "moved", "=", "false", ";", "final", "ITreeStructData", "node", ...
Move cursor one node forward in pre order. @param paramRtx the {@link IReadTransaction} to use @param paramRevision the {@link ERevision} constant @return true, if cursor moved, false otherwise @throws TTIOException
[ "Move", "cursor", "one", "node", "forward", "in", "pre", "order", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java#L195-L233
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java
AbsDiff.moveToFollowingNode
private boolean moveToFollowingNode(final INodeReadTrx paramRtx, final ERevision paramRevision) throws TTIOException { boolean moved = false; while (!((ITreeStructData)paramRtx.getNode()).hasRightSibling() && ((ITreeStructData)paramRtx.getNode()).hasParent() && paramRtx.getNode().getDataKey() != mRootKey) { moved = paramRtx.moveTo(paramRtx.getNode().getParentKey()); if (moved) { switch (paramRevision) { case NEW: mDepth.decrementNewDepth(); break; case OLD: mDepth.decrementOldDepth(); break; } } } if (paramRtx.getNode().getDataKey() == mRootKey) { paramRtx.moveTo(ROOT_NODE); } moved = paramRtx.moveTo(((ITreeStructData)paramRtx.getNode()).getRightSiblingKey()); return moved; }
java
private boolean moveToFollowingNode(final INodeReadTrx paramRtx, final ERevision paramRevision) throws TTIOException { boolean moved = false; while (!((ITreeStructData)paramRtx.getNode()).hasRightSibling() && ((ITreeStructData)paramRtx.getNode()).hasParent() && paramRtx.getNode().getDataKey() != mRootKey) { moved = paramRtx.moveTo(paramRtx.getNode().getParentKey()); if (moved) { switch (paramRevision) { case NEW: mDepth.decrementNewDepth(); break; case OLD: mDepth.decrementOldDepth(); break; } } } if (paramRtx.getNode().getDataKey() == mRootKey) { paramRtx.moveTo(ROOT_NODE); } moved = paramRtx.moveTo(((ITreeStructData)paramRtx.getNode()).getRightSiblingKey()); return moved; }
[ "private", "boolean", "moveToFollowingNode", "(", "final", "INodeReadTrx", "paramRtx", ",", "final", "ERevision", "paramRevision", ")", "throws", "TTIOException", "{", "boolean", "moved", "=", "false", ";", "while", "(", "!", "(", "(", "ITreeStructData", ")", "p...
Move to next following node. @param paramRtx the {@link IReadTransaction} to use @param paramRevision the {@link ERevision} constant @return true, if cursor moved, false otherwise @throws TTIOException
[ "Move", "to", "next", "following", "node", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java#L245-L269
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java
AbsDiff.diff
EDiff diff(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx, final DepthCounter paramDepth, final EFireDiff paramFireDiff) throws TTIOException { assert paramNewRtx != null; assert paramOldRtx != null; assert paramDepth != null; EDiff diff = EDiff.SAME; // Check for modifications. switch (paramNewRtx.getNode().getKind()) { case ROOT: case TEXT: case ELEMENT: if (!checkNodes(paramNewRtx, paramOldRtx)) { diff = diffAlgorithm(paramNewRtx, paramOldRtx, paramDepth); } break; default: // Do nothing. } if (paramFireDiff == EFireDiff.TRUE) { fireDiff(diff, ((ITreeStructData)paramNewRtx.getNode()), ((ITreeStructData)paramOldRtx.getNode()), new DiffDepth(paramDepth.getNewDepth(), paramDepth.getOldDepth())); } return diff; }
java
EDiff diff(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx, final DepthCounter paramDepth, final EFireDiff paramFireDiff) throws TTIOException { assert paramNewRtx != null; assert paramOldRtx != null; assert paramDepth != null; EDiff diff = EDiff.SAME; // Check for modifications. switch (paramNewRtx.getNode().getKind()) { case ROOT: case TEXT: case ELEMENT: if (!checkNodes(paramNewRtx, paramOldRtx)) { diff = diffAlgorithm(paramNewRtx, paramOldRtx, paramDepth); } break; default: // Do nothing. } if (paramFireDiff == EFireDiff.TRUE) { fireDiff(diff, ((ITreeStructData)paramNewRtx.getNode()), ((ITreeStructData)paramOldRtx.getNode()), new DiffDepth(paramDepth.getNewDepth(), paramDepth.getOldDepth())); } return diff; }
[ "EDiff", "diff", "(", "final", "INodeReadTrx", "paramNewRtx", ",", "final", "INodeReadTrx", "paramOldRtx", ",", "final", "DepthCounter", "paramDepth", ",", "final", "EFireDiff", "paramFireDiff", ")", "throws", "TTIOException", "{", "assert", "paramNewRtx", "!=", "nu...
Diff of nodes. @param paramNewRtx {@link IReadTransaction} on new revision @param paramOldRtx {@link IReadTransaction} on old revision @param paramDepth {@link DepthCounter} container for current depths of both transaction cursors @param paramFireDiff determines if a diff should be fired @return kind of difference @throws TTIOException
[ "Diff", "of", "nodes", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java#L286-L312
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java
AbsDiff.optimizedDiff
EDiff optimizedDiff(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx, final DepthCounter paramDepth, final EFireDiff paramFireDiff) throws TTIOException { assert paramNewRtx != null; assert paramOldRtx != null; assert paramDepth != null; EDiff diff = EDiff.SAMEHASH; // Check for modifications. switch (paramNewRtx.getNode().getKind()) { case ROOT: case TEXT: case ELEMENT: if (paramNewRtx.getNode().getDataKey() != paramOldRtx.getNode().getDataKey() || paramNewRtx.getNode().getHash() != paramOldRtx.getNode().getHash()) { // Check if nodes are the same (even if subtrees may vary). if (checkNodes(paramNewRtx, paramOldRtx)) { diff = EDiff.SAME; } else { diff = diffAlgorithm(paramNewRtx, paramOldRtx, paramDepth); } } break; default: // Do nothing. } if (paramFireDiff == EFireDiff.TRUE) { if (diff == EDiff.SAMEHASH) { fireDiff(EDiff.SAME, ((ITreeStructData)paramNewRtx.getNode()), ((ITreeStructData)paramOldRtx .getNode()), new DiffDepth(paramDepth.getNewDepth(), paramDepth.getOldDepth())); } else { fireDiff(diff, ((ITreeStructData)paramNewRtx.getNode()), ((ITreeStructData)paramOldRtx.getNode()), new DiffDepth(paramDepth.getNewDepth(), paramDepth.getOldDepth())); } } return diff; }
java
EDiff optimizedDiff(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx, final DepthCounter paramDepth, final EFireDiff paramFireDiff) throws TTIOException { assert paramNewRtx != null; assert paramOldRtx != null; assert paramDepth != null; EDiff diff = EDiff.SAMEHASH; // Check for modifications. switch (paramNewRtx.getNode().getKind()) { case ROOT: case TEXT: case ELEMENT: if (paramNewRtx.getNode().getDataKey() != paramOldRtx.getNode().getDataKey() || paramNewRtx.getNode().getHash() != paramOldRtx.getNode().getHash()) { // Check if nodes are the same (even if subtrees may vary). if (checkNodes(paramNewRtx, paramOldRtx)) { diff = EDiff.SAME; } else { diff = diffAlgorithm(paramNewRtx, paramOldRtx, paramDepth); } } break; default: // Do nothing. } if (paramFireDiff == EFireDiff.TRUE) { if (diff == EDiff.SAMEHASH) { fireDiff(EDiff.SAME, ((ITreeStructData)paramNewRtx.getNode()), ((ITreeStructData)paramOldRtx .getNode()), new DiffDepth(paramDepth.getNewDepth(), paramDepth.getOldDepth())); } else { fireDiff(diff, ((ITreeStructData)paramNewRtx.getNode()), ((ITreeStructData)paramOldRtx.getNode()), new DiffDepth(paramDepth.getNewDepth(), paramDepth.getOldDepth())); } } return diff; }
[ "EDiff", "optimizedDiff", "(", "final", "INodeReadTrx", "paramNewRtx", ",", "final", "INodeReadTrx", "paramOldRtx", ",", "final", "DepthCounter", "paramDepth", ",", "final", "EFireDiff", "paramFireDiff", ")", "throws", "TTIOException", "{", "assert", "paramNewRtx", "!...
Optimized diff, which skips unnecessary comparsions. @param paramNewRtx {@link IReadTransaction} on new revision @param paramOldRtx {@link IReadTransaction} on old revision @param paramDepth {@link DepthCounter} container for current depths of both transaction cursors @param paramFireDiff determines if a diff should be fired @return kind of difference @throws TTIOException
[ "Optimized", "diff", "which", "skips", "unnecessary", "comparsions", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java#L329-L366
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java
AbsDiff.diffAlgorithm
private EDiff diffAlgorithm(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx, final DepthCounter paramDepth) throws TTIOException { EDiff diff = null; // Check if node has been deleted. if (paramDepth.getOldDepth() > paramDepth.getNewDepth()) { diff = EDiff.DELETED; } else if (checkUpdate(paramNewRtx, paramOldRtx)) { // Check if node has // been updated. diff = EDiff.UPDATED; } else { // See if one of the right sibling matches. EFoundEqualNode found = EFoundEqualNode.FALSE; final long key = paramOldRtx.getNode().getDataKey(); while (((ITreeStructData)paramOldRtx.getNode()).hasRightSibling() && paramOldRtx.moveTo(((ITreeStructData)paramOldRtx.getNode()).getRightSiblingKey()) && found == EFoundEqualNode.FALSE) { if (checkNodes(paramNewRtx, paramOldRtx)) { found = EFoundEqualNode.TRUE; } } paramOldRtx.moveTo(key); diff = found.kindOfDiff(); } assert diff != null; return diff; }
java
private EDiff diffAlgorithm(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx, final DepthCounter paramDepth) throws TTIOException { EDiff diff = null; // Check if node has been deleted. if (paramDepth.getOldDepth() > paramDepth.getNewDepth()) { diff = EDiff.DELETED; } else if (checkUpdate(paramNewRtx, paramOldRtx)) { // Check if node has // been updated. diff = EDiff.UPDATED; } else { // See if one of the right sibling matches. EFoundEqualNode found = EFoundEqualNode.FALSE; final long key = paramOldRtx.getNode().getDataKey(); while (((ITreeStructData)paramOldRtx.getNode()).hasRightSibling() && paramOldRtx.moveTo(((ITreeStructData)paramOldRtx.getNode()).getRightSiblingKey()) && found == EFoundEqualNode.FALSE) { if (checkNodes(paramNewRtx, paramOldRtx)) { found = EFoundEqualNode.TRUE; } } paramOldRtx.moveTo(key); diff = found.kindOfDiff(); } assert diff != null; return diff; }
[ "private", "EDiff", "diffAlgorithm", "(", "final", "INodeReadTrx", "paramNewRtx", ",", "final", "INodeReadTrx", "paramOldRtx", ",", "final", "DepthCounter", "paramDepth", ")", "throws", "TTIOException", "{", "EDiff", "diff", "=", "null", ";", "// Check if node has bee...
Main algorithm to compute diffs between two nodes. @param paramNewRtx {@link IReadTransaction} on new revision @param paramOldRtx {@link IReadTransaction} on old revision @param paramDepth {@link DepthCounter} container for current depths of both transaction cursors @return kind of diff @throws TTIOException
[ "Main", "algorithm", "to", "compute", "diffs", "between", "two", "nodes", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java#L381-L410
train
sebastiangraf/treetank
interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java
AbsDiff.checkUpdate
boolean checkUpdate(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx) throws TTIOException { assert paramNewRtx != null; assert paramOldRtx != null; boolean updated = false; final long newKey = paramNewRtx.getNode().getDataKey(); boolean movedNewRtx = paramNewRtx.moveTo(((ITreeStructData)paramNewRtx.getNode()).getRightSiblingKey()); final long oldKey = paramOldRtx.getNode().getDataKey(); boolean movedOldRtx = paramOldRtx.moveTo(((ITreeStructData)paramOldRtx.getNode()).getRightSiblingKey()); if (movedNewRtx && movedOldRtx && checkNodes(paramNewRtx, paramOldRtx)) { updated = true; } else if (!movedNewRtx && !movedOldRtx) { movedNewRtx = paramNewRtx.moveTo(paramNewRtx.getNode().getParentKey()); movedOldRtx = paramOldRtx.moveTo(paramOldRtx.getNode().getParentKey()); if (movedNewRtx && movedOldRtx && checkNodes(paramNewRtx, paramOldRtx)) { updated = true; } } paramNewRtx.moveTo(newKey); paramOldRtx.moveTo(oldKey); if (!updated) { updated = paramNewRtx.getNode().getDataKey() == paramOldRtx.getNode().getDataKey(); } return updated; }
java
boolean checkUpdate(final INodeReadTrx paramNewRtx, final INodeReadTrx paramOldRtx) throws TTIOException { assert paramNewRtx != null; assert paramOldRtx != null; boolean updated = false; final long newKey = paramNewRtx.getNode().getDataKey(); boolean movedNewRtx = paramNewRtx.moveTo(((ITreeStructData)paramNewRtx.getNode()).getRightSiblingKey()); final long oldKey = paramOldRtx.getNode().getDataKey(); boolean movedOldRtx = paramOldRtx.moveTo(((ITreeStructData)paramOldRtx.getNode()).getRightSiblingKey()); if (movedNewRtx && movedOldRtx && checkNodes(paramNewRtx, paramOldRtx)) { updated = true; } else if (!movedNewRtx && !movedOldRtx) { movedNewRtx = paramNewRtx.moveTo(paramNewRtx.getNode().getParentKey()); movedOldRtx = paramOldRtx.moveTo(paramOldRtx.getNode().getParentKey()); if (movedNewRtx && movedOldRtx && checkNodes(paramNewRtx, paramOldRtx)) { updated = true; } } paramNewRtx.moveTo(newKey); paramOldRtx.moveTo(oldKey); if (!updated) { updated = paramNewRtx.getNode().getDataKey() == paramOldRtx.getNode().getDataKey(); } return updated; }
[ "boolean", "checkUpdate", "(", "final", "INodeReadTrx", "paramNewRtx", ",", "final", "INodeReadTrx", "paramOldRtx", ")", "throws", "TTIOException", "{", "assert", "paramNewRtx", "!=", "null", ";", "assert", "paramOldRtx", "!=", "null", ";", "boolean", "updated", "...
Check for an update of a node. @param paramNewRtx first {@link IReadTransaction} instance @param paramOldRtx second {@link IReadTransaction} instance @return kind of diff @throws TTIOException
[ "Check", "for", "an", "update", "of", "a", "node", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/xml/src/main/java/org/treetank/service/xml/diff/AbsDiff.java#L466-L490
train
centic9/commons-dost
src/main/java/org/dstadler/commons/metrics/MovingAverage.java
MovingAverage.checkArgument
private void checkArgument(boolean argument, String msg, Object... args) { if (!argument) { throw new IllegalArgumentException(String.format(msg, args)); } }
java
private void checkArgument(boolean argument, String msg, Object... args) { if (!argument) { throw new IllegalArgumentException(String.format(msg, args)); } }
[ "private", "void", "checkArgument", "(", "boolean", "argument", ",", "String", "msg", ",", "Object", "...", "args", ")", "{", "if", "(", "!", "argument", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "msg", ",", ...
copy of Guava to avoid including Guava in this core library
[ "copy", "of", "Guava", "to", "avoid", "including", "Guava", "in", "this", "core", "library" ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/metrics/MovingAverage.java#L106-L110
train
Bedework/bw-util
bw-util-jms/src/main/java/org/bedework/util/jms/JmsConnectionHandler.java
JmsConnectionHandler.open
public void open(final String queueName) throws NotificationException { try { final ConnectionFactory connFactory; final Context ctx = new InitialContext(pr); /* try { Context jcectx = (Context)ctx.lookup("java:comp/env/"); // Still here - use that if (jcectx != null) { ctx = jcectx; } } catch (NamingException nfe) { // Stay with root } */ try { connFactory = (ConnectionFactory)ctx.lookup( pr.getProperty("org.bedework.connection.factory.name")); // connFactory = (ConnectionFactory)ctx.lookup(connFactoryName); connection = connFactory.createConnection(); } catch (final Throwable t) { if (debug()) { error(t); } throw new NotificationException(t); } try { /* Session is not transacted, * uses AUTO_ACKNOWLEDGE for message * acknowledgement */ session = connection.createSession(useTransactions, ackMode); if (session == null) { throw new NotificationException("No session created"); } final String qn = pr.getProperty("org.bedework.jms.queue.prefix") + queueName; try { ourQueue = (Queue)new InitialContext().lookup(qn); } catch (final NamingException ne) { // Try again with our own context ourQueue = (Queue)ctx.lookup(qn); } } catch (final Throwable t) { if (debug()) { error(t); } throw new NotificationException(t); } } catch (final NotificationException ne) { throw ne; } catch (final Throwable t) { if (debug()) { error(t); } throw new NotificationException(t); } }
java
public void open(final String queueName) throws NotificationException { try { final ConnectionFactory connFactory; final Context ctx = new InitialContext(pr); /* try { Context jcectx = (Context)ctx.lookup("java:comp/env/"); // Still here - use that if (jcectx != null) { ctx = jcectx; } } catch (NamingException nfe) { // Stay with root } */ try { connFactory = (ConnectionFactory)ctx.lookup( pr.getProperty("org.bedework.connection.factory.name")); // connFactory = (ConnectionFactory)ctx.lookup(connFactoryName); connection = connFactory.createConnection(); } catch (final Throwable t) { if (debug()) { error(t); } throw new NotificationException(t); } try { /* Session is not transacted, * uses AUTO_ACKNOWLEDGE for message * acknowledgement */ session = connection.createSession(useTransactions, ackMode); if (session == null) { throw new NotificationException("No session created"); } final String qn = pr.getProperty("org.bedework.jms.queue.prefix") + queueName; try { ourQueue = (Queue)new InitialContext().lookup(qn); } catch (final NamingException ne) { // Try again with our own context ourQueue = (Queue)ctx.lookup(qn); } } catch (final Throwable t) { if (debug()) { error(t); } throw new NotificationException(t); } } catch (final NotificationException ne) { throw ne; } catch (final Throwable t) { if (debug()) { error(t); } throw new NotificationException(t); } }
[ "public", "void", "open", "(", "final", "String", "queueName", ")", "throws", "NotificationException", "{", "try", "{", "final", "ConnectionFactory", "connFactory", ";", "final", "Context", "ctx", "=", "new", "InitialContext", "(", "pr", ")", ";", "/*\n try...
Open a connection to the named queue ready to create a producer or consumer. @param queueName the queue @throws NotificationException
[ "Open", "a", "connection", "to", "the", "named", "queue", "ready", "to", "create", "a", "producer", "or", "consumer", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-jms/src/main/java/org/bedework/util/jms/JmsConnectionHandler.java#L71-L136
train
centic9/commons-dost
src/main/java/org/dstadler/commons/graphviz/DotUtils.java
DotUtils.writeln
public static void writeln(final Writer writer, final String string, int indentLevel) throws IOException { writer.write(StringUtils.repeat("\t", indentLevel) + string); writer.write("\n"); }
java
public static void writeln(final Writer writer, final String string, int indentLevel) throws IOException { writer.write(StringUtils.repeat("\t", indentLevel) + string); writer.write("\n"); }
[ "public", "static", "void", "writeln", "(", "final", "Writer", "writer", ",", "final", "String", "string", ",", "int", "indentLevel", ")", "throws", "IOException", "{", "writer", ".", "write", "(", "StringUtils", ".", "repeat", "(", "\"\\t\"", ",", "indentLe...
Write out the string and a newline, appending a number of tabs to properly indent the resulting text-file. @param writer The writer for the .dot-file @param string The text to write @param indentLevel How much to indent the line @throws IOException if writing to the Writer fails
[ "Write", "out", "the", "string", "and", "a", "newline", "appending", "a", "number", "of", "tabs", "to", "properly", "indent", "the", "resulting", "text", "-", "file", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/graphviz/DotUtils.java#L45-L48
train
centic9/commons-dost
src/main/java/org/dstadler/commons/graphviz/DotUtils.java
DotUtils.writeHeader
public static void writeHeader(Writer writer, int dpi, String rankDir, String id, List<String> attribLines) throws IOException { // Default settings if (attribLines == null) { attribLines = new ArrayList<>(); } else { attribLines = new ArrayList<>(attribLines); } attribLines.add("node [shape=box];"); // add ... // DPI and Rankdir StringBuilder header = new StringBuilder("digraph " + id + " {\n"); if (dpi > 0) { header.append("dpi=").append(dpi).append(";\n"); } header.append("rankdir=").append(StringUtils.isNotBlank(rankDir) ? rankDir : "LR").append(";\n"); // Additional lines for (String line : attribLines) { line = line.trim(); header.append(line).append(line.endsWith(";") ? "\n" : ";\n"); } DotUtils.writeln(writer, header.toString()); }
java
public static void writeHeader(Writer writer, int dpi, String rankDir, String id, List<String> attribLines) throws IOException { // Default settings if (attribLines == null) { attribLines = new ArrayList<>(); } else { attribLines = new ArrayList<>(attribLines); } attribLines.add("node [shape=box];"); // add ... // DPI and Rankdir StringBuilder header = new StringBuilder("digraph " + id + " {\n"); if (dpi > 0) { header.append("dpi=").append(dpi).append(";\n"); } header.append("rankdir=").append(StringUtils.isNotBlank(rankDir) ? rankDir : "LR").append(";\n"); // Additional lines for (String line : attribLines) { line = line.trim(); header.append(line).append(line.endsWith(";") ? "\n" : ";\n"); } DotUtils.writeln(writer, header.toString()); }
[ "public", "static", "void", "writeHeader", "(", "Writer", "writer", ",", "int", "dpi", ",", "String", "rankDir", ",", "String", "id", ",", "List", "<", "String", ">", "attribLines", ")", "throws", "IOException", "{", "// Default settings", "if", "(", "attrib...
Write the header structure. @param writer A writer where the header is written to. @param dpi The resulting resolution, can be 0 for using the default DPI-setting of dot @param rankDir The direction of the graph, can be null @param id The id of the graph, cannot be null, needs to start with a alphabetical character, can contain numbers, alphabetic characters and underscore only. @param attribLines Additional attributes, can be null @throws IOException if writing to the Writer fails
[ "Write", "the", "header", "structure", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/graphviz/DotUtils.java#L61-L84
train
centic9/commons-dost
src/main/java/org/dstadler/commons/graphviz/DotUtils.java
DotUtils.renderGraph
public static void renderGraph(File dotfile, File resultfile) throws IOException { // call graphviz-dot via commons-exec CommandLine cmdLine = new CommandLine(DOT_EXE); cmdLine.addArgument("-T" + StringUtils.substringAfterLast(resultfile.getAbsolutePath(), ".")); cmdLine.addArgument(dotfile.getAbsolutePath()); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(0); ExecuteWatchdog watchdog = new ExecuteWatchdog(60000); executor.setWatchdog(watchdog); try { try (FileOutputStream out2 = new FileOutputStream(resultfile)) { executor.setStreamHandler(new PumpStreamHandler(out2, System.err)); int exitValue = executor.execute(cmdLine); if(exitValue != 0) { throw new IOException("Could not convert graph to dot, had exit value: " + exitValue + "!"); } } } catch (IOException e) { // if something went wrong the file should not be left behind... if(!resultfile.delete()) { System.out.println("Could not delete file " + resultfile); } throw e; } }
java
public static void renderGraph(File dotfile, File resultfile) throws IOException { // call graphviz-dot via commons-exec CommandLine cmdLine = new CommandLine(DOT_EXE); cmdLine.addArgument("-T" + StringUtils.substringAfterLast(resultfile.getAbsolutePath(), ".")); cmdLine.addArgument(dotfile.getAbsolutePath()); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(0); ExecuteWatchdog watchdog = new ExecuteWatchdog(60000); executor.setWatchdog(watchdog); try { try (FileOutputStream out2 = new FileOutputStream(resultfile)) { executor.setStreamHandler(new PumpStreamHandler(out2, System.err)); int exitValue = executor.execute(cmdLine); if(exitValue != 0) { throw new IOException("Could not convert graph to dot, had exit value: " + exitValue + "!"); } } } catch (IOException e) { // if something went wrong the file should not be left behind... if(!resultfile.delete()) { System.out.println("Could not delete file " + resultfile); } throw e; } }
[ "public", "static", "void", "renderGraph", "(", "File", "dotfile", ",", "File", "resultfile", ")", "throws", "IOException", "{", "// call graphviz-dot via commons-exec", "CommandLine", "cmdLine", "=", "new", "CommandLine", "(", "DOT_EXE", ")", ";", "cmdLine", ".", ...
Call graphviz-dot to convert the .dot-file to a rendered graph. The file extension of the specified result file is being used as the filetype of the rendering. @param dotfile The dot {@code File} used for the graph generation @param resultfile The {@code File} to which should be written @throws IOException if writing the resulting graph fails or other I/O problems occur
[ "Call", "graphviz", "-", "dot", "to", "convert", "the", ".", "dot", "-", "file", "to", "a", "rendered", "graph", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/graphviz/DotUtils.java#L109-L134
train
centic9/commons-dost
src/main/java/org/dstadler/commons/graphviz/DotUtils.java
DotUtils.checkDot
public static boolean checkDot() throws IOException { // call graphviz-dot via commons-exec CommandLine cmdLine = new CommandLine(DOT_EXE); cmdLine.addArgument("-V"); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(0); ExecuteWatchdog watchdog = new ExecuteWatchdog(60000); executor.setWatchdog(watchdog); executor.setStreamHandler(new PumpStreamHandler(System.out, System.err)); int exitValue = executor.execute(cmdLine); if(exitValue != 0) { System.err.println("Could not run '" + DOT_EXE + "', had exit value: " + exitValue + "!"); return false; } return true; }
java
public static boolean checkDot() throws IOException { // call graphviz-dot via commons-exec CommandLine cmdLine = new CommandLine(DOT_EXE); cmdLine.addArgument("-V"); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(0); ExecuteWatchdog watchdog = new ExecuteWatchdog(60000); executor.setWatchdog(watchdog); executor.setStreamHandler(new PumpStreamHandler(System.out, System.err)); int exitValue = executor.execute(cmdLine); if(exitValue != 0) { System.err.println("Could not run '" + DOT_EXE + "', had exit value: " + exitValue + "!"); return false; } return true; }
[ "public", "static", "boolean", "checkDot", "(", ")", "throws", "IOException", "{", "// call graphviz-dot via commons-exec", "CommandLine", "cmdLine", "=", "new", "CommandLine", "(", "DOT_EXE", ")", ";", "cmdLine", ".", "addArgument", "(", "\"-V\"", ")", ";", "Defa...
Verify if dot can be started and print out the version to stdout. @return True if "dot -V" ran successfully, false otherwise @throws IOException If running dot fails.
[ "Verify", "if", "dot", "can", "be", "started", "and", "print", "out", "the", "version", "to", "stdout", "." ]
f6fa4e3e0b943ff103f918824319d8abf33d0e0f
https://github.com/centic9/commons-dost/blob/f6fa4e3e0b943ff103f918824319d8abf33d0e0f/src/main/java/org/dstadler/commons/graphviz/DotUtils.java#L143-L159
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/WorkerHelper.java
WorkerHelper.shredInputStream
public static void shredInputStream(final INodeWriteTrx wtx, final InputStream value, final EShredderInsert child) { final XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.SUPPORT_DTD, false); XMLEventReader parser; try { parser = factory.createXMLEventReader(value); } catch (final XMLStreamException xmlse) { throw new WebApplicationException(xmlse); } try { final XMLShredder shredder = new XMLShredder(wtx, parser, child); shredder.call(); } catch (final Exception exce) { throw new WebApplicationException(exce); } }
java
public static void shredInputStream(final INodeWriteTrx wtx, final InputStream value, final EShredderInsert child) { final XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.SUPPORT_DTD, false); XMLEventReader parser; try { parser = factory.createXMLEventReader(value); } catch (final XMLStreamException xmlse) { throw new WebApplicationException(xmlse); } try { final XMLShredder shredder = new XMLShredder(wtx, parser, child); shredder.call(); } catch (final Exception exce) { throw new WebApplicationException(exce); } }
[ "public", "static", "void", "shredInputStream", "(", "final", "INodeWriteTrx", "wtx", ",", "final", "InputStream", "value", ",", "final", "EShredderInsert", "child", ")", "{", "final", "XMLInputFactory", "factory", "=", "XMLInputFactory", ".", "newInstance", "(", ...
Shreds a given InputStream @param wtx current write transaction reference @param value InputStream to be shred
[ "Shreds", "a", "given", "InputStream" ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/WorkerHelper.java#L91-L108
train
sebastiangraf/treetank
interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/WorkerHelper.java
WorkerHelper.closeWTX
public static void closeWTX(final boolean abortTransaction, final INodeWriteTrx wtx, final ISession ses) throws TTException { synchronized (ses) { if (abortTransaction) { wtx.abort(); } ses.close(); } }
java
public static void closeWTX(final boolean abortTransaction, final INodeWriteTrx wtx, final ISession ses) throws TTException { synchronized (ses) { if (abortTransaction) { wtx.abort(); } ses.close(); } }
[ "public", "static", "void", "closeWTX", "(", "final", "boolean", "abortTransaction", ",", "final", "INodeWriteTrx", "wtx", ",", "final", "ISession", "ses", ")", "throws", "TTException", "{", "synchronized", "(", "ses", ")", "{", "if", "(", "abortTransaction", ...
This method closes all open treetank connections concerning a NodeWriteTrx. @param abortTransaction <code>true</code> if the transaction has to be aborted, <code>false</code> otherwise. @param wtx INodeWriteTrx to be closed @param ses ISession to be closed @throws TreetankException
[ "This", "method", "closes", "all", "open", "treetank", "connections", "concerning", "a", "NodeWriteTrx", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/WorkerHelper.java#L195-L203
train
Bedework/bw-util
bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java
UtilAbstractAction.getContentName
public String getContentName(final Request req) throws Throwable { UtilActionForm form = req.getForm(); PresentationState ps = getPresentationState(req); String contentName = ps.getContentName(); form.setContentName(contentName); return contentName; }
java
public String getContentName(final Request req) throws Throwable { UtilActionForm form = req.getForm(); PresentationState ps = getPresentationState(req); String contentName = ps.getContentName(); form.setContentName(contentName); return contentName; }
[ "public", "String", "getContentName", "(", "final", "Request", "req", ")", "throws", "Throwable", "{", "UtilActionForm", "form", "=", "req", ".", "getForm", "(", ")", ";", "PresentationState", "ps", "=", "getPresentationState", "(", "req", ")", ";", "String", ...
Override this to get the contentName from different sources @param req @return String name of content @throws Throwable
[ "Override", "this", "to", "get", "the", "contentName", "from", "different", "sources" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java#L395-L403
train
Bedework/bw-util
bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java
UtilAbstractAction.checkLogOut
protected String checkLogOut(final HttpServletRequest request, final UtilActionForm form) throws Throwable { final String reqUser = request.getRemoteUser(); final boolean forceLogout = !Util.equalsString(reqUser, form.getCurrentUser()); final String temp = request.getParameter(requestLogout); if (forceLogout || (temp != null)) { final HttpSession sess = request.getSession(false); if ((sess != null) && logOutCleanup(request, form)) { sess.invalidate(); } return forwardLoggedOut; } return null; }
java
protected String checkLogOut(final HttpServletRequest request, final UtilActionForm form) throws Throwable { final String reqUser = request.getRemoteUser(); final boolean forceLogout = !Util.equalsString(reqUser, form.getCurrentUser()); final String temp = request.getParameter(requestLogout); if (forceLogout || (temp != null)) { final HttpSession sess = request.getSession(false); if ((sess != null) && logOutCleanup(request, form)) { sess.invalidate(); } return forwardLoggedOut; } return null; }
[ "protected", "String", "checkLogOut", "(", "final", "HttpServletRequest", "request", ",", "final", "UtilActionForm", "form", ")", "throws", "Throwable", "{", "final", "String", "reqUser", "=", "request", ".", "getRemoteUser", "(", ")", ";", "final", "boolean", "...
Check for logout request. @param request HttpServletRequest @param form @return null for continue, forwardLoggedOut to end session. @throws Throwable
[ "Check", "for", "logout", "request", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java#L511-L532
train
Bedework/bw-util
bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java
UtilAbstractAction.setRefreshInterval
public void setRefreshInterval(final HttpServletRequest request, final HttpServletResponse response, final int refreshInterval, final String refreshAction, final UtilActionForm form) { if (refreshInterval != 0) { StringBuilder sb = new StringBuilder(250); sb.append(refreshInterval); sb.append("; URL="); sb.append(form.getUrlPrefix()); if (!refreshAction.startsWith("/")) { sb.append("/"); } sb.append(refreshAction); response.setHeader("Refresh", sb.toString()); } }
java
public void setRefreshInterval(final HttpServletRequest request, final HttpServletResponse response, final int refreshInterval, final String refreshAction, final UtilActionForm form) { if (refreshInterval != 0) { StringBuilder sb = new StringBuilder(250); sb.append(refreshInterval); sb.append("; URL="); sb.append(form.getUrlPrefix()); if (!refreshAction.startsWith("/")) { sb.append("/"); } sb.append(refreshAction); response.setHeader("Refresh", sb.toString()); } }
[ "public", "void", "setRefreshInterval", "(", "final", "HttpServletRequest", "request", ",", "final", "HttpServletResponse", "response", ",", "final", "int", "refreshInterval", ",", "final", "String", "refreshAction", ",", "final", "UtilActionForm", "form", ")", "{", ...
Check request for refresh interval @param request @param response @param refreshInterval @param refreshAction @param form
[ "Check", "request", "for", "refresh", "interval" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java#L638-L655
train
Bedework/bw-util
bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java
UtilAbstractAction.setAppVar
public boolean setAppVar(final String name, final String val, final HashMap<String, String> appVars) { if (val == null) { appVars.remove(name); return true; } if (appVars.size() > maxAppVars) { return false; } appVars.put(name, val); return true; }
java
public boolean setAppVar(final String name, final String val, final HashMap<String, String> appVars) { if (val == null) { appVars.remove(name); return true; } if (appVars.size() > maxAppVars) { return false; } appVars.put(name, val); return true; }
[ "public", "boolean", "setAppVar", "(", "final", "String", "name", ",", "final", "String", "val", ",", "final", "HashMap", "<", "String", ",", "String", ">", "appVars", ")", "{", "if", "(", "val", "==", "null", ")", "{", "appVars", ".", "remove", "(", ...
Called to set an application variable to a value @param name name of variable @param val new value of variable - null means remove. @param appVars @return boolean True if ok - false for too many vars
[ "Called", "to", "set", "an", "application", "variable", "to", "a", "value" ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java#L739-L752
train
Bedework/bw-util
bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java
UtilAbstractAction.checkConfirmationId
protected String checkConfirmationId(final HttpServletRequest request, final UtilActionForm form) throws Throwable { String reqpar = request.getParameter("confirmationid"); if (reqpar == null) { return null; } if (!reqpar.equals(form.getConfirmationId())) { return "badConformationId"; } return null; }
java
protected String checkConfirmationId(final HttpServletRequest request, final UtilActionForm form) throws Throwable { String reqpar = request.getParameter("confirmationid"); if (reqpar == null) { return null; } if (!reqpar.equals(form.getConfirmationId())) { return "badConformationId"; } return null; }
[ "protected", "String", "checkConfirmationId", "(", "final", "HttpServletRequest", "request", ",", "final", "UtilActionForm", "form", ")", "throws", "Throwable", "{", "String", "reqpar", "=", "request", ".", "getParameter", "(", "\"confirmationid\"", ")", ";", "if", ...
Check for a confirmation id. This is a random string embedded in some requests to confirm that the incoming request came from a page we generated. Not all pages will have such an id but if we do it must match. We expect the request parameter to be of the form<br/> confirmationid=id<p>. @param request Needed to locate session @param form @return String forward to here on error. null for OK. @throws Throwable
[ "Check", "for", "a", "confirmation", "id", ".", "This", "is", "a", "random", "string", "embedded", "in", "some", "requests", "to", "confirm", "that", "the", "incoming", "request", "came", "from", "a", "page", "we", "generated", ".", "Not", "all", "pages", ...
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java#L788-L802
train
Bedework/bw-util
bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java
UtilAbstractAction.getReqPar
protected String getReqPar(final HttpServletRequest req, final String name) throws Throwable { return Util.checkNull(req.getParameter(name)); }
java
protected String getReqPar(final HttpServletRequest req, final String name) throws Throwable { return Util.checkNull(req.getParameter(name)); }
[ "protected", "String", "getReqPar", "(", "final", "HttpServletRequest", "req", ",", "final", "String", "name", ")", "throws", "Throwable", "{", "return", "Util", ".", "checkNull", "(", "req", ".", "getParameter", "(", "name", ")", ")", ";", "}" ]
Get a request parameter stripped of white space. Return null for zero length. @param req @param name name of parameter @return String value @throws Throwable
[ "Get", "a", "request", "parameter", "stripped", "of", "white", "space", ".", "Return", "null", "for", "zero", "length", "." ]
f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad
https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-struts/src/main/java/org/bedework/util/struts/UtilAbstractAction.java#L981-L983
train
danielnorberg/rut
rut/src/main/java/io/norberg/rut/Router.java
Router.route
public Status route(final CharSequence method, final CharSequence path, final Result<T> result) { result.captor.optionalTrailingSlash(optionalTrailingSlash); final RouteTarget<T> route = trie.lookup(path, result.captor); if (route == null) { return result.notFound().status(); } final Target<T> target = route.lookup(method); if (target == null) { return result.notAllowed(route).status(); } return result.success(path, route, target).status(); }
java
public Status route(final CharSequence method, final CharSequence path, final Result<T> result) { result.captor.optionalTrailingSlash(optionalTrailingSlash); final RouteTarget<T> route = trie.lookup(path, result.captor); if (route == null) { return result.notFound().status(); } final Target<T> target = route.lookup(method); if (target == null) { return result.notAllowed(route).status(); } return result.success(path, route, target).status(); }
[ "public", "Status", "route", "(", "final", "CharSequence", "method", ",", "final", "CharSequence", "path", ",", "final", "Result", "<", "T", ">", "result", ")", "{", "result", ".", "captor", ".", "optionalTrailingSlash", "(", "optionalTrailingSlash", ")", ";",...
Route a request. @param method The request method. E.g. {@code GET, PUT, POST, DELETE}, etc. @param path The request path. E.g. {@code /foo/baz/bar}. @param result A {@link Result} for storing the routing result, target and captured parameters. The {@link Result} should have enough capacity to store all captured parameters. See {@link #result()}. @return Routing status. {@link Status#SUCCESS} if an endpoint and matching method was found. {@link Status#NOT_FOUND} if the endpoint could not be found, {@link Status#METHOD_NOT_ALLOWED} if the endpoint was found but the method did not match.
[ "Route", "a", "request", "." ]
6cd99e0d464da934d446b554ab5bbecaf294fcdc
https://github.com/danielnorberg/rut/blob/6cd99e0d464da934d446b554ab5bbecaf294fcdc/rut/src/main/java/io/norberg/rut/Router.java#L49-L61
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java
NodeWriteTrx.insertName
private int insertName(final String pName) throws TTException { final String string = (pName == null ? "" : pName); final int nameKey = NamePageHash.generateHashForString(string); NodeMetaPageFactory.MetaKey key = new NodeMetaPageFactory.MetaKey(nameKey); NodeMetaPageFactory.MetaValue value = new NodeMetaPageFactory.MetaValue(string); getPageWtx().getMetaBucket().put(key, value); return nameKey; }
java
private int insertName(final String pName) throws TTException { final String string = (pName == null ? "" : pName); final int nameKey = NamePageHash.generateHashForString(string); NodeMetaPageFactory.MetaKey key = new NodeMetaPageFactory.MetaKey(nameKey); NodeMetaPageFactory.MetaValue value = new NodeMetaPageFactory.MetaValue(string); getPageWtx().getMetaBucket().put(key, value); return nameKey; }
[ "private", "int", "insertName", "(", "final", "String", "pName", ")", "throws", "TTException", "{", "final", "String", "string", "=", "(", "pName", "==", "null", "?", "\"\"", ":", "pName", ")", ";", "final", "int", "nameKey", "=", "NamePageHash", ".", "g...
Setting a new name in the metapage. @param pName to be set @throws TTException
[ "Setting", "a", "new", "name", "in", "the", "metapage", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java#L491-L498
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java
NodeWriteTrx.adaptForInsert
private void adaptForInsert(final ITreeData paramNewNode, final boolean addAsFirstChild) throws TTException { assert paramNewNode != null; if (paramNewNode instanceof ITreeStructData) { final ITreeStructData strucNode = (ITreeStructData)paramNewNode; final ITreeStructData parent = (ITreeStructData)getPtx().getData(paramNewNode.getParentKey()); parent.incrementChildCount(); if (addAsFirstChild) { parent.setFirstChildKey(paramNewNode.getDataKey()); } getPtx().setData(parent); if (strucNode.hasRightSibling()) { final ITreeStructData rightSiblingNode = (ITreeStructData)getPtx().getData(strucNode.getRightSiblingKey()); rightSiblingNode.setLeftSiblingKey(paramNewNode.getDataKey()); getPtx().setData(rightSiblingNode); } if (strucNode.hasLeftSibling()) { final ITreeStructData leftSiblingNode = (ITreeStructData)getPtx().getData(strucNode.getLeftSiblingKey()); leftSiblingNode.setRightSiblingKey(paramNewNode.getDataKey()); getPtx().setData(leftSiblingNode); } } }
java
private void adaptForInsert(final ITreeData paramNewNode, final boolean addAsFirstChild) throws TTException { assert paramNewNode != null; if (paramNewNode instanceof ITreeStructData) { final ITreeStructData strucNode = (ITreeStructData)paramNewNode; final ITreeStructData parent = (ITreeStructData)getPtx().getData(paramNewNode.getParentKey()); parent.incrementChildCount(); if (addAsFirstChild) { parent.setFirstChildKey(paramNewNode.getDataKey()); } getPtx().setData(parent); if (strucNode.hasRightSibling()) { final ITreeStructData rightSiblingNode = (ITreeStructData)getPtx().getData(strucNode.getRightSiblingKey()); rightSiblingNode.setLeftSiblingKey(paramNewNode.getDataKey()); getPtx().setData(rightSiblingNode); } if (strucNode.hasLeftSibling()) { final ITreeStructData leftSiblingNode = (ITreeStructData)getPtx().getData(strucNode.getLeftSiblingKey()); leftSiblingNode.setRightSiblingKey(paramNewNode.getDataKey()); getPtx().setData(leftSiblingNode); } } }
[ "private", "void", "adaptForInsert", "(", "final", "ITreeData", "paramNewNode", ",", "final", "boolean", "addAsFirstChild", ")", "throws", "TTException", "{", "assert", "paramNewNode", "!=", "null", ";", "if", "(", "paramNewNode", "instanceof", "ITreeStructData", ")...
Adapting everything for insert operations. @param paramNewNode pointer of the new node to be inserted @param addAsFirstChild determines the position where to insert @throws TTIOException if anything weird happens
[ "Adapting", "everything", "for", "insert", "operations", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java#L514-L540
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java
NodeWriteTrx.adaptForRemove
private void adaptForRemove(final ITreeStructData pOldNode) throws TTException { assert pOldNode != null; // Adapt left sibling node if there is one. if (pOldNode.hasLeftSibling()) { final ITreeStructData leftSibling = (ITreeStructData)getPtx().getData(pOldNode.getLeftSiblingKey()); leftSibling.setRightSiblingKey(pOldNode.getRightSiblingKey()); getPtx().setData(leftSibling); } // Adapt right sibling node if there is one. if (pOldNode.hasRightSibling()) { final ITreeStructData rightSibling = (ITreeStructData)getPtx().getData(pOldNode.getRightSiblingKey()); rightSibling.setLeftSiblingKey(pOldNode.getLeftSiblingKey()); getPtx().setData(rightSibling); } // Adapt parent, if node has now left sibling it is a first child. final ITreeStructData parent = (ITreeStructData)getPtx().getData(pOldNode.getParentKey()); if (!pOldNode.hasLeftSibling()) { parent.setFirstChildKey(pOldNode.getRightSiblingKey()); } parent.decrementChildCount(); getPtx().setData(parent); if (pOldNode.getKind() == IConstants.ELEMENT) { // removing attributes for (int i = 0; i < ((ElementNode)pOldNode).getAttributeCount(); i++) { moveTo(((ElementNode)pOldNode).getAttributeKey(i)); getPtx().removeData(mDelegate.getCurrentNode()); } // removing namespaces moveTo(pOldNode.getDataKey()); for (int i = 0; i < ((ElementNode)pOldNode).getNamespaceCount(); i++) { moveTo(((ElementNode)pOldNode).getNamespaceKey(i)); getPtx().removeData(mDelegate.getCurrentNode()); } } // Remove old node. getPtx().removeData(pOldNode); }
java
private void adaptForRemove(final ITreeStructData pOldNode) throws TTException { assert pOldNode != null; // Adapt left sibling node if there is one. if (pOldNode.hasLeftSibling()) { final ITreeStructData leftSibling = (ITreeStructData)getPtx().getData(pOldNode.getLeftSiblingKey()); leftSibling.setRightSiblingKey(pOldNode.getRightSiblingKey()); getPtx().setData(leftSibling); } // Adapt right sibling node if there is one. if (pOldNode.hasRightSibling()) { final ITreeStructData rightSibling = (ITreeStructData)getPtx().getData(pOldNode.getRightSiblingKey()); rightSibling.setLeftSiblingKey(pOldNode.getLeftSiblingKey()); getPtx().setData(rightSibling); } // Adapt parent, if node has now left sibling it is a first child. final ITreeStructData parent = (ITreeStructData)getPtx().getData(pOldNode.getParentKey()); if (!pOldNode.hasLeftSibling()) { parent.setFirstChildKey(pOldNode.getRightSiblingKey()); } parent.decrementChildCount(); getPtx().setData(parent); if (pOldNode.getKind() == IConstants.ELEMENT) { // removing attributes for (int i = 0; i < ((ElementNode)pOldNode).getAttributeCount(); i++) { moveTo(((ElementNode)pOldNode).getAttributeKey(i)); getPtx().removeData(mDelegate.getCurrentNode()); } // removing namespaces moveTo(pOldNode.getDataKey()); for (int i = 0; i < ((ElementNode)pOldNode).getNamespaceCount(); i++) { moveTo(((ElementNode)pOldNode).getNamespaceKey(i)); getPtx().removeData(mDelegate.getCurrentNode()); } } // Remove old node. getPtx().removeData(pOldNode); }
[ "private", "void", "adaptForRemove", "(", "final", "ITreeStructData", "pOldNode", ")", "throws", "TTException", "{", "assert", "pOldNode", "!=", "null", ";", "// Adapt left sibling node if there is one.", "if", "(", "pOldNode", ".", "hasLeftSibling", "(", ")", ")", ...
Adapting everything for remove operations. @param pOldNode pointer of the old node to be replaces @throws TTIOException if anything weird happens
[ "Adapting", "everything", "for", "remove", "operations", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java#L558-L599
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java
NodeWriteTrx.rollingUpdate
private void rollingUpdate(final long paramOldHash) throws TTException { final ITreeData newNode = mDelegate.getCurrentNode(); final long newNodeHash = newNode.hashCode(); long resultNew = newNode.hashCode(); // go the path to the root do { synchronized (mDelegate.getCurrentNode()) { getPtx().getData(mDelegate.getCurrentNode().getDataKey()); if (mDelegate.getCurrentNode().getDataKey() == newNode.getDataKey()) { resultNew = mDelegate.getCurrentNode().getHash() - paramOldHash; resultNew = resultNew + newNodeHash; } else { resultNew = mDelegate.getCurrentNode().getHash() - (paramOldHash * PRIME); resultNew = resultNew + newNodeHash * PRIME; } mDelegate.getCurrentNode().setHash(resultNew); getPtx().setData(mDelegate.getCurrentNode()); } } while (moveTo(mDelegate.getCurrentNode().getParentKey())); mDelegate.setCurrentNode(newNode); }
java
private void rollingUpdate(final long paramOldHash) throws TTException { final ITreeData newNode = mDelegate.getCurrentNode(); final long newNodeHash = newNode.hashCode(); long resultNew = newNode.hashCode(); // go the path to the root do { synchronized (mDelegate.getCurrentNode()) { getPtx().getData(mDelegate.getCurrentNode().getDataKey()); if (mDelegate.getCurrentNode().getDataKey() == newNode.getDataKey()) { resultNew = mDelegate.getCurrentNode().getHash() - paramOldHash; resultNew = resultNew + newNodeHash; } else { resultNew = mDelegate.getCurrentNode().getHash() - (paramOldHash * PRIME); resultNew = resultNew + newNodeHash * PRIME; } mDelegate.getCurrentNode().setHash(resultNew); getPtx().setData(mDelegate.getCurrentNode()); } } while (moveTo(mDelegate.getCurrentNode().getParentKey())); mDelegate.setCurrentNode(newNode); }
[ "private", "void", "rollingUpdate", "(", "final", "long", "paramOldHash", ")", "throws", "TTException", "{", "final", "ITreeData", "newNode", "=", "mDelegate", ".", "getCurrentNode", "(", ")", ";", "final", "long", "newNodeHash", "=", "newNode", ".", "hashCode",...
Adapting the structure with a rolling hash for all ancestors only with update. @param paramOldHash paramOldHash to be removed @throws TTIOException if anything weird happened
[ "Adapting", "the", "structure", "with", "a", "rolling", "hash", "for", "all", "ancestors", "only", "with", "update", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java#L749-L771
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java
NodeWriteTrx.rollingRemove
private void rollingRemove() throws TTException { final ITreeData startNode = mDelegate.getCurrentNode(); long hashToRemove = startNode.getHash(); long hashToAdd = 0; long newHash = 0; // go the path to the root do { synchronized (mDelegate.getCurrentNode()) { getPtx().getData(mDelegate.getCurrentNode().getDataKey()); if (mDelegate.getCurrentNode().getDataKey() == startNode.getDataKey()) { // the begin node is always null newHash = 0; } else if (mDelegate.getCurrentNode().getDataKey() == startNode.getParentKey()) { // the parent node is just removed newHash = mDelegate.getCurrentNode().getHash() - (hashToRemove * PRIME); hashToRemove = mDelegate.getCurrentNode().getHash(); } else { // the ancestors are all touched regarding the modification newHash = mDelegate.getCurrentNode().getHash() - (hashToRemove * PRIME); newHash = newHash + hashToAdd * PRIME; hashToRemove = mDelegate.getCurrentNode().getHash(); } mDelegate.getCurrentNode().setHash(newHash); hashToAdd = newHash; getPtx().setData(mDelegate.getCurrentNode()); } } while (moveTo(mDelegate.getCurrentNode().getParentKey())); mDelegate.setCurrentNode(startNode); }
java
private void rollingRemove() throws TTException { final ITreeData startNode = mDelegate.getCurrentNode(); long hashToRemove = startNode.getHash(); long hashToAdd = 0; long newHash = 0; // go the path to the root do { synchronized (mDelegate.getCurrentNode()) { getPtx().getData(mDelegate.getCurrentNode().getDataKey()); if (mDelegate.getCurrentNode().getDataKey() == startNode.getDataKey()) { // the begin node is always null newHash = 0; } else if (mDelegate.getCurrentNode().getDataKey() == startNode.getParentKey()) { // the parent node is just removed newHash = mDelegate.getCurrentNode().getHash() - (hashToRemove * PRIME); hashToRemove = mDelegate.getCurrentNode().getHash(); } else { // the ancestors are all touched regarding the modification newHash = mDelegate.getCurrentNode().getHash() - (hashToRemove * PRIME); newHash = newHash + hashToAdd * PRIME; hashToRemove = mDelegate.getCurrentNode().getHash(); } mDelegate.getCurrentNode().setHash(newHash); hashToAdd = newHash; getPtx().setData(mDelegate.getCurrentNode()); } } while (moveTo(mDelegate.getCurrentNode().getParentKey())); mDelegate.setCurrentNode(startNode); }
[ "private", "void", "rollingRemove", "(", ")", "throws", "TTException", "{", "final", "ITreeData", "startNode", "=", "mDelegate", ".", "getCurrentNode", "(", ")", ";", "long", "hashToRemove", "=", "startNode", ".", "getHash", "(", ")", ";", "long", "hashToAdd",...
Adapting the structure with a rolling hash for all ancestors only with remove. @throws TTIOException if anything weird happened
[ "Adapting", "the", "structure", "with", "a", "rolling", "hash", "for", "all", "ancestors", "only", "with", "remove", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java#L780-L809
train
sebastiangraf/treetank
coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java
NodeWriteTrx.buildName
public static String buildName(final QName pQName) { if (pQName == null) { throw new NullPointerException("mQName must not be null!"); } String name; if (pQName.getPrefix().isEmpty()) { name = pQName.getLocalPart(); } else { name = new StringBuilder(pQName.getPrefix()).append(":").append(pQName.getLocalPart()).toString(); } return name; }
java
public static String buildName(final QName pQName) { if (pQName == null) { throw new NullPointerException("mQName must not be null!"); } String name; if (pQName.getPrefix().isEmpty()) { name = pQName.getLocalPart(); } else { name = new StringBuilder(pQName.getPrefix()).append(":").append(pQName.getLocalPart()).toString(); } return name; }
[ "public", "static", "String", "buildName", "(", "final", "QName", "pQName", ")", "{", "if", "(", "pQName", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"mQName must not be null!\"", ")", ";", "}", "String", "name", ";", "if", "(", ...
Building name consisting out of prefix and name. NamespaceUri is not used over here. @param pQName the {@link QName} of an element @return a string with [prefix:]localname
[ "Building", "name", "consisting", "out", "of", "prefix", "and", "name", ".", "NamespaceUri", "is", "not", "used", "over", "here", "." ]
9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60
https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/coremodules/node/src/main/java/org/treetank/access/NodeWriteTrx.java#L939-L950
train