idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
19,500
public static Type newInstance ( int sqlType ) { switch ( sqlType ) { case ( java . sql . Types . INTEGER ) : return INTEGER ; case ( java . sql . Types . BIGINT ) : return BIGINT ; case ( java . sql . Types . DOUBLE ) : return DOUBLE ; case ( java . sql . Types . VARCHAR ) : return VARCHAR ; } throw new UnsupportedOpe...
Constructs a new instance corresponding to the specified SQL type .
19,501
public Buffer pin ( BlockId blk ) { PinnedBuffer pinnedBuff = pinnedBuffers . get ( blk ) ; if ( pinnedBuff != null ) { pinnedBuff . pinnedCount ++ ; return pinnedBuff . buffer ; } if ( pinnedBuffers . size ( ) == BUFFER_POOL_SIZE ) throw new BufferAbortException ( ) ; try { Buffer buff ; long timestamp = System . curr...
Pins a buffer to the specified block potentially waiting until a buffer becomes available . If no buffer becomes available within a fixed time period then repins all currently holding blocks .
19,502
public Buffer pinNew ( String fileName , PageFormatter fmtr ) { if ( pinnedBuffers . size ( ) == BUFFER_POOL_SIZE ) throw new BufferAbortException ( ) ; try { Buffer buff ; long timestamp = System . currentTimeMillis ( ) ; boolean waitedBeforeGotBuffer = false ; buff = bufferPool . pinNew ( fileName , fmtr ) ; if ( buf...
Pins a buffer to a new block in the specified file potentially waiting until a buffer becomes available . If no buffer becomes available within a fixed time period then repins all currently holding blocks .
19,503
public void unpin ( Buffer buff ) { BlockId blk = buff . block ( ) ; PinnedBuffer pinnedBuff = pinnedBuffers . get ( blk ) ; if ( pinnedBuff != null ) { pinnedBuff . pinnedCount -- ; if ( pinnedBuff . pinnedCount == 0 ) { bufferPool . unpin ( buff ) ; pinnedBuffers . remove ( blk ) ; synchronized ( bufferPool ) { buffe...
Unpins the specified buffer . If the buffer s pin count becomes 0 then the threads on the wait list are notified .
19,504
private void repin ( ) { if ( logger . isLoggable ( Level . WARNING ) ) logger . warning ( "Tx." + txNum + " is re-pinning all buffers" ) ; try { List < BlockId > blksToBeRepinned = new LinkedList < BlockId > ( ) ; Map < BlockId , Integer > pinCounts = new HashMap < BlockId , Integer > ( ) ; List < Buffer > buffersToBe...
Unpins all currently pinned buffers of the calling transaction and repins them .
19,505
public static Map < String , Integer > offsetMap ( Schema sch ) { int pos = 0 ; Map < String , Integer > offsetMap = new HashMap < String , Integer > ( ) ; for ( String fldname : sch . fields ( ) ) { offsetMap . put ( fldname , pos ) ; pos += Page . maxSize ( sch . type ( fldname ) ) ; } return offsetMap ; }
Returns the map of field name to offset of a specified schema .
19,506
public static int recordSize ( Schema sch ) { int pos = 0 ; for ( String fldname : sch . fields ( ) ) pos += Page . maxSize ( sch . type ( fldname ) ) ; return pos < MIN_REC_SIZE ? MIN_REC_SIZE : pos ; }
Returns the number of bytes required to store a record with the specified schema in disk .
19,507
public Constant getVal ( String fldName ) { int position = fieldPos ( fldName ) ; return getVal ( position , ti . schema ( ) . type ( fldName ) ) ; }
Returns the value stored in the specified field of this record .
19,508
public void setVal ( String fldName , Constant val ) { int position = fieldPos ( fldName ) ; setVal ( position , val ) ; }
Stores a value at the specified field of this record .
19,509
public void delete ( RecordId nextDeletedSlot ) { Constant flag = EMPTY_CONST ; setVal ( currentPos ( ) , flag ) ; setNextDeletedSlotId ( nextDeletedSlot ) ; }
Deletes the current record . Deletion is performed by marking the record as deleted and setting the content as a pointer points to next deleted slot .
19,510
public boolean insertIntoTheCurrentSlot ( ) { if ( ! getVal ( currentPos ( ) , INTEGER ) . equals ( EMPTY_CONST ) ) return false ; setVal ( currentPos ( ) , INUSE_CONST ) ; return true ; }
Marks the current slot as in - used .
19,511
public boolean insertIntoNextEmptySlot ( ) { boolean found = searchFor ( EMPTY ) ; if ( found ) { Constant flag = INUSE_CONST ; setVal ( currentPos ( ) , flag ) ; } return found ; }
Inserts a new blank record somewhere in the page . Return false if there were no available slots .
19,512
public RecordId insertIntoDeletedSlot ( ) { RecordId nds = getNextDeletedSlotId ( ) ; setNextDeletedSlotId ( new RecordId ( new BlockId ( "" , 0 ) , 0 ) ) ; Constant flag = INUSE_CONST ; setVal ( currentPos ( ) , flag ) ; return nds ; }
Inserts a new blank record into this deleted slot and return the record id of the next one .
19,513
public void runAllSlot ( ) { moveToId ( 0 ) ; System . out . println ( "== runAllSlot start at " + currentSlot + " ==" ) ; while ( isValidSlot ( ) ) { if ( currentSlot % 10 == 0 ) System . out . print ( currentSlot + ": " ) ; int flag = ( Integer ) getVal ( currentPos ( ) , INTEGER ) . asJavaVal ( ) ; System . out . pr...
Print all Slot IN_USE or EMPTY for debugging
19,514
public synchronized void startCollecting ( ) { paused = false ; if ( thread != null ) return ; packages = new CountMap < String > ( MAX_PACKAGES ) ; selfMethods = new CountMap < String > ( MAX_METHODS ) ; stackMethods = new CountMap < String > ( MAX_METHODS ) ; lines = new CountMap < String > ( MAX_LINES ) ; total = 0 ...
Start collecting profiling data .
19,515
public synchronized void stopCollecting ( ) { started = false ; if ( thread != null ) { try { thread . join ( ) ; } catch ( InterruptedException e ) { } thread = null ; } }
Stop collecting .
19,516
public String getPackageCsv ( ) { stopCollecting ( ) ; StringBuilder buff = new StringBuilder ( ) ; buff . append ( "Package,Self" ) . append ( LINE_SEPARATOR ) ; for ( String k : new TreeSet < String > ( packages . keySet ( ) ) ) { int percent = 100 * packages . get ( k ) / Math . max ( total , 1 ) ; buff . append ( k...
Stop and obtain the self execution time of packages each as a row in CSV format .
19,517
public String getTopMethods ( int num ) { stopCollecting ( ) ; CountMap < String > selfms = new CountMap < String > ( selfMethods ) ; CountMap < String > stackms = new CountMap < String > ( stackMethods ) ; StringBuilder buff = new StringBuilder ( ) ; buff . append ( "Top methods over " ) . append ( time ) . append ( "...
Stop and obtain the top methods ordered by their self execution time .
19,518
public String getMethodCsv ( ) { stopCollecting ( ) ; StringBuilder buff = new StringBuilder ( ) ; buff . append ( "Method,Self" ) . append ( LINE_SEPARATOR ) ; for ( String k : new TreeSet < String > ( selfMethods . keySet ( ) ) ) { int percent = 100 * selfMethods . get ( k ) / Math . max ( total , 1 ) ; buff . append...
Stop and obtain the self execution time of methods each as a row in CSV format .
19,519
public String getTopLines ( int num ) { stopCollecting ( ) ; CountMap < String > ls = new CountMap < String > ( lines ) ; StringBuilder buff = new StringBuilder ( ) ; buff . append ( "Top lines over " ) . append ( time ) . append ( " ms (" ) . append ( pauseTime ) . append ( " ms paused), with " ) . append ( total ) . ...
Stop and obtain the top lines ordered by their execution time .
19,520
public void createIndex ( String idxName , String tblName , List < String > fldNames , IndexType idxType , Transaction tx ) { RecordFile rf = idxTi . open ( tx , true ) ; rf . insert ( ) ; rf . setVal ( ICAT_IDXNAME , new VarcharConstant ( idxName ) ) ; rf . setVal ( ICAT_TBLNAME , new VarcharConstant ( tblName ) ) ; r...
Creates an index of the specified type for the specified field . A unique ID is assigned to this index and its information is stored in the idxcat table .
19,521
public List < IndexInfo > getIndexInfo ( String tblName , String fldName , Transaction tx ) { if ( ! loadedTables . contains ( tblName ) ) { readFromFile ( tblName , tx ) ; } Map < String , List < IndexInfo > > iiMap = iiMapByTblAndFlds . get ( tblName ) ; if ( iiMap == null ) return Collections . emptyList ( ) ; List ...
Returns a map containing the index info for all indexes on the specified table .
19,522
public IndexInfo getIndexInfoByName ( String idxName , Transaction tx ) { IndexInfo ii = iiMapByIdxNames . get ( idxName ) ; if ( ii != null ) return ii ; String tblName = null ; List < String > fldNames = new LinkedList < String > ( ) ; IndexType idxType = null ; RecordFile rf = idxTi . open ( tx , true ) ; rf . befor...
Returns the requested index info object with the given index name .
19,523
public Index open ( Transaction tx ) { TableInfo ti = VanillaDb . catalogMgr ( ) . getTableInfo ( tblName , tx ) ; if ( ti == null ) throw new TableNotFoundException ( "table '" + tblName + "' is not defined in catalog." ) ; return Index . newInstance ( this , new SearchKeyType ( ti . schema ( ) , fldNames ) , tx ) ; }
Opens the index described by this object .
19,524
public Constant nextVal ( Type type ) { Constant val = pg . getVal ( currentPos , type ) ; currentPos += Page . size ( val ) ; return val ; }
Returns the next value of this log record .
19,525
public int getColumnType ( int column ) throws RemoteException { String fldname = getColumnName ( column ) ; return schema . type ( fldname ) . getSqlType ( ) ; }
Returns the type of the specified column . The method first finds the name of the field in that column and then looks up its type in the schema .
19,526
public int getColumnDisplaySize ( int column ) throws RemoteException { String fldname = getColumnName ( column ) ; Type fldtype = schema . type ( fldname ) ; if ( fldtype . isFixedSize ( ) ) return fldtype . maxSize ( ) * 8 / 5 ; return schema . type ( fldname ) . getArgument ( ) ; }
Returns the number of characters required to display the specified column .
19,527
public boolean next ( ) { if ( isLhsEmpty ) return false ; if ( idx . next ( ) ) { ts . moveToRecordId ( idx . getDataRecordId ( ) ) ; return true ; } else if ( ! ( isLhsEmpty = ! s . next ( ) ) ) { resetIndex ( ) ; return next ( ) ; } else return false ; }
Moves the scan to the next record . The method moves to the next index record if possible . Otherwise it moves to the next LHS record and the first index record . If there are no more LHS records the method returns false .
19,528
public Constant getVal ( String fldName ) { if ( ts . hasField ( fldName ) ) return ts . getVal ( fldName ) ; else return s . getVal ( fldName ) ; }
Returns the Constant value of the specified field .
19,529
public boolean hasField ( String fldName ) { return ts . hasField ( fldName ) || s . hasField ( fldName ) ; }
Returns true if the field is in the schema .
19,530
public void undo ( Transaction tx ) { LogSeqNum lsn = tx . recoveryMgr ( ) . logLogicalAbort ( this . txNum , this . lsn ) ; VanillaDb . logMgr ( ) . flush ( lsn ) ; }
Appends a Logical Abort Record to indicate the logical operation has be aborted
19,531
public Collection < String > getViewNamesByTable ( String tblName , Transaction tx ) { Collection < String > result = new LinkedList < String > ( ) ; TableInfo ti = tblMgr . getTableInfo ( VCAT , tx ) ; RecordFile rf = ti . open ( tx , true ) ; rf . beforeFirst ( ) ; while ( rf . next ( ) ) { Parser parser = new Parser...
We may have to come out a better method .
19,532
public boolean next ( ) { if ( ! moreGroups ) return false ; if ( aggFns != null ) for ( AggregationFn fn : aggFns ) fn . processFirst ( ss ) ; groupVal = new GroupValue ( ss , groupFlds ) ; while ( moreGroups = ss . next ( ) ) { GroupValue gv = new GroupValue ( ss , groupFlds ) ; if ( ! groupVal . equals ( gv ) ) brea...
Moves to the next group . The key of the group is determined by the group values at the current record . The method repeatedly reads underlying records until it encounters a record having a different key . The aggregation functions are called for each record in the group . The values of the grouping fields for the grou...
19,533
public Constant getVal ( String fldname ) { if ( groupFlds . contains ( fldname ) ) return groupVal . getVal ( fldname ) ; if ( aggFns != null ) for ( AggregationFn fn : aggFns ) if ( fn . fieldName ( ) . equals ( fldname ) ) return fn . value ( ) ; throw new RuntimeException ( "field " + fldname + " not found." ) ; }
Gets the Constant value of the specified field . If the field is a group field then its value can be obtained from the saved group value . Otherwise the value is obtained from the appropriate aggregation function .
19,534
public boolean hasField ( String fldname ) { if ( groupFlds . contains ( fldname ) ) return true ; if ( aggFns != null ) for ( AggregationFn fn : aggFns ) if ( fn . fieldName ( ) . equals ( fldname ) ) return true ; return false ; }
Returns true if the specified field is either a grouping field or created by an aggregation function .
19,535
void flushAll ( ) { for ( Buffer buff : bufferPool ) { try { buff . getExternalLock ( ) . lock ( ) ; buff . flush ( ) ; } finally { buff . getExternalLock ( ) . unlock ( ) ; } } }
Flushes all dirty buffers .
19,536
Buffer pin ( BlockId blk ) { synchronized ( prepareAnchor ( blk ) ) { Buffer buff = findExistingBuffer ( blk ) ; if ( buff == null ) { int lastReplacedBuff = this . lastReplacedBuff ; int currBlk = ( lastReplacedBuff + 1 ) % bufferPool . length ; while ( currBlk != lastReplacedBuff ) { buff = bufferPool [ currBlk ] ; i...
Pins a buffer to the specified block . If there is already a buffer assigned to that block then that buffer is used ; otherwise an unpinned buffer from the pool is chosen . Returns a null value if there are no available buffers .
19,537
void unpin ( Buffer ... buffs ) { for ( Buffer buff : buffs ) { try { buff . getExternalLock ( ) . lock ( ) ; buff . unpin ( ) ; if ( ! buff . isPinned ( ) ) numAvailable . incrementAndGet ( ) ; } finally { buff . getExternalLock ( ) . unlock ( ) ; } } }
Unpins the specified buffers .
19,538
public static void initializeSystem ( Transaction tx ) { tx . recoveryMgr ( ) . recoverSystem ( tx ) ; tx . bufferMgr ( ) . flushAll ( ) ; VanillaDb . logMgr ( ) . removeAndCreateNewLog ( ) ; new StartRecord ( tx . getTransactionNumber ( ) ) . writeToLog ( ) ; }
Goes through the log rolling back all uncompleted transactions . Flushes all modified blocks . Finally writes a quiescent checkpoint record to the log and flush it . This method should be called only during system startup before user transactions begin .
19,539
public void onTxCommit ( Transaction tx ) { if ( ! tx . isReadOnly ( ) && enableLogging ) { LogSeqNum lsn = new CommitRecord ( txNum ) . writeToLog ( ) ; VanillaDb . logMgr ( ) . flush ( lsn ) ; } }
Writes a commit record to the log and then flushes the log record to disk .
19,540
public void onTxRollback ( Transaction tx ) { if ( ! tx . isReadOnly ( ) && enableLogging ) { rollback ( tx ) ; LogSeqNum lsn = new RollbackRecord ( txNum ) . writeToLog ( ) ; VanillaDb . logMgr ( ) . flush ( lsn ) ; } }
Does the roll back process writes a rollback record to the log and flushes the log record to disk .
19,541
public LogSeqNum logSetVal ( Buffer buff , int offset , Constant newVal ) { if ( enableLogging ) { BlockId blk = buff . block ( ) ; if ( isTempBlock ( blk ) ) return null ; return new SetValueRecord ( txNum , blk , offset , buff . getVal ( offset , newVal . getType ( ) ) , newVal ) . writeToLog ( ) ; } else return null...
Writes a set value record to the log .
19,542
public LogSeqNum logLogicalAbort ( long txNum , LogSeqNum undoNextLSN ) { if ( enableLogging ) { return new LogicalAbortRecord ( txNum , undoNextLSN ) . writeToLog ( ) ; } else return null ; }
Writes a logical abort record into the log .
19,543
public void delete ( SearchKey key , RecordId dataRecordId , boolean doLogicalLogging ) { if ( tx . isReadOnly ( ) ) throw new UnsupportedOperationException ( ) ; search ( new SearchRange ( key ) , SearchPurpose . DELETE ) ; if ( doLogicalLogging ) tx . recoveryMgr ( ) . logLogicalStart ( ) ; leaf . delete ( dataRecord...
Deletes the specified index record . The method first traverses the directory to find the leaf page containing that record ; then it deletes the record from the page . F
19,544
public void close ( ) { if ( leaf != null ) { leaf . close ( ) ; leaf = null ; } dirsMayBeUpdated = null ; }
Closes the index by closing its open leaf page if necessary .
19,545
public synchronized TableStatInfo getTableStatInfo ( TableInfo ti , Transaction tx ) { if ( isRefreshStatOn ) { Integer c = updateCounts . get ( ti . tableName ( ) ) ; if ( c != null && c > REFRESH_THRESHOLD ) VanillaDb . taskMgr ( ) . runTask ( new StatisticsRefreshTask ( tx , ti . tableName ( ) ) ) ; } TableStatInfo ...
Returns the statistical information about the specified table .
19,546
public boolean hasNext ( ) { if ( ! isForward ) { currentRec = currentRec - pointerSize ; isForward = true ; } return currentRec > 0 || blk . number ( ) > 0 ; }
Determines if the current log record is the earliest record in the log file .
19,547
public BasicLogRecord next ( ) { if ( ! isForward ) { currentRec = currentRec - pointerSize ; isForward = true ; } if ( currentRec == 0 ) moveToNextBlock ( ) ; currentRec = ( Integer ) pg . getVal ( currentRec , INTEGER ) . asJavaVal ( ) ; return new BasicLogRecord ( pg , new LogSeqNum ( blk . number ( ) , currentRec +...
Moves to the next log record in reverse order . If the current log record is the earliest in its block then the method moves to the next oldest block and returns the log record from there .
19,548
private void moveToNextBlock ( ) { blk = new BlockId ( blk . fileName ( ) , blk . number ( ) - 1 ) ; pg . read ( blk ) ; currentRec = ( Integer ) pg . getVal ( LogMgr . LAST_POS , INTEGER ) . asJavaVal ( ) ; }
Moves to the next log block in reverse order and positions it after the last record in that block .
19,549
private void moveToPrevBlock ( ) { blk = new BlockId ( blk . fileName ( ) , blk . number ( ) + 1 ) ; pg . read ( blk ) ; currentRec = 0 + pointerSize ; }
Moves to the previous log block in reverse order and positions it after the last record in that block .
19,550
public Constant evaluate ( Record rec ) { return op . evaluate ( lhs , rhs , rec ) ; }
Evaluates the arithmetic expression by computing on the values from the record .
19,551
public boolean isApplicableTo ( Schema sch ) { return lhs . isApplicableTo ( sch ) && rhs . isApplicableTo ( sch ) ; }
Returns true if both expressions are in the specified schema .
19,552
public static void formatFileHeader ( String fileName , Transaction tx ) { tx . concurrencyMgr ( ) . modifyFile ( fileName ) ; if ( VanillaDb . fileMgr ( ) . size ( fileName ) == 0 ) { FileHeaderFormatter fhf = new FileHeaderFormatter ( ) ; Buffer buff = tx . bufferMgr ( ) . pinNew ( fileName , fhf ) ; tx . bufferMgr (...
Format the header of specified file .
19,553
public boolean next ( ) { if ( currentBlkNum == 0 && ! moveTo ( 1 ) ) return false ; while ( true ) { if ( rp . next ( ) ) return true ; if ( ! moveTo ( currentBlkNum + 1 ) ) return false ; } }
Moves to the next record . Returns false if there is no next record .
19,554
public void setVal ( String fldName , Constant val ) { if ( tx . isReadOnly ( ) && ! isTempTable ( ) ) throw new UnsupportedOperationException ( ) ; Type fldType = ti . schema ( ) . type ( fldName ) ; Constant v = val . castTo ( fldType ) ; if ( Page . size ( v ) > Page . maxSize ( fldType ) ) throw new SchemaIncompati...
Sets a value of the specified field in the current record . The type of the value must be equal to that of the specified field .
19,555
public void insert ( ) { if ( tx . isReadOnly ( ) && ! isTempTable ( ) ) throw new UnsupportedOperationException ( ) ; if ( ! isTempTable ( ) ) tx . concurrencyMgr ( ) . modifyFile ( fileName ) ; if ( fhp == null ) fhp = openHeaderForModification ( ) ; tx . recoveryMgr ( ) . logLogicalStart ( ) ; if ( fhp . hasDeletedS...
Inserts a new blank record somewhere in the file beginning at the current record . If the new record does not fit into an existing block then a new block is appended to the file .
19,556
public void insert ( RecordId rid ) { if ( tx . isReadOnly ( ) && ! isTempTable ( ) ) throw new UnsupportedOperationException ( ) ; if ( ! isTempTable ( ) ) tx . concurrencyMgr ( ) . modifyFile ( fileName ) ; if ( fhp == null ) fhp = openHeaderForModification ( ) ; tx . recoveryMgr ( ) . logLogicalStart ( ) ; moveToRec...
Inserts a record to a specified physical address .
19,557
public void moveToRecordId ( RecordId rid ) { moveTo ( rid . block ( ) . number ( ) ) ; rp . moveToId ( rid . id ( ) ) ; }
Positions the current record as indicated by the specified record ID .
19,558
public RecordId currentRecordId ( ) { int id = rp . currentId ( ) ; return new RecordId ( new BlockId ( fileName , currentBlkNum ) , id ) ; }
Returns the record ID of the current record .
19,559
public Operator operator ( String fldName ) { if ( lhs . isFieldName ( ) && lhs . asFieldName ( ) . equals ( fldName ) ) return op ; if ( rhs . isFieldName ( ) && rhs . asFieldName ( ) . equals ( fldName ) ) return op . complement ( ) ; return null ; }
Determines if this term is of the form F&lt ; OP&gt ; E where F is the specified field &lt ; OP&gt ; is an operator and E is an expression . If so the method returns &lt ; OP&gt ; . If not the method returns null .
19,560
public Constant oppositeConstant ( String fldName ) { if ( lhs . isFieldName ( ) && lhs . asFieldName ( ) . equals ( fldName ) && rhs . isConstant ( ) ) return rhs . asConstant ( ) ; if ( rhs . isFieldName ( ) && rhs . asFieldName ( ) . equals ( fldName ) && lhs . isConstant ( ) ) return lhs . asConstant ( ) ; return n...
Determines if this term is of the form F&lt ; OP&gt ; C where F is the specified field &lt ; OP&gt ; is an operator and C is some constant . If so the method returns C . If not the method returns null .
19,561
public String oppositeField ( String fldName ) { if ( lhs . isFieldName ( ) && lhs . asFieldName ( ) . equals ( fldName ) && rhs . isFieldName ( ) ) return rhs . asFieldName ( ) ; if ( rhs . isFieldName ( ) && rhs . asFieldName ( ) . equals ( fldName ) && lhs . isFieldName ( ) ) return lhs . asFieldName ( ) ; return nu...
Determines if this term is of the form F1&lt ; OP&gt ; F2 where F1 is the specified field &lt ; OP&gt ; is an operator and F2 is another field . If so the method returns F2 . If not the method returns null .
19,562
public synchronized Hosts putAllInRandomOrder ( String domain , String [ ] ips ) { Random random = new Random ( ) ; int index = ( int ) ( random . nextLong ( ) % ips . length ) ; if ( index < 0 ) { index += ips . length ; } LinkedList < String > ipList = new LinkedList < String > ( ) ; for ( int i = 0 ; i < ips . lengt...
avoid many server visit first ip in same time . s
19,563
public static String [ ] getByInternalAPI ( ) { try { Class < ? > resolverConfiguration = Class . forName ( "sun.net.dns.ResolverConfiguration" ) ; Method open = resolverConfiguration . getMethod ( "open" ) ; Method getNameservers = resolverConfiguration . getMethod ( "nameservers" ) ; Object instance = open . invoke (...
has 300s latency when system resolv change
19,564
public static IResolver defaultResolver ( ) { return new IResolver ( ) { public Record [ ] resolve ( Domain domain ) throws IOException { String [ ] addresses = defaultServer ( ) ; if ( addresses == null ) { throw new IOException ( "no dns server" ) ; } IResolver resolver = new Resolver ( InetAddress . getByName ( addr...
system ip would change
19,565
void writeAssocBean ( ) throws IOException { writingAssocBean = true ; origDestPackage = destPackage ; destPackage = destPackage + ".assoc" ; origShortName = shortName ; shortName = "Assoc" + shortName ; prepareAssocBeanImports ( ) ; writer = new Append ( createFileWriter ( ) ) ; writePackage ( ) ; writeImports ( ) ; w...
Write the type query assoc bean .
19,566
private void prepareAssocBeanImports ( ) { importTypes . remove ( DB ) ; importTypes . remove ( TQROOTBEAN ) ; importTypes . remove ( DATABASE ) ; importTypes . add ( TQASSOCBEAN ) ; if ( isEntity ( ) ) { importTypes . add ( TQPROPERTY ) ; importTypes . add ( origDestPackage + ".Q" + origShortName ) ; } Iterator < Stri...
Prepare the imports for writing assoc bean .
19,567
private void writeRootBeanConstructor ( ) throws IOException { writer . eol ( ) ; writer . append ( " /**" ) . eol ( ) ; writer . append ( " * Construct with a given Database." ) . eol ( ) ; writer . append ( " */" ) . eol ( ) ; writer . append ( " public Q%s(Database server) {" , shortName ) . eol ( ) ; writer ....
Write the constructors for root type query bean .
19,568
private void writeAssocBeanConstructor ( ) { writer . append ( " public Q%s(String name, R root) {" , shortName ) . eol ( ) ; writer . append ( " super(name, root);" ) . eol ( ) ; writer . append ( " }" ) . eol ( ) ; }
Write constructor for assoc type query bean .
19,569
private void writeFields ( ) throws IOException { for ( PropertyMeta property : properties ) { property . writeFieldDefn ( writer , shortName , writingAssocBean ) ; writer . eol ( ) ; } writer . eol ( ) ; }
Write all the fields .
19,570
private void writeClass ( ) { if ( writingAssocBean ) { writer . append ( "/**" ) . eol ( ) ; writer . append ( " * Association query bean for %s." , shortName ) . eol ( ) ; writer . append ( " * " ) . eol ( ) ; writer . append ( " * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS." ) . eol ( ) ; writer . append (...
Write the class definition .
19,571
private void writeImports ( ) { for ( String importType : importTypes ) { writer . append ( "import %s;" , importType ) . eol ( ) ; } writer . eol ( ) ; }
Write all the imports .
19,572
static String [ ] split ( String className ) { String [ ] result = new String [ 2 ] ; int startPos = className . lastIndexOf ( '.' ) ; if ( startPos == - 1 ) { result [ 1 ] = className ; return result ; } result [ 0 ] = className . substring ( 0 , startPos ) ; result [ 1 ] = className . substring ( startPos + 1 ) ; ret...
Split into package and class name .
19,573
static String shortName ( String className ) { int startPos = className . lastIndexOf ( '.' ) ; if ( startPos == - 1 ) { return className ; } return className . substring ( startPos + 1 ) ; }
Trim off package to return the simple class name .
19,574
Append append ( String format , Object ... args ) { return append ( String . format ( format , args ) ) ; }
Append content with formatted arguments .
19,575
< A extends Annotation > A findAnnotation ( TypeElement element , Class < A > anno ) { final A annotation = element . getAnnotation ( anno ) ; if ( annotation != null ) { return annotation ; } final TypeMirror typeMirror = element . getSuperclass ( ) ; if ( typeMirror . getKind ( ) == TypeKind . NONE ) { return null ; ...
Find the annotation searching the inheritance hierarchy .
19,576
private static boolean dbJsonField ( Element field ) { return ( field . getAnnotation ( DbJson . class ) != null || field . getAnnotation ( DbJsonB . class ) != null ) ; }
Return true if it is a DbJson field .
19,577
private PropertyType createPropertyTypeAssoc ( String fullName ) { String [ ] split = Split . split ( fullName ) ; String propertyName = "QAssoc" + split [ 1 ] ; String packageName = packageAppend ( split [ 0 ] , "query.assoc" ) ; return new PropertyTypeAssoc ( propertyName , packageName ) ; }
Create the QAssoc PropertyType .
19,578
private String packageAppend ( String origPackage , String suffix ) { if ( origPackage == null ) { return suffix ; } else { return origPackage + "." + suffix ; } }
Prepend the package to the suffix taking null into account .
19,579
JavaFileObject createWriter ( String factoryClassName , Element originatingElement ) throws IOException { return filer . createSourceFile ( factoryClassName , originatingElement ) ; }
Create a file writer for the given class name .
19,580
public static String printNode ( Node node , boolean prettyprint ) { StringWriter strw = new StringWriter ( ) ; new DOMWriter ( strw ) . setPrettyprint ( prettyprint ) . print ( node ) ; return strw . toString ( ) ; }
Print a node with explicit prettyprinting . The defaults for all other DOMWriter properties apply .
19,581
public static String resolve ( String normalized ) { StringBuilder builder = new StringBuilder ( ) ; int end = normalized . length ( ) ; int pos = normalized . indexOf ( '&' ) ; int last = 0 ; if ( pos == - 1 ) return normalized ; while ( pos != - 1 ) { String sub = normalized . subSequence ( last , pos ) . toString ( ...
Transforms an XML normalized string by resolving all predefined character and entity references
19,582
private static void invokeMethod ( final Object instance , final Method method , final Object [ ] args ) { final boolean accessability = method . isAccessible ( ) ; try { method . setAccessible ( true ) ; method . invoke ( instance , args ) ; } catch ( Exception e ) { InjectionException . rethrow ( e ) ; } finally { me...
Invokes method on object with specified arguments .
19,583
private static void setField ( final Object instance , final Field field , final Object value ) { final boolean accessability = field . isAccessible ( ) ; try { field . setAccessible ( true ) ; field . set ( instance , value ) ; } catch ( Exception e ) { InjectionException . rethrow ( e ) ; } finally { field . setAcces...
Sets field on object with specified value .
19,584
public void onEndpointInstantiated ( final Endpoint endpoint , final Invocation invocation ) { final Object _targetBean = this . getTargetBean ( invocation ) ; final Reference reference = endpoint . getInstanceProvider ( ) . getInstance ( _targetBean . getClass ( ) . getName ( ) ) ; final Object targetBean = reference ...
Injects resources on target bean and calls post construct method . Finally it registers target bean for predestroy phase .
19,585
private Object getTargetBean ( final Invocation invocation ) { final InvocationContext invocationContext = invocation . getInvocationContext ( ) ; return invocationContext . getTargetBean ( ) ; }
Returns endpoint instance associated with current invocation .
19,586
public static < A > A getRequiredAttachment ( final Deployment dep , final Class < A > key ) { final A value = dep . getAttachment ( key ) ; if ( value == null ) { throw Messages . MESSAGES . cannotFindAttachmentInDeployment ( key , dep . getSimpleName ( ) ) ; } return value ; }
Returns required attachment value from webservice deployment .
19,587
public static < A > A getOptionalAttachment ( final Deployment dep , final Class < A > key ) { return dep . getAttachment ( key ) ; }
Returns optional attachment value from webservice deployment or null if not bound .
19,588
protected void createConstructorDelegates ( ConstructorBodyCreator creator ) { ClassMetadataSource data = reflectionMetadataSource . getClassMetadata ( getSuperClass ( ) ) ; for ( Constructor < ? > constructor : data . getConstructors ( ) ) { if ( ! Modifier . isPrivate ( constructor . getModifiers ( ) ) ) { creator . ...
Adds constructors that delegate the the superclass constructor for all non - private constructors present on the superclass
19,589
public static void assertNoPrimitiveParameters ( final Method method , Class < ? extends Annotation > annotation ) { for ( Class < ? > type : method . getParameterTypes ( ) ) { if ( type . isPrimitive ( ) ) { throw annotation == null ? MESSAGES . methodCannotDeclarePrimitiveParameters ( method ) : MESSAGES . methodCann...
Asserts method don t declare primitive parameters .
19,590
public static void assertNotPrimitiveType ( final Field field , Class < ? extends Annotation > annotation ) { if ( field . getType ( ) . isPrimitive ( ) ) { throw annotation == null ? MESSAGES . fieldCannotBeOfPrimitiveOrVoidType ( field ) : MESSAGES . fieldCannotBeOfPrimitiveOrVoidType2 ( field , annotation ) ; } }
Asserts field is not of primitive type .
19,591
public static void assertNoParameters ( final Method method , Class < ? extends Annotation > annotation ) { if ( method . getParameterTypes ( ) . length != 0 ) { throw annotation == null ? MESSAGES . methodHasToHaveNoParameters ( method ) : MESSAGES . methodHasToHaveNoParameters2 ( method , annotation ) ; } }
Asserts method have no parameters .
19,592
public static void assertVoidReturnType ( final Method method , Class < ? extends Annotation > annotation ) { if ( ( ! method . getReturnType ( ) . equals ( Void . class ) ) && ( ! method . getReturnType ( ) . equals ( Void . TYPE ) ) ) { throw annotation == null ? MESSAGES . methodHasToReturnVoid ( method ) : MESSAGES...
Asserts method return void .
19,593
public static void assertNotVoidType ( final Field field , Class < ? extends Annotation > annotation ) { if ( ( field . getClass ( ) . equals ( Void . class ) ) && ( field . getClass ( ) . equals ( Void . TYPE ) ) ) { throw annotation == null ? MESSAGES . fieldCannotBeOfPrimitiveOrVoidType ( field ) : MESSAGES . fieldC...
Asserts field isn t of void type .
19,594
public static void assertNoCheckedExceptionsAreThrown ( final Method method , Class < ? extends Annotation > annotation ) { Class < ? > [ ] declaredExceptions = method . getExceptionTypes ( ) ; for ( int i = 0 ; i < declaredExceptions . length ; i ++ ) { Class < ? > exception = declaredExceptions [ i ] ; if ( ! excepti...
Asserts method don t throw checked exceptions .
19,595
public static void assertNotStatic ( final Method method , Class < ? extends Annotation > annotation ) { if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { throw annotation == null ? MESSAGES . methodCannotBeStatic ( method ) : MESSAGES . methodCannotBeStatic2 ( method , annotation ) ; } }
Asserts method is not static .
19,596
public static void assertNotStatic ( final Field field , Class < ? extends Annotation > annotation ) { if ( Modifier . isStatic ( field . getModifiers ( ) ) ) { throw annotation == null ? MESSAGES . fieldCannotBeStaticOrFinal ( field ) : MESSAGES . fieldCannotBeStaticOrFinal2 ( field , annotation ) ; } }
Asserts field is not static .
19,597
public static void assertNotFinal ( final Field field , Class < ? extends Annotation > annotation ) { if ( Modifier . isFinal ( field . getModifiers ( ) ) ) { throw annotation == null ? MESSAGES . fieldCannotBeStaticOrFinal ( field ) : MESSAGES . fieldCannotBeStaticOrFinal2 ( field , annotation ) ; } }
Asserts field is not final .
19,598
public static void assertOneParameter ( final Method method , Class < ? extends Annotation > annotation ) { if ( method . getParameterTypes ( ) . length != 1 ) { throw annotation == null ? MESSAGES . methodHasToDeclareExactlyOneParameter ( method ) : MESSAGES . methodHasToDeclareExactlyOneParameter2 ( method , annotati...
Asserts method have exactly one parameter .
19,599
public static void assertValidSetterName ( final Method method , Class < ? extends Annotation > annotation ) { final String methodName = method . getName ( ) ; final boolean correctMethodNameLength = methodName . length ( ) > 3 ; final boolean isSetterMethodName = methodName . startsWith ( "set" ) ; final boolean isUpp...
Asserts valid Java Beans setter method name .