idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
128,000
protected void storeBuffer ( ) { if ( buffer != null && buffer . length ( ) > insertStatement . length ( ) ) { if ( ! insertStatement . isEmpty ( ) ) { this . buffer . append ( ";" ) ; } bufferList . add ( buffer ) ; } this . buffer = new StringBuilder ( ) ; this . buffer . append ( insertStatement ) ; }
Finalizes the query in the currently used buffer and creates a new one . The finalized query will be added to the list of queries .
128,001
public void enableSrcPosCalculation ( ) { calculateSrcPositions = true ; final int len = sb . length ( ) ; ib = new ArrayList < Integer > ( len ) ; for ( int i = 0 ; i < len ; i ++ ) ib . add ( i ) ; }
Enables the Calculation of Src Position . The base for these position will be the aktual not the initial String wich is uses as Base for the SpanManager .
128,002
public Set < Category > getSiblings ( ) { Set < Category > siblings = new HashSet < Category > ( ) ; for ( Category parent : this . getParents ( ) ) { siblings . addAll ( parent . getChildren ( ) ) ; } siblings . remove ( this ) ; return siblings ; }
Returns the siblings of this category .
128,003
public void writeDiff ( final Task < Diff > diff , final int start ) throws IOException { int size = diff . size ( ) ; Diff d ; String previousRevision = null , currentRevision = null ; this . writer . write ( WikipediaXMLKeys . KEY_START_PAGE . getKeyword ( ) + "\r\n" ) ; ArticleInformation header = diff . getHeader (...
Writes a part of the diff task starting with the given element to the output using wikipedia xml notation .
128,004
public static boolean scan ( final char [ ] input ) { int surLow = 0xD800 ; int surHgh = 0xDFFF ; int end = input . length ; for ( int i = 0 ; i < end ; i ++ ) { if ( ( int ) input [ i ] >= surLow && input [ i ] <= surHgh ) { return true ; } } return false ; }
Returns whether a surrogate character was contained in the specified input .
128,005
public static char [ ] replace ( final char [ ] input ) { int surLow = 0xD800 ; int surHgh = 0xDFFF ; int end = input . length ; char [ ] output = new char [ end ] ; for ( int i = 0 ; i < end ; i ++ ) { if ( ( int ) input [ i ] >= surLow && input [ i ] <= surHgh ) { output [ i ] = '?' ; } else { output [ i ] = input [ ...
Replaces all surrogates characters with ? .
128,006
public static void logArticleRead ( final Logger logger , final Task < Revision > article , final long time , final long position ) { logger . logMessage ( Level . INFO , "Read article\t" + Time . toClock ( time ) + "\t" + article . toString ( ) + "\t" + position ) ; }
Logs the reading of an revision task .
128,007
public static void logErrorRetrieveArchive ( final Logger logger , final ArchiveDescription archive , final Error e ) { logger . logError ( Level . ERROR , "Error while accessing archive " + archive . toString ( ) , e ) ; }
Logs the occurance of an error while retrieving the input file .
128,008
public static void logExceptionRetrieveArchive ( final Logger logger , final ArchiveDescription archive , final Exception e ) { logger . logException ( Level . ERROR , "Exception while accessing archive " + archive . toString ( ) , e ) ; }
Logs the occurance of an exception while retrieving the input file .
128,009
public static void logNoMoreArticles ( final Logger logger , final ArchiveDescription archive ) { logger . logMessage ( Level . INFO , "Archive " + archive . toString ( ) + " contains no more articles" ) ; }
Logs that no more articles are available .
128,010
public static void logReadTaskException ( final Logger logger , final Task < Revision > task , final Exception e ) { if ( task != null ) { logger . logException ( Level . ERROR , "Error while reading a task: " + task . toString ( ) , e ) ; } else { logger . logException ( Level . ERROR , "Error while reading an unknown...
Logs an occurance of an exception while reading a task .
128,011
public static void logStatus ( final Logger logger , final ArticleReaderInterface articleReader , final long startTime , final long sleepingTime , final long workingTime ) { String message = "Consumer-Status-Report [" + Time . toClock ( System . currentTimeMillis ( ) - startTime ) + "]" ; if ( articleReader != null ) {...
Logs the status of the article consumer .
128,012
public static void logTaskReaderException ( final Logger logger , final ArticleReaderException e ) { logger . logException ( Level . ERROR , "TaskReaderException" , e ) ; }
Logs the occurance of an ArticleReaderException .
128,013
public static void logDiffProcessed ( final Logger logger , final Task < Diff > diff , final long time ) { logger . logMessage ( Level . INFO , "Generated Entry\t" + Time . toClock ( time ) + "\t" + diff . toString ( ) ) ; }
Logs the processing of a diff task .
128,014
public static void logFileCreation ( final Logger logger , final String path ) { logger . logMessage ( Level . INFO , "New File created:\t" + path ) ; }
Logs the creation of an output file .
128,015
public static void logReadTaskOutOfMemoryError ( final Logger logger , final Task < Diff > task , final OutOfMemoryError e ) { if ( task != null ) { logger . logError ( Level . WARN , "Error while reading a task: " + task . toString ( ) , e ) ; } else { logger . logError ( Level . WARN , "Error while reading an unknown...
Logs the occurrence of an OutOfMemoryError while reading a task .
128,016
public static void logSQLConsumerException ( final Logger logger , final SQLConsumerException e ) { logger . logException ( Level . ERROR , "SQLConsumerException" , e ) ; }
Logs the occurrence of an SqlConsumerException .
128,017
public static void logStatus ( final Logger logger , final long time , final int articleConsumer , final int diffConsumer , final int sqlConsumer , final boolean archiveState , final boolean articleState , final boolean diffState ) { logger . logMessage ( Level . INFO , "\r\nDiffTool-Status-Report [" + Time . toClock (...
Logs the status of the diff tool .
128,018
public static void logShutdown ( final Logger logger , final long endTime ) { logger . logMessage ( Level . INFO , "DiffTool initiates SHUTDOWN\t" + Time . toClock ( endTime ) ) ; }
Logs the shutdown of the logger .
128,019
public void writeEndPage ( ) throws IOException { writer . openElement ( "document" ) ; writer . textElement ( "id" , Integer . toString ( _page . Id ) ) ; writer . textElement ( "group" , "0" ) ; writer . textElement ( "timestamp" , formatTimestamp ( _rev . Timestamp ) ) ; writer . textElement ( "title" , _page . Titl...
FIXME What s the group number here do? FIXME preprocess the text to strip some formatting?
128,020
private static boolean checkArgs ( String [ ] args ) { boolean result = ( args . length > 0 ) ; if ( ! result ) { System . out . println ( "Usage: java -jar JWPLTimeMachine.jar <config-file>" ) ; } return result ; }
Checks given arguments
128,021
public Title getTitle ( int pageId ) throws WikiApiException { Session session = this . __getHibernateSession ( ) ; session . beginTransaction ( ) ; Object returnValue = session . createNativeQuery ( "select p.name from PageMapLine as p where p.pageId= :pId" ) . setParameter ( "pId" , pageId , IntegerType . INSTANCE ) ...
Gets the title for a given pageId .
128,022
public Page getArticleForDiscussionPage ( Page discussionPage ) throws WikiApiException { if ( discussionPage . isDiscussion ( ) ) { String title = discussionPage . getTitle ( ) . getPlainTitle ( ) . replaceAll ( WikiConstants . DISCUSSION_PREFIX , "" ) ; if ( title . contains ( "/" ) ) { title = title . split ( "/" ) ...
Returns the article page for a given discussion page .
128,023
public Page getDiscussionPage ( Page articlePage ) throws WikiApiException { String articleTitle = articlePage . getTitle ( ) . toString ( ) ; if ( articleTitle . startsWith ( WikiConstants . DISCUSSION_PREFIX ) ) { return articlePage ; } else { return new Page ( this , WikiConstants . DISCUSSION_PREFIX + articleTitle ...
Gets the discussion page for the given article page The provided page must not be a discussion page
128,024
protected Map < Page , Double > getSimilarPages ( String pPattern , int pSize ) throws WikiApiException { Title title = new Title ( pPattern ) ; String pattern = title . getWikiStyleTitle ( ) ; Map < Page , Double > pageMap = new HashMap < Page , Double > ( ) ; Map < Integer , Double > distanceMap = new HashMap < Integ...
Gets the pages or redirects with a name similar to the pattern . Calling this method is quite costly as similarity is computed for all names .
128,025
public Category getCategory ( int pageId ) { long hibernateId = __getCategoryHibernateId ( pageId ) ; if ( hibernateId == - 1 ) { return null ; } try { Category cat = new Category ( this , hibernateId ) ; return cat ; } catch ( WikiPageNotFoundException e ) { return null ; } }
Gets the category for a given pageId .
128,026
protected Set < Integer > __getCategories ( ) { Session session = this . __getHibernateSession ( ) ; session . beginTransaction ( ) ; List < Integer > idList = session . createQuery ( "select cat.pageId from Category as cat" , Integer . class ) . list ( ) ; Set < Integer > categorySet = new HashSet < Integer > ( idList...
Protected method that is much faster than the public version but exposes too much implementation details . Get a set with all category pageIDs . Returning all category objects is much too expensive .
128,027
public boolean existsPage ( String title ) { if ( title == null || title . length ( ) == 0 ) { return false ; } Title t ; try { t = new Title ( title ) ; } catch ( WikiTitleParsingException e ) { return false ; } String encodedTitle = t . getWikiStyleTitle ( ) ; Session session = this . __getHibernateSession ( ) ; sess...
Tests whether a page or redirect with the given title exists . Trying to retrieve a page that does not exist in Wikipedia throws an exception . You may catch the exception or use this test depending on your task .
128,028
public boolean existsPage ( int pageID ) { if ( pageID < 0 ) { return false ; } Session session = this . __getHibernateSession ( ) ; session . beginTransaction ( ) ; List returnList = session . createNativeQuery ( "select p.id from PageMapLine as p where p.pageID = :pageId" ) . setParameter ( "pageId" , pageID , Intege...
Tests whether a page with the given pageID exists . Trying to retrieve a pageID that does not exist in Wikipedia throws an exception .
128,029
protected long __getPageHibernateId ( int pageID ) { long hibernateID = - 1 ; if ( idMapPages . containsKey ( pageID ) ) { return idMapPages . get ( pageID ) ; } Session session = this . __getHibernateSession ( ) ; session . beginTransaction ( ) ; Object retObjectPage = session . createQuery ( "select page.id from Page...
Get the hibernate ID to a given pageID of a page . We need different methods for pages and categories here as a page and a category can have the same ID .
128,030
public String getWikipediaId ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( this . getDatabaseConfiguration ( ) . getHost ( ) ) ; sb . append ( "_" ) ; sb . append ( this . getDatabaseConfiguration ( ) . getDatabase ( ) ) ; sb . append ( "_" ) ; sb . append ( this . getDatabaseConfiguration ( ) . getLan...
The ID consists of the host the database and the language . This should be unique in most cases .
128,031
private byte [ ] encode ( final RevisionCodecData codecData , final Diff diff ) throws UnsupportedEncodingException , EncodingException { this . data = new BitWriter ( codecData . totalSizeInBits ( ) ) ; encodeCodecData ( codecData ) ; DiffPart part ; Iterator < DiffPart > partIt = diff . iterator ( ) ; while ( partIt ...
Creates the binary encoding of the diff while using the codec information .
128,032
private void encodeCodecData ( final RevisionCodecData codecData ) throws EncodingException { this . codecData = codecData ; data . writeBit ( 0 ) ; data . writeBit ( 0 ) ; data . writeBit ( 0 ) ; this . data . writeValue ( 5 , codecData . getBlocksizeS ( ) ) ; this . data . writeValue ( 5 , codecData . getBlocksizeE (...
Encodes the codecData .
128,033
private void encodeCut ( final DiffPart part ) throws EncodingException { data . writeBit ( 1 ) ; data . writeBit ( 0 ) ; data . writeBit ( 1 ) ; data . writeValue ( codecData . getBlocksizeS ( ) , part . getStart ( ) ) ; data . writeValue ( codecData . getBlocksizeE ( ) , part . getLength ( ) ) ; data . writeValue ( c...
Encodes a Cut operation .
128,034
private void encodeDelete ( final DiffPart part ) throws EncodingException { data . writeBit ( 0 ) ; data . writeBit ( 1 ) ; data . writeBit ( 1 ) ; data . writeValue ( codecData . getBlocksizeS ( ) , part . getStart ( ) ) ; data . writeValue ( codecData . getBlocksizeE ( ) , part . getLength ( ) ) ; data . writeFillBi...
Encodes a Delete operation .
128,035
private void encodeFullRevisionUncompressed ( final DiffPart part ) throws UnsupportedEncodingException , EncodingException { data . writeBit ( 0 ) ; data . writeBit ( 0 ) ; data . writeBit ( 1 ) ; String text = part . getText ( ) ; byte [ ] bText = text . getBytes ( WIKIPEDIA_ENCODING ) ; data . writeValue ( codecData...
Encodes a FullRevision operation .
128,036
private void encodePaste ( final DiffPart part ) throws EncodingException { data . writeBit ( 1 ) ; data . writeBit ( 1 ) ; data . writeBit ( 0 ) ; data . writeValue ( codecData . getBlocksizeS ( ) , part . getStart ( ) ) ; data . writeValue ( codecData . getBlocksizeB ( ) , Integer . parseInt ( part . getText ( ) ) ) ...
Encodes a Paste operation .
128,037
public void readDump ( ) throws IOException { try { SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; factory . setFeature ( XMLConstants . FEATURE_SECURE_PROCESSING , false ) ; SAXParser parser = factory . newSAXParser ( ) ; parser . parse ( input , this ) ; } catch ( ParserConfigurationException e ) { t...
Reads through the entire XML dump on the input stream sending events to the DumpWriter as it goes . May throw exceptions on invalid input or due to problems with the output .
128,038
public int compareTo ( final ChronoIndexData info ) { long value ; if ( chronoSort ) { value = this . time - info . time ; } else { value = this . revisionCounter - info . revisionCounter ; } if ( value == 0 ) { return 0 ; } else if ( value > 0 ) { return 1 ; } else { return - 1 ; } }
Compares this ChronoInfo to the given info .
128,039
public Iterable < Page > getPagesContainingTemplateNames ( List < String > templateNames ) throws WikiApiException { return getFilteredPages ( templateNames , true ) ; }
Return an iterable containing all pages that contain a template the name of which equals any of the given Strings .
128,040
public Iterable < Page > getPagesNotContainingTemplateNames ( List < String > templateNames ) throws WikiApiException { return getFilteredPages ( templateNames , false ) ; }
Return an iterable containing all pages that do NOT contain a template the name of which equals of the given Strings .
128,041
public List < Integer > getRevisionsWithFirstTemplateAppearance ( String templateName ) throws WikiApiException { System . err . println ( "Note: This function call demands parsing several revision for each page. A method using the revision-template index is currently under construction." ) ; templateName = templateNam...
This method first creates a list of pages containing templates that equal any of the provided Strings . It then returns a list of revision ids of the revisions in which the respective templates first appeared .
128,042
public List < Integer > getIdsOfPagesThatEverContainedTemplateNames ( List < String > templateNames ) throws WikiApiException { if ( revApi == null ) { revApi = new RevisionApi ( wiki . getDatabaseConfiguration ( ) ) ; } Set < Integer > pageIdSet = new HashSet < Integer > ( ) ; List < Integer > revsWithTemplate = getRe...
Returns the ids of all pages that ever contained any of the given template names in the history of their existence .
128,043
public List < Integer > getIdsOfPagesThatEverContainedTemplateFragments ( List < String > templateFragments ) throws WikiApiException { if ( revApi == null ) { revApi = new RevisionApi ( wiki . getDatabaseConfiguration ( ) ) ; } Set < Integer > pageIdSet = new HashSet < Integer > ( ) ; List < Integer > revsWithTemplate...
Returns the ids of all pages that ever contained any template that started with any of the given template fragments
128,044
public List < Integer > getPageIdsContainingTemplateNames ( List < String > templateNames ) throws WikiApiException { return getFilteredPageIds ( templateNames , true ) ; }
Returns a list containing the ids of all pages that contain a template the name of which equals any of the given Strings .
128,045
public List < Integer > getPageIdsNotContainingTemplateNames ( List < String > templateNames ) throws WikiApiException { return getFilteredPageIds ( templateNames , false ) ; }
Returns a list containing the ids of all pages that do not contain a template the name of which equals any of the given Strings .
128,046
public List < Integer > getRevisionIdsContainingTemplateNames ( List < String > templateNames ) throws WikiApiException { return getFilteredRevisionIds ( templateNames , true ) ; }
Returns a list containing the ids of all revisions that contain a template the name of which equals any of the given Strings .
128,047
public List < Integer > getRevisionIdsNotContainingTemplateNames ( List < String > templateNames ) throws WikiApiException { return getFilteredRevisionIds ( templateNames , false ) ; }
Returns a list containing the ids of all revisions that do not contain a template the name of which equals any of the given Strings .
128,048
public List < String > getTemplateNamesFromRevision ( int revid ) throws WikiApiException { if ( revid < 1 ) { throw new WikiApiException ( "Revision ID must be > 0" ) ; } try { PreparedStatement statement = null ; ResultSet result = null ; List < String > templateNames = new LinkedList < String > ( ) ; try { statement...
Returns the names of all templates contained in the specified revision .
128,049
public boolean revisionContainsTemplateFragment ( int revId , String templateFragment ) throws WikiApiException { List < String > tplList = getTemplateNamesFromRevision ( revId ) ; for ( String tpl : tplList ) { if ( tpl . toLowerCase ( ) . startsWith ( templateFragment . toLowerCase ( ) ) ) { return true ; } } return ...
Determines whether a given revision contains a template starting witht the given fragment
128,050
public boolean tableExists ( String table ) throws SQLException { PreparedStatement statement = null ; ResultSet result = null ; try { statement = this . connection . prepareStatement ( "SHOW TABLES;" ) ; result = execute ( statement ) ; if ( result == null ) { return false ; } boolean found = false ; while ( result . ...
Checks if a specific table exists
128,051
public void add ( final ChronoStorageBlock block ) { int revCount = block . getRevisionCounter ( ) ; this . size += block . length ( ) ; if ( first == null ) { first = block ; } else { ChronoStorageBlock previous = null , current = first ; do { if ( revCount < current . getRevisionCounter ( ) ) { block . setCounterPrev...
Adds a ChonoStorageBlock to this chrono full revision object .
128,052
public Revision getNearest ( final int revisionCounter ) { if ( first != null ) { ChronoStorageBlock previous = null , current = first ; while ( current != null && current . getRevisionCounter ( ) <= revisionCounter ) { previous = current ; current = current . getCounterNext ( ) ; } return previous . getRev ( ) ; } ret...
Returns the nearest available revision to the specified revision counter .
128,053
public long clean ( final int currentRevisionIndex , final int revisionIndex ) { if ( first == null ) { return 0 ; } else if ( this . set . isEmpty ( ) ) { this . first = null ; this . size = 0 ; return 0 ; } ChronoStorageBlock next , prev , current = first ; boolean remove ; do { remove = false ; if ( current . isDeli...
Reduces the storage space .
128,054
public static HashSet < String > createSetFromProperty ( String property ) { HashSet < String > properties = new HashSet < String > ( ) ; if ( property != null && ! property . equals ( "null" ) ) { Pattern params = Pattern . compile ( "([\\w]+)[;]*" ) ; Matcher matcher = params . matcher ( property . trim ( ) ) ; while...
Parses property string into HashSet
128,055
private boolean notAllowedStart ( String startTag ) { errorState = errorState && startElements . containsKey ( startTag ) && forbiddenIdStartElements . containsKey ( startTag ) ; return errorState ; }
If error with wrong id tag occurs the errorState flag will be set . In this case some start tags have to be ignored .
128,056
private boolean notAllowedEnd ( String endTag ) { errorState = errorState && endElements . containsKey ( endTag ) && forbiddenIdEndElements . containsKey ( endTag ) ; return errorState ; }
If error with wrong id tag occurs the errorState flag will be set . In this case some end tags have to be ignored .
128,057
private List < String > sentenceSplit ( String str ) { BreakIterator iterator = BreakIterator . getSentenceInstance ( Locale . US ) ; iterator . setText ( str ) ; int start = iterator . first ( ) ; List < String > sentences = new ArrayList < String > ( ) ; for ( int end = iterator . next ( ) ; end != BreakIterator . DO...
Splits a String into sentences using the BreakIterator with US locale
128,058
private String listToString ( List < String > stringList ) { StringBuilder concat = new StringBuilder ( ) ; for ( String str : stringList ) { concat . append ( str ) ; concat . append ( System . getProperty ( "line.separator" ) ) ; } return concat . toString ( ) ; }
Concatenates a list of Strings to one line - separated String
128,059
private String normalize ( String str ) { str = StringUtils . trimToEmpty ( str ) ; str = StringUtils . normalizeSpace ( str ) ; str = str . replaceAll ( "\\s+(?=[.!,\\?;:])" , "" ) ; return str ; }
Normalizes the Strings in the TextPair . This mainly deals with whitespace - issues . Other normalizations can be included .
128,060
public Revision getDiscussionRevisionForArticleRevision ( int revisionId ) throws WikiApiException , WikiPageNotFoundException { Revision rev = revApi . getRevision ( revisionId ) ; Timestamp revTime = rev . getTimeStamp ( ) ; Page discussion = wiki . getDiscussionPage ( rev . getArticleID ( ) ) ; List < Timestamp > di...
For a given article revision the method returns the revision of the article discussion page which was current at the time the revision was created .
128,061
public List < Revision > getDiscussionArchiveRevisionsForArticleRevision ( int revisionId ) throws WikiApiException , WikiPageNotFoundException { List < Revision > result = new LinkedList < Revision > ( ) ; Revision rev = revApi . getRevision ( revisionId ) ; Timestamp revTime = rev . getTimeStamp ( ) ; Iterable < Page...
For a given article revision the method returns the revisions of the archived article discussion pages which were available at the time of the article revision
128,062
public static String getRedirectDestination ( String pageText ) { String redirectString = null ; try { String regex = "\\[\\[\\s*(.+?)\\s*]]" ; Pattern pattern = Pattern . compile ( regex ) ; Matcher matcher = pattern . matcher ( pageText ) ; if ( matcher . find ( ) ) { redirectString = matcher . group ( 1 ) ; } if ( r...
Return the redirect destination of according to wikimedia syntax .
128,063
public void add ( final ConfigItem item ) { failed = failed || item . getType ( ) == ConfigItemTypes . ERROR ; this . list . add ( item ) ; }
Adds a configuration item to the list .
128,064
public Object getValueAt ( final int row , final int column ) { ConfigItem item = this . list . get ( row ) ; switch ( column ) { case 0 : return item . getType ( ) ; case 1 : return item . getKey ( ) ; case 2 : return item . getMessage ( ) ; } return null ; }
Returns the value at the specified column of the specified row .
128,065
private String generatePageSQLStatement ( boolean tableExists , Map < String , Set < Integer > > dataSourceToUse ) { StringBuffer output = new StringBuffer ( ) ; output . append ( "CREATE TABLE IF NOT EXISTS " + GeneratorConstants . TABLE_TPLID_PAGEID + " (" + "templateId INTEGER UNSIGNED NOT NULL," + "pageId INTEGER U...
Generate sql statement for table template id - > page id
128,066
private String generateTemplateIdSQLStatement ( boolean tableExists ) { StringBuffer output = new StringBuffer ( ) ; output . append ( "CREATE TABLE IF NOT EXISTS " + GeneratorConstants . TABLE_TPLID_TPLNAME + " (" + "templateId INTEGER NOT NULL AUTO_INCREMENT," + "templateName MEDIUMTEXT NOT NULL, " + "PRIMARY KEY(tem...
Generate sql statement for table template id - > template name
128,067
private String generateRevisionSQLStatement ( boolean tableExists , Map < String , Set < Integer > > dataSourceToUse ) { StringBuffer output = new StringBuffer ( ) ; output . append ( "CREATE TABLE IF NOT EXISTS " + GeneratorConstants . TABLE_TPLID_REVISIONID + " (" + "templateId INTEGER UNSIGNED NOT NULL," + "revision...
Generate sql statement for table template id - > revision id
128,068
void writeSQL ( boolean revTableExists , boolean pageTableExists , GeneratorMode mode ) { try ( Writer writer = new BufferedWriter ( new OutputStreamWriter ( new BufferedOutputStream ( new FileOutputStream ( outputPath ) ) , charset ) ) ) { StringBuilder dataToDump = new StringBuilder ( ) ; dataToDump . append ( genera...
Generate and write sql statements to output file
128,069
public static ModifyType detectModifyType ( SQLiteModelMethod method , JQLType jqlType ) { SQLiteDaoDefinition daoDefinition = method . getParent ( ) ; SQLiteEntity entity = method . getEntity ( ) ; ModifyType updateResultType = null ; int count = 0 ; for ( Pair < String , TypeName > param : method . getParameters ( ) ...
Detect method type .
128,070
public static void checkContentProviderVarsAndArguments ( final SQLiteModelMethod method , List < JQLPlaceHolder > placeHolders ) { AssertKripton . assertTrue ( placeHolders . size ( ) == method . contentProviderUriVariables . size ( ) , "In '%s.%s' content provider URI path variables and variables used in where condit...
Check content provider vars and arguments .
128,071
static void generateInitForDynamicWhereVariables ( SQLiteModelMethod method , MethodSpec . Builder methodBuilder , String dynamiWhereName , String dynamicWhereArgsName ) { GenerationPartMarks . begin ( methodBuilder , GenerationPartMarks . CODE_001 ) ; if ( method . hasDynamicWhereConditions ( ) ) { methodBuilder . add...
Generate init for dynamic where variables .
128,072
public static void generateLogForModifiers ( final SQLiteModelMethod method , MethodSpec . Builder methodBuilder ) { JQLChecker jqlChecker = JQLChecker . getInstance ( ) ; final One < Boolean > usedInWhere = new One < Boolean > ( false ) ; methodBuilder . addCode ( "\n// display log\n" ) ; String sqlForLog = jqlChecker...
generate sql log .
128,073
public static void generate ( Elements elementUtils , Filer filer , SQLiteDatabaseSchema schema , Set < GeneratedTypeElement > generatedEntities ) throws Exception { BindTableGenerator visitor = new BindTableGenerator ( elementUtils , filer , schema ) ; List < SQLiteEntity > orderedEntities = BindDataSourceBuilder . or...
Generate table for entities .
128,074
public static ClassName tableClassName ( SQLiteDaoDefinition dao , SQLiteEntity entity ) { String entityName = BindDataSourceSubProcessor . generateEntityQualifiedName ( dao , entity ) ; return TypeUtility . className ( entityName + SUFFIX ) ; }
Table class name .
128,075
private void generateColumnsArray ( Finder < SQLProperty > entity ) { Builder sp = FieldSpec . builder ( ArrayTypeName . of ( String . class ) , "COLUMNS" , Modifier . STATIC , Modifier . PRIVATE , Modifier . FINAL ) ; String s = "" ; StringBuilder buffer = new StringBuilder ( ) ; for ( SQLProperty property : entity . ...
generate columns array .
128,076
public static Triple < String , String , String > buildIndexes ( final GeneratedTypeElement entity , boolean unique , int counter ) { Triple < String , String , String > result = new Triple < > ( ) ; result . value0 = "" ; result . value1 = "" ; result . value2 = "" ; List < String > indexes = entity . index ; String u...
A generated element can have only a primary key and two FK .
128,077
static void generateModifyQueryCommonPart ( SQLiteModelMethod method , TypeSpec . Builder classBuilder , MethodSpec . Builder methodBuilder ) { boolean updateMode = ( method . jql . operationType == JQLType . UPDATE ) ; SqlModifyBuilder . generateInitForDynamicWhereVariables ( method , methodBuilder , method . dynamicW...
Generate modify query common part .
128,078
public void buildReturnCode ( MethodSpec . Builder methodBuilder , boolean updateMode , SQLiteModelMethod method , TypeName returnType ) { if ( returnType == TypeName . VOID ) { } else if ( isTypeIncludedIn ( returnType , Boolean . TYPE , Boolean . class ) ) { methodBuilder . addJavadoc ( "\n" ) ; if ( updateMode ) met...
Builds the return code .
128,079
private String extractSQLForJavaDoc ( final SQLiteModelMethod method ) { final One < Boolean > usedInWhere = new One < > ( false ) ; String sqlForJavaDoc = JQLChecker . getInstance ( ) . replace ( method , method . jql , new JQLReplacerListenerImpl ( method ) { public String onColumnNameToUpdate ( String columnName ) {...
Extract SQL for java doc .
128,080
protected static String generateTag ( ) { StackTraceElement [ ] elements = Thread . currentThread ( ) . getStackTrace ( ) ; String currentPath = elements [ 4 ] . getClassName ( ) ; String method = elements [ 4 ] . getMethodName ( ) ; int line = elements [ 4 ] . getLineNumber ( ) ; String tag = currentPath + ", " + meth...
generate tag .
128,081
@ SuppressWarnings ( "unchecked" ) static < E , M extends BinderMapper < E > > M getMapper ( Class < E > cls ) { M mapper = ( M ) OBJECT_MAPPERS . get ( cls ) ; if ( mapper == null ) { String beanClassName = cls . getName ( ) ; String mapperClassName = cls . getName ( ) + KriptonBinder . MAPPER_CLASS_SUFFIX ; try { Cla...
Gets the mapper .
128,082
public boolean processSecondRound ( Set < ? extends TypeElement > annotations , RoundEnvironment roundEnv ) { for ( SQLiteDatabaseSchema schema : schemas ) { for ( String daoName : schema . getDaoNameSet ( ) ) { if ( globalDaoGenerated . contains ( daoName ) ) { createSQLEntityFromDao ( schema , schema . getElement ( )...
Process second round .
128,083
public boolean analyzeSecondRound ( Set < ? extends TypeElement > annotations , RoundEnvironment roundEnv ) { parseBindType ( roundEnv ) ; for ( Element item : roundEnv . getElementsAnnotatedWith ( BindSqlType . class ) ) { if ( item . getKind ( ) != ElementKind . CLASS ) { String msg = String . format ( "%s %s, only c...
Analyze second round .
128,084
public boolean analyzeRound ( Set < ? extends TypeElement > annotations , RoundEnvironment roundEnv ) { parseBindType ( roundEnv ) ; for ( Element item : roundEnv . getElementsAnnotatedWith ( BindSqlType . class ) ) { if ( item . getKind ( ) != ElementKind . CLASS ) { String msg = String . format ( "%s %s, only class c...
Analyze round .
128,085
private void analyzeForeignKey ( SQLiteDatabaseSchema schema ) { for ( SQLiteEntity entity : schema . getEntities ( ) ) { for ( SQLProperty property : entity . getCollection ( ) ) { if ( property . isForeignKey ( ) ) { SQLiteEntity reference = schema . getEntity ( property . foreignParentClassName ) ; AssertKripton . a...
Analyze foreign key .
128,086
private boolean isGeneratedEntity ( String fullName ) { for ( GeneratedTypeElement item : this . generatedEntities ) { if ( item . getQualifiedName ( ) . equals ( fullName ) ) { return true ; } } return false ; }
Checks if is generated entity .
128,087
private void checkForeignKeyForM2M ( SQLiteDatabaseSchema currentSchema , final SQLiteEntity currentEntity , ClassName m2mEntity ) { if ( m2mEntity != null ) { SQLiteEntity temp = currentSchema . getEntity ( m2mEntity . toString ( ) ) ; AssertKripton . asserTrueOrForeignKeyNotFound ( currentEntity . referedEntities . c...
Check foreign key for M 2 M .
128,088
protected void createSQLDaoDefinition ( SQLiteDatabaseSchema schema , final Map < String , TypeElement > globalBeanElements , final Map < String , TypeElement > globalDaoElements , String daoItem ) { Element daoElement = globalDaoElements . get ( daoItem ) ; if ( daoElement . getKind ( ) != ElementKind . INTERFACE ) { ...
Create DAO definition .
128,089
private void fillMethods ( final SQLiteDaoDefinition currentDaoDefinition , Element daoElement ) { final One < Boolean > methodWithAnnotation = new One < Boolean > ( false ) ; SqlBuilderHelper . forEachMethods ( ( TypeElement ) daoElement , new MethodFoundListener ( ) { public void onMethod ( ExecutableElement element ...
Fill methods .
128,090
public static String generateEntityName ( SQLiteDaoDefinition dao , SQLiteEntity entity ) { String entityName ; if ( entity == null ) { M2MEntity m2mEntity = M2MEntity . extractEntityManagedByDAO ( dao . getElement ( ) ) ; entityName = m2mEntity . getSimpleName ( ) ; } else { entityName = entity . getSimpleName ( ) ; }...
dao or entity can be null .
128,091
public static String generateEntityQualifiedName ( SQLiteDaoDefinition dao , SQLiteEntity entity ) { String entityName ; if ( entity == null ) { M2MEntity m2mEntity = M2MEntity . extractEntityManagedByDAO ( dao . getElement ( ) ) ; entityName = m2mEntity . getQualifiedName ( ) ; } else { entityName = entity . getName (...
Generate entity qualified name .
128,092
public static void generate ( Elements elementUtils , Filer filer , SQLiteDatabaseSchema schema ) throws Exception { BindContentProviderBuilder visitorDao = new BindContentProviderBuilder ( elementUtils , filer , schema ) ; visitorDao . build ( elementUtils , filer , schema ) ; }
Generate content provider .
128,093
private void generateURIForMethod ( SQLiteDatabaseSchema schema , List < FieldSpec > listFieldAlias , Set < String > alreadyUsedName , Converter < String , String > format , Pair < String , ContentEntry > entry , SQLiteModelMethod method ) { if ( method == null ) return ; String alias = "URI_" + entry . value1 . pathCo...
Generate URI for method .
128,094
private void defineJavadocForContentUri ( MethodSpec . Builder builder , SQLiteModelMethod method ) { String contentUri = method . contentProviderUri ( ) . replace ( "*" , "[*]" ) ; classBuilder . addJavadoc ( "<tr><td><pre>$L</pre></td><td>{@link $LImpl#$L}</td></tr>\n" , contentUri , method . getParent ( ) . getName ...
Define javadoc for content uri .
128,095
private void generateDelete ( SQLiteDatabaseSchema schema ) { MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "delete" ) . addModifiers ( Modifier . PUBLIC ) . addAnnotation ( Override . class ) . returns ( Integer . TYPE ) ; methodBuilder . addParameter ( Uri . class , "uri" ) ; methodBuilder . addPa...
Generate delete .
128,096
private void defineJavadocHeaderForContentOperation ( MethodSpec . Builder builder , String value ) { builder . addJavadoc ( "\n<h2>Supported $L operations</h2>\n" , value ) ; builder . addJavadoc ( "<table>\n" ) ; builder . addJavadoc ( "<tr><th>URI</th><th>DAO.METHOD</th></tr>\n" ) ; classBuilder . addJavadoc ( "<h2>...
Define javadoc header for content operation .
128,097
private void generateGetType ( SQLiteDatabaseSchema schema ) { MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "getType" ) . addModifiers ( Modifier . PUBLIC ) . addAnnotation ( Override . class ) . returns ( String . class ) ; methodBuilder . addParameter ( Uri . class , "uri" ) ; methodBuilder . beg...
Generate get type .
128,098
private void generateOnShutdown ( String dataSourceNameClazz ) { MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "shutdown" ) . addModifiers ( Modifier . PUBLIC ) . addAnnotation ( Override . class ) . returns ( Void . TYPE ) ; methodBuilder . addJavadoc ( "<p>Close database.</p>\n" ) ; methodBuilder ...
Generate on shutdown .
128,099
private void generateQuery ( SQLiteDatabaseSchema schema ) { MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "query" ) . addModifiers ( Modifier . PUBLIC ) . addAnnotation ( Override . class ) . returns ( Cursor . class ) ; methodBuilder . addParameter ( Uri . class , "uri" ) ; methodBuilder . addPara...
Generate query .