idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
23,300
private void scanComment ( ) { final char input = mQuery . charAt ( mPos + 1 ) ; if ( mInput == ':' ) { if ( input == ')' ) { mCommentCount -- ; if ( mCommentCount == 0 ) { mState = State . START ; mPos ++ ; } } } else if ( mInput == '(' ) { if ( input == ':' ) { mCommentCount ++ ; } } mPos ++ ; }
Scans comments .
23,301
private boolean isLetter ( final char paramInput ) { return ( paramInput >= '0' && paramInput <= '9' ) || ( paramInput >= 'a' && paramInput <= 'z' ) || ( paramInput >= 'A' && paramInput <= 'Z' ) || ( paramInput == '_' ) || ( paramInput == '-' ) || ( paramInput == '.' ) ; }
Checks if the given character is a letter .
23,302
public StreamingOutput getResource ( final String resourceName , final long nodeId , final Map < QueryParameter , String > queryParams ) throws JaxRxException { final StreamingOutput sOutput = new StreamingOutput ( ) { public void write ( final OutputStream output ) throws IOException , JaxRxException { final String re...
This method is responsible to deliver the whole XML resource addressed by a unique node id .
23,303
public StreamingOutput performQueryOnResource ( final String resourceName , final long nodeId , final String query , final Map < QueryParameter , String > queryParams ) { final StreamingOutput sOutput = new StreamingOutput ( ) { public void write ( final OutputStream output ) throws IOException , JaxRxException { final...
This method is responsible to perform a XPath query expression on the XML resource which is addressed through a unique node id .
23,304
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 { session = mDatabase . ...
This method is responsible to modify the XML resource which is addressed through a unique node id .
23,305
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 = fals...
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 .
23,306
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 ( reso...
This method serializes requested resource
23,307
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 ) |...
Factory method to implement the comparator .
23,308
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 ; } }
Get an Integer request parameter or null . Emit error for non - null and non integer
23,309
public static String retrieveData ( String sUrl , int timeout ) throws IOException { return retrieveData ( sUrl , null , timeout ) ; }
Download data from an URL .
23,310
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 ) ; } return new String ( rawData , encoding ) ; }
Download data from an URL if necessary converting from a character encoding .
23,311
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 ( ) ; if (...
Download data from an URL and return the raw bytes .
23,312
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 { if ( type == NamePageHash . generateHashForString ( "xs:unt...
Atomizes an operand according to the rules specified in the XPath specification .
23,313
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 ; }
If the named property is present and has a value use that . Otherwise set the value to the given default and use that .
23,314
public void finishExpr ( final INodeReadTrx mTransaction , final int mNum ) { if ( getPipeStack ( ) . size ( ) != mNum ) { throw new IllegalStateException ( "The query has not been processed correctly" ) ; } int no = mNum ; AbsAxis [ ] axis ; if ( no > 1 ) { axis = new AbsAxis [ no ] ; while ( no -- > 0 ) { axis [ no ]...
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 .
23,315
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 ...
Adds a if expression to the pipeline .
23,316
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 ( ) ;...
Adds a comparison expression to the pipeline .
23,317
public void addOperatorExpression ( final INodeReadTrx mTransaction , final String mOperator ) { assert getPipeStack ( ) . size ( ) >= 1 ; final INodeReadTrx rtx = mTransaction ; final AbsAxis mOperand2 = getPipeStack ( ) . pop ( ) . getExpr ( ) ; final AbsAxis mOperand1 = getPipeStack ( ) . pop ( ) . getExpr ( ) ; if ...
Adds an operator expression to the pipeline .
23,318
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 ( ) !=...
Adds a union expression to the pipeline .
23,319
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 ...
Adds a and expression to the pipeline .
23,320
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 ...
Adds a or expression to the pipeline .
23,321
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 ( ) ; f...
Adds a intersect or a exception expression to the pipeline .
23,322
public void addLiteral ( final INodeReadTrx pTrans , final AtomicValue pVal ) { getExpression ( ) . add ( new LiteralExpr ( pTrans , AbsAxis . addAtomicToItemList ( pTrans , pVal ) ) ) ; }
Adds a literal expression to the pipeline .
23,323
public void addStep ( final AbsAxis axis , final AbsFilter mFilter ) { getExpression ( ) . add ( new FilterAxis ( axis , mRtx , mFilter ) ) ; }
Adds a step to the pipeline .
23,324
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." ) ; } }
Returns a queue of all pipelines build so far and empties the pipeline stack .
23,325
public void addPredicate ( final INodeReadTrx mTransaction ) { assert getPipeStack ( ) . size ( ) >= 2 ; final AbsAxis mPredicate = getPipeStack ( ) . pop ( ) . getExpr ( ) ; if ( mPredicate instanceof LiteralExpr ) { mPredicate . hasNext ( ) ; final int type = mTransaction . getNode ( ) . getTypeKey ( ) ; if ( type ==...
Adds a predicate to the pipeline .
23,326
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 ; whi...
Adds a SomeExpression or an EveryExpression to the pipeline depending on the parameter isSome .
23,327
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...
Adds a castable expression to the pipeline .
23,328
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 ) ;...
Adds a range expression to the pipeline .
23,329
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 (...
Adds a instance of expression to the pipeline .
23,330
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 ( getP...
Adds a variable expression to the pipeline . Adds the expression that will evaluate the results the variable holds .
23,331
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 ) ; for ( int i = 0 ; i < mNum ; i ++ ) { args . add ( getPipeStack ( ) . pop ( ) . ...
Adds a function to the pipeline .
23,332
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 ...
Adds a VarRefExpr to the pipeline . This Expression holds a reference to the current context item of the specified variable .
23,333
public static boolean stopProcess ( final AbstractProcessorThread proc ) { proc . info ( "************************************************************" ) ; proc . info ( " * Stopping " + proc . getName ( ) ) ; proc . info ( "************************************************************" ) ; proc . setRunning ( false ) ;...
Shut down a running process .
23,334
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 .
23,335
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 ) ; } }
Move cursor to a node by its node key .
23,336
public void close ( ) throws TTException { atomics . remove ( mRTX ) ; lastPointer . remove ( mRTX ) ; mRTX . close ( ) ; }
Closing the Transaction
23,337
public ItemList getItemList ( ) { if ( ! atomics . containsKey ( mRTX ) ) { atomics . put ( mRTX , new ItemList ( ) ) ; } return atomics . get ( mRTX ) ; }
Getting the ItemList .
23,338
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 ) ; }
Adding any AtomicVal to any ItemList staticly .
23,339
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 (...
Return the next record in the input stream .
23,340
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 . ge...
dumpLdif write the entire record as ldif .
23,341
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 ; }
If either the lang or country is null we provide a default value for the whole locale . Otherwise we construct one .
23,342
private StreamingOutput createOutput ( final JaxRx impl , final ResourcePath path ) { String qu = path . getValue ( QueryParameter . COMMAND ) ; if ( qu != null ) { return impl . command ( qu , path ) ; } qu = path . getValue ( QueryParameter . RUN ) ; if ( qu != null ) { return impl . run ( qu , path ) ; } qu = path ....
Returns a stream output depending on the query parameters .
23,343
Response createResponse ( final JaxRx impl , final ResourcePath path ) { final StreamingOutput out = createOutput ( impl , path ) ; final boolean wrap = path . getValue ( QueryParameter . WRAP ) == null || path . getValue ( QueryParameter . WRAP ) . equals ( "yes" ) ; String type = wrap ? MediaType . APPLICATION_XML : ...
Returns a result depending on the query parameters .
23,344
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 ( fina...
Extracts and returns query parameters from the specified map . If a parameter is specified multiple times its values will be separated with tab characters .
23,345
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 ( ) . toSt...
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 .
23,346
private void prefetch ( long storageIndex ) { long startIndex = storageIndex / BYTES_IN_DATA ; startIndex += 128 ; if ( mPrefetchedBuckets . contains ( startIndex ) ) { mPrefetchedBuckets . remove ( startIndex ) ; return ; } for ( int i = 0 ; i < BUCKETS_TO_PREFETCH ; i ++ ) { if ( ( startIndex + i ) > ( mNodeNumbers /...
Prefetch buckets if necessary
23,347
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 = n...
This method parses an XML input with a W3C DOM implementation and validates it then with the available XML schema .
23,348
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 . new...
This method checks the parsed document if it is valid to a given XML schema . If not an exception is thrown
23,349
public static String getUid ( ) { 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 ) ) . appen...
Code copied and modified from hibernate UUIDHexGenerator . Generates a unique 36 character key of hex + separators .
23,350
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 ; }
From hibernate . util
23,351
public boolean search ( String base , String filter ) throws NamingException { return search ( base , filter , scopeSub ) ; }
Carry out a subtree search
23,352
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 .
23,353
public boolean searchOne ( String base , String filter ) throws NamingException { return search ( base , filter , scopeOne ) ; }
Carry out a one level search
23,354
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 .
23,355
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 ( ) ; }
Returning all elements as Iterator .
23,356
public boolean read ( Input in ) throws NamingException { clear ( ) ; this . in = in ; 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 ( ) ; ...
Read an entire ldif record from an input stream
23,357
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' ) ; } w...
Write the data we built this from
23,358
public void write ( Writer wtr ) throws Throwable { wtr . write ( getDn ( ) ) ; wtr . write ( '\n' ) ; throw new Exception ( "Incomplete" ) ; }
Write an ldif record representing this object
23,359
private void addAttrVal ( String attr , String val , boolean encoded , boolean url ) throws NamingException { if ( state == stateNeedDn ) { if ( attr . equals ( "version" ) ) { if ( version != null ) throwmsg ( "Repeated version record" ) ; if ( ! ( val . equals ( "1" ) ) ) throwmsg ( "Invalid LDIF version " + val . to...
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 .
23,360
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 ; defaul...
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 .
23,361
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 ) ; }
Decode a percent encoded byte . E . g . %3F - > 63 .
23,362
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 ) ) ; }
Decode two hex nibbles to a byte . E . g . 3 and F - > 63 .
23,363
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 ; }
Decode a hex nibble . E . g . 3 - > 3 and F - > 15 .
23,364
private static int utf8Read3 ( int cu1 , int cu2 , int cu3 ) { if ( ( cu2 & 0xC0 ) != 0x80 ) { return INVALID ; } if ( cu1 == 0xE0 && cu2 < 0xA0 ) { return INVALID ; } if ( ( cu3 & 0xC0 ) != 0x80 ) { return INVALID ; } return ( cu1 << 12 ) + ( cu2 << 6 ) + cu3 - 0xE2080 ; }
Read a 3 byte UTF8 sequence .
23,365
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 ; } if ( cu1 == 0xF4 && cu2 >= 0x90 ) { return INVALID ; } if ( ( cu3 & 0xC0 ) != 0x80 ) { return INVALID ; } if ( ( cu4 & 0xC0 ) != 0x80 ) { retu...
Read a 4 byte UTF8 sequence .
23,366
public void close ( ) { if ( consumer != null ) { try { consumer . close ( ) ; } catch ( Throwable t ) { warn ( t . getMessage ( ) ) ; } } conn . close ( ) ; }
Close and release resources .
23,367
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 = fal...
For asynch we do the onMessage listener style . Otherwise we wait synchronously for incoming messages .
23,368
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 ...
Test URL and report if it can be read .
23,369
private void fillDataStructures ( ) { final ITreeData treeData = mRtx . getNode ( ) ; mInOrder . put ( treeData , true ) ; mDescendants . put ( treeData , 1L ) ; }
Fill data structures .
23,370
@ 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 ( ) ) { soc...
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 .
23,371
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 ; }
Fetch a timezone object from the server given the id .
23,372
void diffMovement ( ) throws TTException { assert mHashKind != null ; assert mNewRtx != null ; assert mOldRtx != null ; assert mDiff != null ; assert mDiffKind != null ; if ( mNewRtx . getNode ( ) . getKind ( ) != ROOT ) { if ( mHashKind == HashKind . None || mDiffKind == EDiffOptimized . NO ) { mDiff = diff ( mNewRtx ...
Do the diff .
23,373
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 == EDif...
Move cursor one node forward in pre order .
23,374
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 ( ) . ...
Move to next following node .
23,375
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 ; switch ( paramNewRtx . getNode ( ) . get...
Diff of nodes .
23,376
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 ; switch ( paramNewRtx . getN...
Optimized diff which skips unnecessary comparsions .
23,377
private EDiff diffAlgorithm ( final INodeReadTrx paramNewRtx , final INodeReadTrx paramOldRtx , final DepthCounter paramDepth ) throws TTIOException { EDiff diff = null ; if ( paramDepth . getOldDepth ( ) > paramDepth . getNewDepth ( ) ) { diff = EDiff . DELETED ; } else if ( checkUpdate ( paramNewRtx , paramOldRtx ) )...
Main algorithm to compute diffs between two nodes .
23,378
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 ( ( ( ITreeStruct...
Check for an update of a node .
23,379
private void checkArgument ( boolean argument , String msg , Object ... args ) { if ( ! argument ) { throw new IllegalArgumentException ( String . format ( msg , args ) ) ; } }
copy of Guava to avoid including Guava in this core library
23,380
public void open ( final String queueName ) throws NotificationException { try { final ConnectionFactory connFactory ; final Context ctx = new InitialContext ( pr ) ; try { connFactory = ( ConnectionFactory ) ctx . lookup ( pr . getProperty ( "org.bedework.connection.factory.name" ) ) ; connection = connFactory . creat...
Open a connection to the named queue ready to create a producer or consumer .
23,381
public static void writeln ( final Writer writer , final String string , int indentLevel ) throws IOException { writer . write ( StringUtils . repeat ( "\t" , indentLevel ) + string ) ; writer . write ( "\n" ) ; }
Write out the string and a newline appending a number of tabs to properly indent the resulting text - file .
23,382
public static void writeHeader ( Writer writer , int dpi , String rankDir , String id , List < String > attribLines ) throws IOException { if ( attribLines == null ) { attribLines = new ArrayList < > ( ) ; } else { attribLines = new ArrayList < > ( attribLines ) ; } attribLines . add ( "node [shape=box];" ) ; StringBui...
Write the header structure .
23,383
public static void renderGraph ( File dotfile , File resultfile ) throws IOException { CommandLine cmdLine = new CommandLine ( DOT_EXE ) ; cmdLine . addArgument ( "-T" + StringUtils . substringAfterLast ( resultfile . getAbsolutePath ( ) , "." ) ) ; cmdLine . addArgument ( dotfile . getAbsolutePath ( ) ) ; DefaultExecu...
Call graphviz - dot to convert the . dot - file to a rendered graph .
23,384
public static boolean checkDot ( ) throws IOException { CommandLine cmdLine = new CommandLine ( DOT_EXE ) ; cmdLine . addArgument ( "-V" ) ; DefaultExecutor executor = new DefaultExecutor ( ) ; executor . setExitValue ( 0 ) ; ExecuteWatchdog watchdog = new ExecuteWatchdog ( 60000 ) ; executor . setWatchdog ( watchdog )...
Verify if dot can be started and print out the version to stdout .
23,385
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 . createXMLEventR...
Shreds a given InputStream
23,386
public static void closeWTX ( final boolean abortTransaction , final INodeWriteTrx wtx , final ISession ses ) throws TTException { synchronized ( ses ) { if ( abortTransaction ) { wtx . abort ( ) ; } ses . close ( ) ; } }
This method closes all open treetank connections concerning a NodeWriteTrx .
23,387
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 ; }
Override this to get the contentName from different sources
23,388
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 ) ;...
Check for logout request .
23,389
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 ( "; ...
Check request for refresh interval
23,390
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 ; }
Called to set an application variable to a value
23,391
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...
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 .
23,392
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 .
23,393
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 ( ) ; } fi...
Route a request .
23,394
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 ...
Setting a new name in the metapage .
23,395
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 ...
Adapting everything for insert operations .
23,396
private void adaptForRemove ( final ITreeStructData pOldNode ) throws TTException { assert pOldNode != null ; if ( pOldNode . hasLeftSibling ( ) ) { final ITreeStructData leftSibling = ( ITreeStructData ) getPtx ( ) . getData ( pOldNode . getLeftSiblingKey ( ) ) ; leftSibling . setRightSiblingKey ( pOldNode . getRightS...
Adapting everything for remove operations .
23,397
private void rollingUpdate ( final long paramOldHash ) throws TTException { final ITreeData newNode = mDelegate . getCurrentNode ( ) ; final long newNodeHash = newNode . hashCode ( ) ; long resultNew = newNode . hashCode ( ) ; do { synchronized ( mDelegate . getCurrentNode ( ) ) { getPtx ( ) . getData ( mDelegate . get...
Adapting the structure with a rolling hash for all ancestors only with update .
23,398
private void rollingRemove ( ) throws TTException { final ITreeData startNode = mDelegate . getCurrentNode ( ) ; long hashToRemove = startNode . getHash ( ) ; long hashToAdd = 0 ; long newHash = 0 ; do { synchronized ( mDelegate . getCurrentNode ( ) ) { getPtx ( ) . getData ( mDelegate . getCurrentNode ( ) . getDataKey...
Adapting the structure with a rolling hash for all ancestors only with remove .
23,399
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 ( ":" ) ....
Building name consisting out of prefix and name . NamespaceUri is not used over here .