idx
int64 0
41.2k
| question
stringlengths 83
4.15k
| target
stringlengths 5
715
|
|---|---|---|
4,600
|
public static void generateFieldPersistance ( BindTypeContext context , List < ? extends ManagedModelProperty > collection , PersistType persistType , boolean forceName , Modifier ... modifiers ) { for ( ManagedModelProperty property : collection ) { if ( property . bindProperty != null && ! property . hasTypeAdapter ( ) ) { if ( forceName ) property . bindProperty . label = DEFAULT_FIELD_NAME ; BindTransformer . checkIfIsInUnsupportedPackage ( property . bindProperty . getPropertyType ( ) . getTypeName ( ) ) ; generateFieldSerialize ( context , persistType , property . bindProperty , modifiers ) ; generateFieldParser ( context , persistType , property . bindProperty , modifiers ) ; } } }
|
Manage field s persistence for both in SharedPreference and SQLite flavours .
|
4,601
|
public static void generateFieldSerialize ( BindTypeContext context , PersistType persistType , BindProperty property , Modifier ... modifiers ) { Converter < String , String > format = CaseFormat . LOWER_CAMEL . converterTo ( CaseFormat . UPPER_CAMEL ) ; String methodName = "serialize" + format . convert ( property . getName ( ) ) ; MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( methodName ) . addJavadoc ( "for attribute $L serialization\n" , property . getName ( ) ) . addParameter ( ParameterSpec . builder ( typeName ( property . getElement ( ) ) , "value" ) . build ( ) ) . addModifiers ( modifiers ) ; switch ( persistType ) { case STRING : methodBuilder . returns ( className ( String . class ) ) ; break ; case BYTE : methodBuilder . returns ( TypeUtility . arrayTypeName ( Byte . TYPE ) ) ; break ; } if ( ArrayTypeName . of ( Byte . TYPE ) . equals ( property . getPropertyType ( ) . getTypeName ( ) ) && persistType == PersistType . BYTE ) { methodBuilder . addStatement ( "return value" ) ; } else { methodBuilder . beginControlFlow ( "if (value==null)" ) ; methodBuilder . addStatement ( "return null" ) ; methodBuilder . endControlFlow ( ) ; methodBuilder . addStatement ( "$T context=$T.jsonBind()" , KriptonJsonContext . class , KriptonBinder . class ) ; methodBuilder . beginControlFlow ( "try ($T stream=new $T(); $T wrapper=context.createSerializer(stream))" , KriptonByteArrayOutputStream . class , KriptonByteArrayOutputStream . class , JacksonWrapperSerializer . class ) ; methodBuilder . addStatement ( "$T jacksonSerializer=wrapper.jacksonGenerator" , JsonGenerator . class ) ; if ( ! property . isBindedObject ( ) ) { methodBuilder . addStatement ( "jacksonSerializer.writeStartObject()" ) ; } methodBuilder . addStatement ( "int fieldCount=0" ) ; BindTransform bindTransform = BindTransformer . lookup ( property ) ; String serializerName = "jacksonSerializer" ; bindTransform . generateSerializeOnJackson ( context , methodBuilder , serializerName , null , "value" , property ) ; if ( ! property . isBindedObject ( ) ) { methodBuilder . addStatement ( "jacksonSerializer.writeEndObject()" ) ; } methodBuilder . addStatement ( "jacksonSerializer.flush()" ) ; switch ( persistType ) { case STRING : methodBuilder . addStatement ( "return stream.toString()" ) ; break ; case BYTE : methodBuilder . addStatement ( "return stream.toByteArray()" ) ; break ; } methodBuilder . nextControlFlow ( "catch($T e)" , Exception . class ) ; methodBuilder . addStatement ( "throw(new $T(e.getMessage()))" , KriptonRuntimeException . class ) ; methodBuilder . endControlFlow ( ) ; } context . builder . addMethod ( methodBuilder . build ( ) ) ; }
|
generates code to manage field serialization .
|
4,602
|
public static void generateParamSerializer ( BindTypeContext context , String propertyName , TypeName parameterTypeName , PersistType persistType ) { propertyName = SQLiteDaoDefinition . PARAM_SERIALIZER_PREFIX + propertyName ; MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( propertyName ) . addJavadoc ( "for param $L serialization\n" , propertyName ) . addParameter ( ParameterSpec . builder ( parameterTypeName , "value" ) . build ( ) ) ; methodBuilder . addModifiers ( context . modifiers ) ; switch ( persistType ) { case STRING : methodBuilder . returns ( className ( String . class ) ) ; break ; case BYTE : methodBuilder . returns ( TypeUtility . arrayTypeName ( Byte . TYPE ) ) ; break ; } methodBuilder . beginControlFlow ( "if (value==null)" ) ; methodBuilder . addStatement ( "return null" ) ; methodBuilder . endControlFlow ( ) ; methodBuilder . addStatement ( "$T context=$T.jsonBind()" , KriptonJsonContext . class , KriptonBinder . class ) ; methodBuilder . beginControlFlow ( "try ($T stream=new $T(); $T wrapper=context.createSerializer(stream))" , KriptonByteArrayOutputStream . class , KriptonByteArrayOutputStream . class , JacksonWrapperSerializer . class ) ; methodBuilder . addStatement ( "$T jacksonSerializer=wrapper.jacksonGenerator" , JsonGenerator . class ) ; methodBuilder . addStatement ( "int fieldCount=0" ) ; BindTransform bindTransform = BindTransformer . lookup ( parameterTypeName ) ; String serializerName = "jacksonSerializer" ; boolean isInCollection = true ; if ( ! BindTransformer . isBindedObject ( parameterTypeName ) ) { methodBuilder . addStatement ( "$L.writeStartObject()" , serializerName ) ; isInCollection = false ; } BindProperty property = BindProperty . builder ( parameterTypeName ) . inCollection ( isInCollection ) . elementName ( DEFAULT_FIELD_NAME ) . build ( ) ; bindTransform . generateSerializeOnJackson ( context , methodBuilder , serializerName , null , "value" , property ) ; if ( ! BindTransformer . isBindedObject ( parameterTypeName ) ) { methodBuilder . addStatement ( "$L.writeEndObject()" , serializerName ) ; } methodBuilder . addStatement ( "$L.flush()" , serializerName ) ; switch ( persistType ) { case STRING : methodBuilder . addStatement ( "return stream.toString()" ) ; break ; case BYTE : methodBuilder . addStatement ( "return stream.toByteArray()" ) ; break ; } methodBuilder . nextControlFlow ( "catch($T e)" , Exception . class ) ; methodBuilder . addStatement ( "throw(new $T(e.getMessage()))" , KriptonRuntimeException . class ) ; methodBuilder . endControlFlow ( ) ; context . builder . addMethod ( methodBuilder . build ( ) ) ; }
|
Generate param serializer .
|
4,603
|
public static void generateParamParser ( BindTypeContext context , String methodName , TypeName parameterTypeName , PersistType persistType ) { methodName = SQLiteDaoDefinition . PARAM_PARSER_PREFIX + methodName ; MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( methodName ) . addJavadoc ( "for param $L parsing\n" , methodName ) . returns ( parameterTypeName ) ; methodBuilder . addModifiers ( context . modifiers ) ; switch ( persistType ) { case STRING : methodBuilder . addParameter ( ParameterSpec . builder ( className ( String . class ) , "input" ) . build ( ) ) ; break ; case BYTE : methodBuilder . addParameter ( ParameterSpec . builder ( TypeUtility . arrayTypeName ( Byte . TYPE ) , "input" ) . build ( ) ) ; break ; } methodBuilder . beginControlFlow ( "if (input==null)" ) ; methodBuilder . addStatement ( "return null" ) ; methodBuilder . endControlFlow ( ) ; methodBuilder . addStatement ( "$T context=$T.jsonBind()" , KriptonJsonContext . class , KriptonBinder . class ) ; methodBuilder . beginControlFlow ( "try ($T wrapper=context.createParser(input))" , JacksonWrapperParser . class ) ; methodBuilder . addStatement ( "$T jacksonParser=wrapper.jacksonParser" , JsonParser . class ) ; methodBuilder . addCode ( "// START_OBJECT\n" ) ; methodBuilder . addStatement ( "jacksonParser.nextToken()" ) ; methodBuilder . addCode ( "// value of \"element\"\n" ) ; methodBuilder . addStatement ( "jacksonParser.nextValue()" ) ; String parserName = "jacksonParser" ; BindTransform bindTransform = BindTransformer . lookup ( parameterTypeName ) ; methodBuilder . addStatement ( "$T result=null" , parameterTypeName ) ; BindProperty property = BindProperty . builder ( parameterTypeName ) . inCollection ( false ) . elementName ( DEFAULT_FIELD_NAME ) . build ( ) ; bindTransform . generateParseOnJackson ( context , methodBuilder , parserName , null , "result" , property ) ; methodBuilder . addStatement ( "return result" ) ; methodBuilder . nextControlFlow ( "catch($T e)" , Exception . class ) ; methodBuilder . addStatement ( "throw(new $T(e.getMessage()))" , KriptonRuntimeException . class ) ; methodBuilder . endControlFlow ( ) ; context . builder . addMethod ( methodBuilder . build ( ) ) ; }
|
Generate param parser .
|
4,604
|
protected void checkTypeAdapter ( @ SuppressWarnings ( "rawtypes" ) ModelEntity entity , TypeMirror propertyType , TypeAdapter typeAdapter , ModelAnnotation annotation ) { TypeName sourceType = TypeUtility . typeName ( TypeAdapterHelper . detectSourceType ( entity . getElement ( ) , typeAdapter . adapterClazz ) ) ; TypeName uboxSourceType = sourceType ; if ( TypeUtility . isTypeWrappedPrimitive ( sourceType ) ) { uboxSourceType = sourceType . unbox ( ) ; } boolean expr = uboxSourceType . toString ( ) . equals ( propertyType . toString ( ) ) || sourceType . toString ( ) . equals ( propertyType . toString ( ) ) ; AssertKripton . fail ( ! expr , "In class '%s', property '%s' uses @%s that manages type '%s' instead of '%s'" , entity . getElement ( ) . asType ( ) , getName ( ) , annotation . getSimpleName ( ) , element . asType ( ) . toString ( ) , TypeAdapterHelper . detectSourceType ( entity . getElement ( ) , typeAdapter . adapterClazz ) , getPropertyType ( ) . getTypeName ( ) ) ; }
|
Check type adapter .
|
4,605
|
private static boolean contentEquals ( String s , char [ ] chars , int start , int length ) { if ( s . length ( ) != length ) { return false ; } for ( int i = 0 ; i < length ; i ++ ) { if ( chars [ start + i ] != s . charAt ( i ) ) { return false ; } } return true ; }
|
Content equals .
|
4,606
|
public E findImmutablePropertyByName ( String name ) { String lcName = name . toLowerCase ( ) ; for ( E item : immutableCollection ) { if ( item . getName ( ) . toLowerCase ( ) . equals ( lcName ) ) { return item ; } } return null ; }
|
Find property by name .
|
4,607
|
public static DynamicByteBuffer createExact ( final int capacity ) { return new DynamicByteBuffer ( capacity ) { public DynamicByteBuffer add ( byte [ ] chars ) { DynamicByteBufferHelper . _idx ( buffer , length , chars ) ; length += chars . length ; return this ; } } ; }
|
Creates the exact .
|
4,608
|
public void addUnsignedByte ( short value ) { if ( 1 + length < capacity ) { DynamicByteBufferHelper . unsignedByteTo ( buffer , length , value ) ; } else { buffer = DynamicByteBufferHelper . grow ( buffer , buffer . length * 2 + 1 ) ; capacity = buffer . length ; DynamicByteBufferHelper . unsignedByteTo ( buffer , length , value ) ; } length += 1 ; }
|
Adds the unsigned byte .
|
4,609
|
public DynamicByteBuffer addUnsignedInt ( long value ) { if ( 4 + length < capacity ) { DynamicByteBufferHelper . unsignedIntTo ( buffer , length , value ) ; } else { buffer = DynamicByteBufferHelper . grow ( buffer , buffer . length * 2 + 4 ) ; capacity = buffer . length ; DynamicByteBufferHelper . unsignedIntTo ( buffer , length , value ) ; } length += 4 ; return this ; }
|
Adds the unsigned int .
|
4,610
|
public void addUnsignedShort ( int value ) { if ( 2 + length < capacity ) { DynamicByteBufferHelper . unsignedShortTo ( buffer , length , value ) ; } else { buffer = DynamicByteBufferHelper . grow ( buffer , buffer . length * 2 + 2 ) ; capacity = buffer . length ; DynamicByteBufferHelper . unsignedShortTo ( buffer , length , value ) ; } length += 2 ; }
|
Adds the unsigned short .
|
4,611
|
public void writeLargeDoubleArray ( double [ ] values ) { int byteSize = values . length * 8 + 4 ; this . add ( values . length ) ; doWriteDoubleArray ( values , byteSize ) ; }
|
Write large double array .
|
4,612
|
public void writeLargeLongArray ( long [ ] values ) { int byteSize = values . length * 8 + 4 ; this . add ( values . length ) ; doWriteLongArray ( values , byteSize ) ; }
|
Write large long array .
|
4,613
|
public void writeLargeString ( String s ) { final byte [ ] bytes = DynamicByteBufferHelper . bytes ( s ) ; this . add ( bytes . length ) ; this . add ( bytes ) ; }
|
Write large string .
|
4,614
|
public void writeMediumDoubleArray ( double [ ] values ) { int byteSize = values . length * 8 + 2 ; this . addUnsignedShort ( values . length ) ; doWriteDoubleArray ( values , byteSize ) ; }
|
Write medium double array .
|
4,615
|
public void writeMediumFloatArray ( float [ ] values ) { int byteSize = values . length * 4 + 2 ; this . addUnsignedShort ( values . length ) ; doWriteFloatArray ( values , byteSize ) ; }
|
Write medium float array .
|
4,616
|
public void writeMediumLongArray ( long [ ] values ) { int byteSize = values . length * 8 + 2 ; this . addUnsignedShort ( values . length ) ; doWriteLongArray ( values , byteSize ) ; }
|
Write medium long array .
|
4,617
|
public void writeMediumShortArray ( short [ ] values ) { int byteSize = values . length * 2 + 2 ; this . addUnsignedShort ( values . length ) ; doWriteShortArray ( values , byteSize ) ; }
|
Write medium short array .
|
4,618
|
public void writeMediumString ( String s ) { final byte [ ] bytes = DynamicByteBufferHelper . bytes ( s ) ; this . addUnsignedShort ( bytes . length ) ; this . add ( bytes ) ; }
|
Write medium string .
|
4,619
|
public void writeSmallDoubleArray ( double [ ] values ) { int byteSize = values . length * 8 + 1 ; this . addUnsignedByte ( ( short ) values . length ) ; doWriteDoubleArray ( values , byteSize ) ; }
|
Write small double array .
|
4,620
|
public void writeSmallLongArray ( long [ ] values ) { int byteSize = values . length * 8 + 1 ; this . addUnsignedByte ( ( short ) values . length ) ; doWriteLongArray ( values , byteSize ) ; }
|
Write small long array .
|
4,621
|
public void writeSmallShortArray ( short [ ] values ) { int byteSize = values . length * 2 + 1 ; this . addUnsignedByte ( ( short ) values . length ) ; doWriteShortArray ( values , byteSize ) ; }
|
Write small short array .
|
4,622
|
public void writeSmallString ( String s ) { final byte [ ] bytes = DynamicByteBufferHelper . bytes ( s ) ; this . addUnsignedByte ( ( short ) bytes . length ) ; this . add ( bytes ) ; }
|
Write small string .
|
4,623
|
public String getQualifiedName ( ) { if ( StringUtils . hasText ( packageName ) ) { return packageName + "." + typeSpec . name ; } return typeSpec . name ; }
|
Gets the qualified name .
|
4,624
|
public static void writeJava2File ( Filer filer , String packageName , TypeSpec typeSpec ) throws IOException { JavaFile target = JavaFile . builder ( packageName , typeSpec ) . skipJavaLangImports ( true ) . build ( ) ; target . writeTo ( filer ) ; }
|
Write java 2 file .
|
4,625
|
public static ClassName generateDaoFactoryClassName ( SQLiteDatabaseSchema schema ) { String schemaName = buildDaoFactoryName ( schema ) ; String packageName = TypeUtility . extractPackageName ( schema . getElement ( ) ) ; return ClassName . get ( packageName , schemaName ) ; }
|
Given a schema generate its daoFactory name .
|
4,626
|
public static void init ( Context contextValue , ExecutorService service ) { context = contextValue ; if ( service == null ) { executerService = Executors . newFixedThreadPool ( THREAD_POOL_SIZE_DEFAULT ) ; } else { executerService = service ; } }
|
Method to invoke during application initialization .
|
4,627
|
private MethodSpec . Builder generateExecuteMethod ( String packageName , SQLiteEntity entity ) { ParameterizedTypeName parameterizedReturnTypeName = ParameterizedTypeName . get ( className ( ArrayList . class ) , className ( packageName , entity . getSimpleName ( ) ) ) ; MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "execute" ) . addJavadoc ( "<p>Execute the cursor and read all rows from database.</p>\n\n" ) . addJavadoc ( "@return list of beans\n" ) . addModifiers ( Modifier . PUBLIC ) . returns ( parameterizedReturnTypeName ) ; TypeName entityClass = typeName ( entity . getElement ( ) ) ; methodBuilder . addCode ( "\n" ) ; methodBuilder . addCode ( "$T resultList=new $T(cursor.getCount());\n" , parameterizedReturnTypeName , parameterizedReturnTypeName ) ; methodBuilder . addCode ( "$T resultBean=new $T();\n" , entityClass , entityClass ) ; methodBuilder . addCode ( "\n" ) ; methodBuilder . beginControlFlow ( "if (cursor.moveToFirst())" ) ; methodBuilder . beginControlFlow ( "do\n" ) ; methodBuilder . addCode ( "resultBean=new $T();\n\n" , entityClass ) ; int i = 0 ; for ( ModelProperty item : entity . getCollection ( ) ) { methodBuilder . addCode ( "if (index$L>=0 && !cursor.isNull(index$L)) { " , i , i ) ; SQLTransformer . cursor2Java ( methodBuilder , entityClass , item , "resultBean" , "cursor" , "index" + i + "" ) ; methodBuilder . addCode ( ";" ) ; methodBuilder . addCode ( "}\n" ) ; i ++ ; } methodBuilder . addCode ( "\n" ) ; methodBuilder . addCode ( "resultList.add(resultBean);\n" ) ; methodBuilder . endControlFlow ( "while (cursor.moveToNext())" ) ; methodBuilder . endControlFlow ( ) ; methodBuilder . addCode ( "cursor.close();\n" ) ; methodBuilder . addCode ( "\n" ) ; methodBuilder . addCode ( "return resultList;\n" ) ; return methodBuilder ; }
|
Generate execute method .
|
4,628
|
protected Class < ? > defineCollectionClass ( ParameterizedTypeName collectionTypeName ) { if ( collectionTypeName . rawType . toString ( ) . startsWith ( collectionClazz . getCanonicalName ( ) ) ) { return defaultClazz ; } else if ( collectionTypeName . rawType . toString ( ) . startsWith ( SortedMap . class . getCanonicalName ( ) ) ) { return TreeMap . class ; } else if ( collectionTypeName . rawType . toString ( ) . startsWith ( SortedSet . class . getCanonicalName ( ) ) ) { return TreeSet . class ; } try { return Class . forName ( collectionTypeName . rawType . toString ( ) ) ; } catch ( ClassNotFoundException e ) { e . printStackTrace ( ) ; throw new KriptonClassNotFoundException ( e ) ; } }
|
Define collection class .
|
4,629
|
public static ClassName defineCollection ( TypeName listClazzName ) { try { Class < ? > clazz = null ; if ( listClazzName instanceof ParameterizedTypeName ) { ParameterizedTypeName returnListName = ( ParameterizedTypeName ) listClazzName ; clazz = Class . forName ( returnListName . rawType . toString ( ) ) ; } else { clazz = Class . forName ( listClazzName . toString ( ) ) ; } if ( clazz . isAssignableFrom ( List . class ) ) { clazz = ArrayList . class ; } else if ( clazz . isAssignableFrom ( Set . class ) ) { clazz = LinkedHashSet . class ; } else if ( clazz . isAssignableFrom ( Collection . class ) ) { clazz = ArrayList . class ; } return ClassName . get ( clazz ) ; } catch ( ClassNotFoundException e ) { e . printStackTrace ( ) ; } return null ; }
|
Define collection .
|
4,630
|
public void putNull ( String key ) { if ( this . compiledStatement != null ) { compiledStatement . bindNull ( compiledStatementBindIndex ++ ) ; } else if ( values != null ) { values . putNull ( key ) ; return ; } names . add ( key ) ; args . add ( null ) ; valueType . add ( ParamType . NULL ) ; }
|
Adds a null value to the set .
|
4,631
|
public void addWhereArgs ( String value ) { if ( this . compiledStatement != null ) { compiledStatement . bindString ( compiledStatementBindIndex ++ , value ) ; } whereArgs . add ( value ) ; valueType . add ( ParamType . STRING ) ; }
|
Adds the where args .
|
4,632
|
public void clear ( ) { names . clear ( ) ; values = null ; valueType . clear ( ) ; args . clear ( ) ; whereArgs . clear ( ) ; compiledStatement = null ; compiledStatementBindIndex = 1 ; }
|
Removes all values .
|
4,633
|
public String keyList ( ) { String separator = "" ; StringBuilder buffer = new StringBuilder ( ) ; String item ; for ( int i = 0 ; i < names . size ( ) ; i ++ ) { item = names . get ( i ) ; buffer . append ( separator + item ) ; separator = ", " ; } return buffer . toString ( ) ; }
|
Key list .
|
4,634
|
public String keyValueList ( ) { String separator = "" ; StringBuilder buffer = new StringBuilder ( ) ; for ( int i = 0 ; i < names . size ( ) ; i ++ ) { buffer . append ( separator + "?" ) ; separator = ", " ; } return buffer . toString ( ) ; }
|
Key value list .
|
4,635
|
private Class < ? > replaceInterface ( Class < ? > clazz ) { if ( clazz . equals ( List . class ) ) { return ArrayList . class ; } if ( clazz . equals ( Set . class ) ) { return HashSet . class ; } if ( clazz . equals ( Map . class ) ) { return HashMap . class ; } return clazz ; }
|
Replace interface .
|
4,636
|
private void checkRelaxed ( String errorMessage ) { if ( ! relaxed ) { throw new KriptonRuntimeException ( errorMessage , true , this . getLineNumber ( ) , this . getColumnNumber ( ) , getPositionDescription ( ) , null ) ; } if ( error == null ) { error = "Error: " + errorMessage ; } }
|
Check relaxed .
|
4,637
|
private String readUntil ( char [ ] delimiter , boolean returnText ) throws IOException , KriptonRuntimeException { int start = position ; StringBuilder result = null ; if ( returnText && text != null ) { result = new StringBuilder ( ) ; result . append ( text ) ; } search : while ( true ) { if ( position + delimiter . length >= limit ) { if ( start < position && returnText ) { if ( result == null ) { result = new StringBuilder ( ) ; } result . append ( buffer , start , position - start ) ; } if ( ! fillBuffer ( delimiter . length ) ) { checkRelaxed ( UNEXPECTED_EOF ) ; type = COMMENT ; return null ; } start = position ; } for ( int i = 0 ; i < delimiter . length ; i ++ ) { if ( buffer [ position + i ] != delimiter [ i ] ) { position ++ ; continue search ; } } break ; } int end = position ; position += delimiter . length ; if ( ! returnText ) { return null ; } else if ( result == null ) { return stringPool . get ( buffer , start , end - start ) ; } else { result . append ( buffer , start , end - start ) ; return result . toString ( ) ; } }
|
Reads text until the specified delimiter is encountered . Consumes the text and the delimiter .
|
4,638
|
private void readXmlDeclaration ( ) throws IOException , KriptonRuntimeException { if ( bufferStartLine != 0 || bufferStartColumn != 0 || position != 0 ) { checkRelaxed ( "processing instructions must not start with xml" ) ; } read ( START_PROCESSING_INSTRUCTION ) ; parseStartTag ( true , true ) ; if ( attributeCount < 1 || ! "version" . equals ( attributes [ 2 ] ) ) { checkRelaxed ( "version expected" ) ; } version = attributes [ 3 ] ; int pos = 1 ; if ( pos < attributeCount && "encoding" . equals ( attributes [ 2 + 4 ] ) ) { encoding = attributes [ 3 + 4 ] ; pos ++ ; } if ( pos < attributeCount && "standalone" . equals ( attributes [ 4 * pos + 2 ] ) ) { String st = attributes [ 3 + 4 * pos ] ; if ( "yes" . equals ( st ) ) { standalone = Boolean . TRUE ; } else if ( "no" . equals ( st ) ) { standalone = Boolean . FALSE ; } else { checkRelaxed ( "illegal standalone value: " + st ) ; } pos ++ ; } if ( pos != attributeCount ) { checkRelaxed ( "unexpected attributes in XML declaration" ) ; } isWhitespace = true ; text = null ; }
|
Returns true if an XML declaration was read .
|
4,639
|
private String readComment ( boolean returnText ) throws IOException , KriptonRuntimeException { read ( START_COMMENT ) ; if ( relaxed ) { return readUntil ( END_COMMENT , returnText ) ; } String commentText = readUntil ( COMMENT_DOUBLE_DASH , returnText ) ; if ( peekCharacter ( ) != '>' ) { throw new KriptonRuntimeException ( "Comments may not contain --" , true , this . getLineNumber ( ) , this . getColumnNumber ( ) , getPositionDescription ( ) , null ) ; } position ++ ; return commentText ; }
|
Read comment .
|
4,640
|
private void readInternalSubset ( ) throws IOException , KriptonRuntimeException { read ( '[' ) ; while ( true ) { skip ( ) ; if ( peekCharacter ( ) == ']' ) { position ++ ; return ; } int declarationType = peekType ( true ) ; switch ( declarationType ) { case ELEMENTDECL : readElementDeclaration ( ) ; break ; case ATTLISTDECL : readAttributeListDeclaration ( ) ; break ; case ENTITYDECL : readEntityDeclaration ( ) ; break ; case NOTATIONDECL : readNotationDeclaration ( ) ; break ; case PROCESSING_INSTRUCTION : read ( START_PROCESSING_INSTRUCTION ) ; readUntil ( END_PROCESSING_INSTRUCTION , false ) ; break ; case COMMENT : readComment ( false ) ; break ; case PARAMETER_ENTITY_REF : throw new KriptonRuntimeException ( "Parameter entity references are not supported" , true , this . getLineNumber ( ) , this . getColumnNumber ( ) , getPositionDescription ( ) , null ) ; default : throw new KriptonRuntimeException ( "Unexpected token" , true , this . getLineNumber ( ) , this . getColumnNumber ( ) , getPositionDescription ( ) , null ) ; } } }
|
Read internal subset .
|
4,641
|
private void readNotationDeclaration ( ) throws IOException , KriptonRuntimeException { read ( START_NOTATION ) ; skip ( ) ; readName ( ) ; if ( ! readExternalId ( false , false ) ) { throw new KriptonRuntimeException ( "Expected external ID or public ID for notation" , true , this . getLineNumber ( ) , this . getColumnNumber ( ) , getPositionDescription ( ) , null ) ; } skip ( ) ; read ( '>' ) ; }
|
Read notation declaration .
|
4,642
|
private void readEndTag ( ) throws IOException , KriptonRuntimeException { read ( '<' ) ; read ( '/' ) ; name = readName ( ) ; skip ( ) ; read ( '>' ) ; int sp = ( depth - 1 ) * 4 ; if ( depth == 0 ) { checkRelaxed ( "read end tag " + name + " with no tags open" ) ; type = COMMENT ; return ; } if ( name . equals ( elementStack [ sp + 3 ] ) ) { namespace = elementStack [ sp ] ; prefix = elementStack [ sp + 1 ] ; name = elementStack [ sp + 2 ] ; } else if ( ! relaxed ) { throw new KriptonRuntimeException ( "expected: /" + elementStack [ sp + 3 ] + " read: " + name , true , this . getLineNumber ( ) , this . getColumnNumber ( ) , getPositionDescription ( ) , null ) ; } }
|
Read end tag .
|
4,643
|
private String readName ( ) throws IOException , KriptonRuntimeException { if ( position >= limit && ! fillBuffer ( 1 ) ) { checkRelaxed ( "name expected" ) ; return "" ; } int start = position ; StringBuilder result = null ; char c = buffer [ position ] ; if ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || c == '_' || c == ':' || c >= '\u00c0' || relaxed ) { position ++ ; } else { checkRelaxed ( "name expected" ) ; return "" ; } while ( true ) { if ( position >= limit ) { if ( result == null ) { result = new StringBuilder ( ) ; } result . append ( buffer , start , position - start ) ; if ( ! fillBuffer ( 1 ) ) { return result . toString ( ) ; } start = position ; } c = buffer [ position ] ; if ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || ( c >= '0' && c <= '9' ) || c == '_' || c == '-' || c == ':' || c == '.' || c >= '\u00b7' ) { position ++ ; continue ; } if ( result == null ) { return stringPool . get ( buffer , start , position - start ) ; } else { result . append ( buffer , start , position - start ) ; return result . toString ( ) ; } } }
|
Returns an element or attribute name . This is always non - empty for non - relaxed parsers .
|
4,644
|
public T get ( String name ) { String lcName = name . toLowerCase ( ) ; for ( T item : collection ) { if ( item . getName ( ) . toLowerCase ( ) . equals ( lcName ) ) { return item ; } } return null ; }
|
Find for contained element using its name .
|
4,645
|
public static void javaProperty2ContentValues ( MethodSpec . Builder methodBuilder , TypeName beanClass , String beanName , ModelProperty property ) { TypeName typeName = null ; if ( property != null && property . getPropertyType ( ) != null ) { typeName = property . getPropertyType ( ) . getTypeName ( ) ; } if ( property != null && property . hasTypeAdapter ( ) ) { typeName = typeName ( property . typeAdapter . dataType ) ; } SQLTransform transform = lookup ( typeName ) ; AssertKripton . assertTrueOrUnsupportedFieldTypeException ( transform != null , typeName ) ; transform . generateWriteProperty2ContentValues ( methodBuilder , beanName , beanClass , property ) ; }
|
Used to convert a property of managed bean to contentValue .
|
4,646
|
public static void javaProperty2WhereCondition ( MethodSpec . Builder methodBuilder , SQLiteModelMethod method , String paramName , TypeName paramType , ModelProperty property ) { if ( property != null && property . hasTypeAdapter ( ) ) { methodBuilder . addCode ( AbstractSQLTransform . PRE_TYPE_ADAPTER_TO_STRING + "$L" + AbstractSQLTransform . POST_TYPE_ADAPTER , SQLTypeAdapterUtils . class , typeName ( property . typeAdapter . adapterClazz ) , PropertyUtility . getter ( paramName , paramType , property ) ) ; } else if ( property != null ) { SQLTransform transform = lookup ( property . getPropertyType ( ) . getTypeName ( ) ) ; AssertKripton . assertTrueOrUnsupportedFieldTypeException ( transform != null , paramType ) ; transform . generateWriteProperty2WhereCondition ( methodBuilder , paramName , paramType , property ) ; } else { AssertKripton . assertTrueOrUnsupportedFieldTypeException ( false , paramType ) ; } }
|
Used to convert a property of managed bean to where condition .
|
4,647
|
public static void javaMethodParam2ContentValues ( MethodSpec . Builder methodBuilder , SQLiteModelMethod method , String paramName , TypeName paramType , ModelProperty property ) { AssertKripton . assertTrueOrInvalidMethodSignException ( ! method . hasAdapterForParam ( paramName ) , method , "method's parameter '%s' can not use a type adapter" , paramName ) ; SQLTransform transform = ( property != null && property . hasTypeAdapter ( ) ) ? lookup ( typeName ( property . typeAdapter . dataType ) ) : lookup ( paramType ) ; AssertKripton . assertTrueOrUnsupportedFieldTypeException ( transform != null , ( property != null && property . hasTypeAdapter ( ) ) ? typeName ( property . typeAdapter . dataType ) : paramType ) ; transform . generateWriteParam2ContentValues ( methodBuilder , method , paramName , paramType , property ) ; }
|
Used to convert a method s parameter to contentValues . It can not have a type adpter because it eventually use the one define in associated bean s attribute
|
4,648
|
public static boolean isSupportedJDKType ( TypeName typeName ) { if ( typeName . isPrimitive ( ) ) { return getPrimitiveTransform ( typeName ) != null ; } String name = typeName . toString ( ) ; if ( name . startsWith ( "java.lang" ) ) { return getLanguageTransform ( typeName ) != null ; } if ( name . startsWith ( "java.util" ) ) { return getUtilTransform ( typeName ) != null ; } if ( name . startsWith ( "java.math" ) ) { return getMathTransform ( typeName ) != null ; } if ( name . startsWith ( "java.net" ) ) { return getNetTransform ( typeName ) != null ; } if ( name . startsWith ( "java.sql" ) ) { return getSqlTransform ( typeName ) != null ; } return false ; }
|
Checks if is supported JDK type .
|
4,649
|
public static void resetBean ( MethodSpec . Builder methodBuilder , TypeName beanClass , String beanName , ModelProperty property , String cursorName , String indexName ) { SQLTransform transform = lookup ( property . getElement ( ) . asType ( ) ) ; if ( transform == null ) { throw new IllegalArgumentException ( "Transform of " + property . getElement ( ) . asType ( ) + " not supported" ) ; } transform . generateResetProperty ( methodBuilder , beanClass , beanName , property , cursorName , indexName ) ; }
|
Reset bean .
|
4,650
|
public static String columnTypeAsString ( SQLProperty property ) { if ( property . columnAffinityType != null && ColumnAffinityType . AUTO != property . columnAffinityType ) { return property . columnAffinityType . toString ( ) ; } TypeName typeName = property . getPropertyType ( ) . getTypeName ( ) ; if ( property . hasTypeAdapter ( ) ) { typeName = typeName ( property . typeAdapter . dataType ) ; } SQLTransform transform = lookup ( typeName ) ; if ( transform == null ) { throw new IllegalArgumentException ( "Transform of " + property . getElement ( ) . asType ( ) + " not supported" ) ; } return transform . getColumnType ( ) . toString ( ) ; }
|
Detect column type . If column affinity is specified by annotation affinity column is used .
|
4,651
|
public Map . Entry < K , V > ceil ( K k ) { if ( contains ( k ) ) { return mHashMap . get ( k ) . mPrevious ; } return null ; }
|
Return an entry added to prior to an entry associated with the given key .
|
4,652
|
public static < D , J > J toJava ( Class < ? extends PreferenceTypeAdapter < J , D > > clazz , D value ) { @ SuppressWarnings ( "unchecked" ) PreferenceTypeAdapter < J , D > adapter = cache . get ( clazz ) ; if ( adapter == null ) { adapter = generateAdapter ( clazz ) ; } return adapter . toJava ( value ) ; }
|
To java .
|
4,653
|
public static boolean isStringSet ( PrefsProperty property ) { boolean isStringSet = false ; TypeName typeName ; if ( property . hasTypeAdapter ( ) ) { typeName = TypeUtility . typeName ( property . typeAdapter . dataType ) ; } else { typeName = TypeUtility . typeName ( property . getElement ( ) . asType ( ) ) ; } if ( typeName instanceof ParameterizedTypeName && TypeUtility . isSet ( typeName ) ) { ParameterizedTypeName parameterizedTypeName = ( ParameterizedTypeName ) typeName ; if ( TypeUtility . isEquals ( parameterizedTypeName . typeArguments . get ( 0 ) , String . class . getCanonicalName ( ) ) ) { isStringSet = true ; } } return isStringSet ; }
|
Checks if is string set .
|
4,654
|
public String getAttributeAsClassName ( AnnotationAttributeType attribute ) { String temp = attributes . get ( attribute . getValue ( ) ) ; if ( StringUtils . hasText ( temp ) ) { temp = temp . replace ( ".class" , "" ) ; } return temp ; }
|
Gets the attribute as class name .
|
4,655
|
public List < String > getAttributeAsArray ( AnnotationAttributeType attribute ) { String temp = attributes . get ( attribute . getValue ( ) ) ; return AnnotationUtility . extractAsArrayOfString ( temp ) ; }
|
Gets the attribute as array .
|
4,656
|
public int getAttributeAsInt ( AnnotationAttributeType attribute ) { String temp = attributes . get ( attribute . getValue ( ) ) ; return Integer . parseInt ( temp ) ; }
|
Gets the attribute as int .
|
4,657
|
protected void generateSubQueries ( Builder methodBuilder , SQLiteModelMethod method ) { SQLiteEntity entity = method . getEntity ( ) ; for ( Triple < String , String , SQLiteModelMethod > item : method . childrenSelects ) { TypeName entityTypeName = TypeUtility . typeName ( entity . getElement ( ) ) ; String setter ; if ( entity . isImmutablePojo ( ) ) { String idGetter = ImmutableUtility . IMMUTABLE_PREFIX + entity . getPrimaryKey ( ) . getName ( ) ; setter = ImmutableUtility . IMMUTABLE_PREFIX + entity . findRelationByParentProperty ( item . value0 ) . value0 . getName ( ) + "=" + String . format ( "this.daoFactory.get%s().%s(%s)" , item . value2 . getParent ( ) . getName ( ) , item . value2 . getName ( ) , idGetter ) ; } else { String idGetter = PropertyUtility . getter ( "resultBean" , entityTypeName , entity . getPrimaryKey ( ) ) ; setter = PropertyUtility . setter ( entityTypeName , "resultBean" , entity . findRelationByParentProperty ( item . value0 ) . value0 , String . format ( "this.daoFactory.get%s().%s(%s)" , item . value2 . getParent ( ) . getName ( ) , item . value2 . getName ( ) , idGetter ) ) ; } methodBuilder . addComment ( "sub query: $L" , setter ) ; methodBuilder . addStatement ( "$L" , setter ) ; } }
|
generate code for sub queries
|
4,658
|
public void generateCommonPart ( SQLiteModelMethod method , TypeSpec . Builder classBuilder , MethodSpec . Builder methodBuilder , Set < JQLProjection > fieldList , boolean generateSqlField ) { generateCommonPart ( method , classBuilder , methodBuilder , fieldList , GenerationType . ALL , null , generateSqlField , false ) ; }
|
Generate common part .
|
4,659
|
protected MethodSpec . Builder generateMethodBuilder ( SQLiteModelMethod method ) { MethodSpec . Builder methodBuilder ; if ( method . hasLiveData ( ) ) { methodBuilder = MethodSpec . methodBuilder ( method . getName ( ) + LIVE_DATA_PREFIX ) . addModifiers ( Modifier . PROTECTED ) ; } else { methodBuilder = MethodSpec . methodBuilder ( method . getName ( ) ) . addAnnotation ( Override . class ) . addModifiers ( Modifier . PUBLIC ) ; } return methodBuilder ; }
|
Generate method builder .
|
4,660
|
protected void generateMethodSignature ( SQLiteModelMethod method , MethodSpec . Builder methodBuilder , TypeName returnTypeName , ParameterSpec ... additionalParameterSpec ) { boolean finalParameter = false ; if ( method . hasLiveData ( ) && returnTypeName . equals ( method . liveDataReturnClass ) ) { finalParameter = true ; } for ( Pair < String , TypeName > item : method . getParameters ( ) ) { ParameterSpec . Builder builder = ParameterSpec . builder ( item . value1 , item . value0 ) ; if ( finalParameter ) { builder . addModifiers ( Modifier . FINAL ) ; } methodBuilder . addParameter ( builder . build ( ) ) ; } for ( ParameterSpec item : additionalParameterSpec ) { methodBuilder . addParameter ( item ) ; } methodBuilder . returns ( returnTypeName ) ; }
|
Generate method signature .
|
4,661
|
public static void checkUnusedParameters ( SQLiteModelMethod method , Set < String > usedMethodParameters , TypeName excludedClasses ) { int paramsCount = method . getParameters ( ) . size ( ) ; int usedCount = usedMethodParameters . size ( ) ; if ( paramsCount > usedCount ) { StringBuilder sb = new StringBuilder ( ) ; String separator = "" ; for ( Pair < String , TypeName > item : method . getParameters ( ) ) { if ( excludedClasses != null && item . value1 . equals ( excludedClasses ) ) { usedCount ++ ; } else { if ( ! usedMethodParameters . contains ( item . value0 ) ) { sb . append ( separator + "'" + item . value0 + "'" ) ; separator = ", " ; } } } if ( paramsCount > usedCount ) { throw ( new InvalidMethodSignException ( method , "unused parameter(s) " + sb . toString ( ) ) ) ; } } }
|
Check if there are unused method parameters . In this case an exception was throws .
|
4,662
|
private static void generateSQLBuild ( SQLiteModelMethod method , MethodSpec . Builder methodBuilder , SplittedSql splittedSql , boolean countQuery ) { methodBuilder . addStatement ( "$T _sqlBuilder=sqlBuilder()" , StringBuilder . class ) ; methodBuilder . addStatement ( "_sqlBuilder.append($S)" , splittedSql . sqlBasic . trim ( ) ) ; SqlModifyBuilder . generateInitForDynamicWhereVariables ( method , methodBuilder , method . dynamicWhereParameterName , method . dynamicWhereArgsParameterName ) ; if ( method . jql . isOrderBy ( ) ) { methodBuilder . addStatement ( "String _sortOrder=$L" , method . jql . paramOrderBy ) ; } SqlBuilderHelper . generateWhereCondition ( methodBuilder , method , false ) ; SqlSelectBuilder . generateDynamicPartOfQuery ( method , methodBuilder , splittedSql , countQuery ) ; }
|
Generate SQL build .
|
4,663
|
public static String extractClassName ( String fullName ) { int l = fullName . lastIndexOf ( "." ) ; return fullName . substring ( l + 1 ) ; }
|
Extract class name .
|
4,664
|
public static boolean isTypeIncludedIn ( TypeName value , Type ... types ) { for ( Type item : types ) { if ( value . equals ( typeName ( item ) ) ) { return true ; } } return false ; }
|
Checks if is type included in .
|
4,665
|
public static boolean isTypePrimitive ( TypeName value ) { return isTypeIncludedIn ( value , Byte . TYPE , Character . TYPE , Boolean . TYPE , Short . TYPE , Integer . TYPE , Long . TYPE , Float . TYPE , Double . TYPE ) ; }
|
Checks if is type primitive .
|
4,666
|
public static boolean isTypeWrappedPrimitive ( TypeName value ) { return isTypeIncludedIn ( value , Byte . class , Character . class , Boolean . class , Short . class , Integer . class , Long . class , Float . class , Double . class ) ; }
|
Checks if is type wrapped primitive .
|
4,667
|
public static boolean isEquals ( TypeName value , TypeName kindOfParameter ) { return value . toString ( ) . equals ( kindOfParameter . toString ( ) ) ; }
|
Check if class that is rapresented by value has same typeName of entity parameter .
|
4,668
|
public static TypeName typeName ( TypeMirror typeMirror ) { LiteralType literalType = LiteralType . of ( typeMirror . toString ( ) ) ; if ( literalType . isArray ( ) ) { return ArrayTypeName . of ( typeName ( literalType . getRawType ( ) ) ) ; } else if ( literalType . isCollection ( ) ) { return ParameterizedTypeName . get ( TypeUtility . className ( literalType . getRawType ( ) ) , typeName ( literalType . getTypeParameter ( ) ) ) ; } TypeName [ ] values = { TypeName . BOOLEAN , TypeName . BYTE , TypeName . CHAR , TypeName . DOUBLE , TypeName . FLOAT , TypeName . INT , TypeName . LONG , TypeName . SHORT , TypeName . VOID } ; for ( TypeName item : values ) { if ( typeMirror . toString ( ) . equals ( item . toString ( ) ) ) { return item ; } } return TypeName . get ( typeMirror ) ; }
|
Convert a TypeMirror in a typeName .
|
4,669
|
public static ClassName mergeTypeNameWithSuffix ( TypeName typeName , String typeNameSuffix ) { ClassName className = className ( typeName . toString ( ) ) ; return classNameWithSuffix ( className . packageName ( ) , className . simpleName ( ) , typeNameSuffix ) ; }
|
Merge type name with suffix .
|
4,670
|
public static TypeName typeName ( String typeName ) { TypeName [ ] values = { TypeName . BOOLEAN , TypeName . BYTE , TypeName . CHAR , TypeName . DOUBLE , TypeName . FLOAT , TypeName . INT , TypeName . LONG , TypeName . SHORT , TypeName . VOID } ; for ( TypeName item : values ) { if ( item . toString ( ) . equals ( typeName ) ) { return item ; } } LiteralType literalName = LiteralType . of ( typeName ) ; if ( literalName . isParametrizedType ( ) ) { return ParameterizedTypeName . get ( className ( literalName . getRawType ( ) ) , typeName ( literalName . getTypeParameter ( ) ) ) ; } if ( literalName . isArray ( ) ) { return ArrayTypeName . of ( typeName ( literalName . getRawType ( ) ) ) ; } return ClassName . bestGuess ( typeName ) ; }
|
Convert a TypeMirror in a typeName or classname or whatever .
|
4,671
|
public static void checkTypeCompatibility ( SQLiteModelMethod method , Pair < String , TypeName > item , ModelProperty property ) { if ( ! TypeUtility . isEquals ( item . value1 , property . getPropertyType ( ) . getTypeName ( ) ) ) { throw ( new InvalidMethodSignException ( method , String . format ( "property '%s' is type '%s' and method parameter '%s' is type '%s': they must have same type" , property . getName ( ) , property . getPropertyType ( ) . getTypeName ( ) , item . value0 , item . value1 . toString ( ) ) ) ) ; } }
|
Check if type if compatibility .
|
4,672
|
public static void beginStringConversion ( Builder methodBuilder , ModelProperty property ) { TypeName modelType = typeName ( property . getElement ( ) . asType ( ) ) ; beginStringConversion ( methodBuilder , modelType ) ; }
|
generate begin string to translate in code to used in content value or parameter need to be converted in string through String . valueOf
|
4,673
|
public static void endStringConversion ( Builder methodBuilder , TypeName typeMirror ) { SQLTransform transform = SQLTransformer . lookup ( typeMirror ) ; switch ( transform . getColumnType ( ) ) { case TEXT : return ; case BLOB : methodBuilder . addCode ( ",$T.UTF_8)" , StandardCharsets . class ) ; break ; case INTEGER : case REAL : methodBuilder . addCode ( ")" ) ; break ; default : break ; } }
|
generate end string to translate in code to used in content value or parameter need to be converted in string through String . valueOf
|
4,674
|
public static TypeName typeName ( TypeElement element , String suffix ) { String fullName = element . getQualifiedName ( ) . toString ( ) + suffix ; int lastIndex = fullName . lastIndexOf ( "." ) ; String packageName = fullName . substring ( 0 , lastIndex ) ; String className = fullName . substring ( lastIndex + 1 ) ; return typeName ( packageName , className ) ; }
|
Type name .
|
4,675
|
public static TypeName parameterizedTypeName ( ClassName rawClass , TypeName paramClass ) { return ParameterizedTypeName . get ( rawClass , paramClass ) ; }
|
Parameterized type name .
|
4,676
|
public static String simpleName ( TypeName clazzName ) { String clazz = clazzName . toString ( ) ; int index = clazz . lastIndexOf ( "." ) ; if ( index > 0 ) { clazz = clazz . substring ( index + 1 ) ; } return clazz ; }
|
Return simple typeName of class .
|
4,677
|
public static boolean isEnum ( String className ) { try { TypeElement element = BindTypeSubProcessor . elementUtils . getTypeElement ( className ) ; if ( element instanceof TypeElement ) { TypeElement typeElement = element ; TypeMirror superclass = typeElement . getSuperclass ( ) ; if ( superclass instanceof DeclaredType ) { DeclaredType superclassDeclaredType = ( DeclaredType ) superclass ; if ( JAVA_LANG_ENUM . equals ( getCanonicalTypeName ( superclassDeclaredType ) ) ) { return true ; } } } return false ; } catch ( Throwable e ) { return false ; } }
|
Checks if is enum .
|
4,678
|
public static boolean isCollectionOfType ( TypeName typeName , TypeName elementTypeName ) { return isAssignable ( typeName , Collection . class ) && isEquals ( ( ( ParameterizedTypeName ) typeName ) . typeArguments . get ( 0 ) , elementTypeName ) ; }
|
Checks if is collection and if element type is the one passed as parameter .
|
4,679
|
public static boolean isAssignable ( TypeName typeName , Class < ? > assignableClazz ) { try { if ( typeName instanceof ParameterizedTypeName ) { typeName = ( ( ParameterizedTypeName ) typeName ) . rawType ; } else if ( typeName instanceof ArrayTypeName ) { typeName = ( ( ArrayTypeName ) typeName ) . componentType ; } Class < ? > resolvedType = Class . forName ( typeName . toString ( ) ) ; return assignableClazz . isAssignableFrom ( resolvedType ) ; } catch ( ClassNotFoundException e ) { return false ; } }
|
Checks if is assignable .
|
4,680
|
public static String extractPackageName ( TypeElement element ) { String fullName = element . getQualifiedName ( ) . toString ( ) ; if ( fullName . lastIndexOf ( "." ) > 0 ) { return fullName . substring ( 0 , fullName . lastIndexOf ( "." ) ) ; } return "" ; }
|
Extract package name .
|
4,681
|
protected < L extends JqlBaseListener > void analyzeVariableStatementInternal ( JQLContext jqlContext , final String jql , L listener ) { walker . walk ( listener , prepareVariableStatement ( jqlContext , jql ) . value0 ) ; }
|
Analyze variable statement internal .
|
4,682
|
protected Pair < ParserRuleContext , CommonTokenStream > prepareParser ( final JQLContext jqlContext , final String jql ) { JqlLexer lexer = new JqlLexer ( CharStreams . fromString ( jql ) ) ; CommonTokenStream tokens = new CommonTokenStream ( lexer ) ; JqlParser parser = new JqlParser ( tokens ) ; parser . removeErrorListeners ( ) ; parser . addErrorListener ( new JQLBaseErrorListener ( ) { public void syntaxError ( Recognizer < ? , ? > recognizer , Object offendingSymbol , int line , int charPositionInLine , String msg , RecognitionException e ) { AssertKripton . assertTrue ( false , jqlContext . getContextDescription ( ) + ": unespected char at pos %s of SQL '%s'" , charPositionInLine , jql ) ; } } ) ; ParserRuleContext context = parser . parse ( ) ; return new Pair < > ( context , tokens ) ; }
|
Prepare parser .
|
4,683
|
public Set < String > extractColumnsToInsertOrUpdate ( final JQLContext jqlContext , String jqlValue , final Finder < SQLProperty > entity ) { final Set < String > result = new LinkedHashSet < String > ( ) ; final One < Boolean > selectionOn = new One < Boolean > ( null ) ; final One < Boolean > insertOn = new One < Boolean > ( null ) ; analyzeInternal ( jqlContext , jqlValue , new JqlBaseListener ( ) { public void enterColumn_name_set ( Column_name_setContext ctx ) { if ( insertOn . value0 == null ) { insertOn . value0 = true ; } } public void exitColumn_name_set ( Column_name_setContext ctx ) { insertOn . value0 = false ; } public void enterColumns_to_update ( Columns_to_updateContext ctx ) { if ( selectionOn . value0 == null ) { selectionOn . value0 = true ; } } public void exitColumns_to_update ( Columns_to_updateContext ctx ) { selectionOn . value0 = false ; } public void enterColumn_name ( Column_nameContext ctx ) { if ( insertOn . value0 != null && insertOn . value0 == true ) { result . add ( ctx . getText ( ) ) ; } } public void enterColumn_name_to_update ( Column_name_to_updateContext ctx ) { result . add ( ctx . getText ( ) ) ; } } ) ; return result ; }
|
Extract columns to insert or update .
|
4,684
|
private String replaceInternal ( final JQLContext jqlContext , String jql , final List < Triple < Token , Token , String > > replace , JqlBaseListener rewriterListener ) { Pair < ParserRuleContext , CommonTokenStream > parser = prepareParser ( jqlContext , jql ) ; walker . walk ( rewriterListener , parser . value0 ) ; TokenStreamRewriter rewriter = new TokenStreamRewriter ( parser . value1 ) ; for ( Triple < Token , Token , String > item : replace ) { rewriter . replace ( item . value0 , item . value1 , item . value2 ) ; } return rewriter . getText ( ) ; }
|
Replace internal .
|
4,685
|
private String replaceFromVariableStatementInternal ( JQLContext context , String jql , final List < Triple < Token , Token , String > > replace , JqlBaseListener rewriterListener ) { Pair < ParserRuleContext , CommonTokenStream > parser = prepareVariableStatement ( context , jql ) ; walker . walk ( rewriterListener , parser . value0 ) ; TokenStreamRewriter rewriter = new TokenStreamRewriter ( parser . value1 ) ; for ( Triple < Token , Token , String > item : replace ) { rewriter . replace ( item . value0 , item . value1 , item . value2 ) ; } return rewriter . getText ( ) ; }
|
Replace from variable statement internal .
|
4,686
|
private < L extends Collection < JQLPlaceHolder > > L extractPlaceHolders ( final JQLContext jqlContext , String jql , final L result ) { final One < Boolean > valid = new One < > ( ) ; valid . value0 = false ; analyzeInternal ( jqlContext , jql , new JqlBaseListener ( ) { public void enterBind_parameter ( Bind_parameterContext ctx ) { String value ; if ( ctx . bind_parameter_name ( ) != null ) { value = ctx . bind_parameter_name ( ) . getText ( ) ; } else { value = ctx . getText ( ) ; } result . add ( new JQLPlaceHolder ( JQLPlaceHolderType . PARAMETER , value ) ) ; } public void enterBind_dynamic_sql ( Bind_dynamic_sqlContext ctx ) { result . add ( new JQLPlaceHolder ( JQLPlaceHolderType . DYNAMIC_SQL , ctx . bind_parameter_name ( ) . getText ( ) ) ) ; } } ) ; return result ; }
|
Extract place holders .
|
4,687
|
private < L extends Collection < JQLPlaceHolder > > L extractPlaceHoldersFromVariableStatement ( final JQLContext jqlContext , String jql , final L result ) { final One < Boolean > valid = new One < > ( ) ; if ( ! StringUtils . hasText ( jql ) ) return result ; valid . value0 = false ; analyzeVariableStatementInternal ( jqlContext , jql , new JqlBaseListener ( ) { public void enterBind_parameter ( Bind_parameterContext ctx ) { String parameter ; if ( ctx . bind_parameter_name ( ) != null ) { parameter = ctx . bind_parameter_name ( ) . getText ( ) ; } else { parameter = ctx . getText ( ) ; } result . add ( new JQLPlaceHolder ( JQLPlaceHolderType . PARAMETER , parameter ) ) ; } public void enterBind_dynamic_sql ( Bind_dynamic_sqlContext ctx ) { result . add ( new JQLPlaceHolder ( JQLPlaceHolderType . DYNAMIC_SQL , ctx . bind_parameter_name ( ) . getText ( ) ) ) ; } } ) ; return result ; }
|
Extract place holders from variable statement .
|
4,688
|
void generateSerializeInternal ( BindTypeContext context , MethodSpec . Builder methodBuilder , String serializerName , TypeName beanClass , String beanName , BindProperty property , boolean onString ) { TypeName typeName = property . getPropertyType ( ) . getTypeName ( ) ; String bindName = context . getBindMapperName ( context , typeName ) ; if ( property . isNullable ( ) ) { methodBuilder . beginControlFlow ( "if ($L!=null) " , getter ( beanName , beanClass , property ) ) ; } if ( property . isProperty ( ) ) { methodBuilder . addStatement ( "fieldCount++" ) ; } if ( ! property . isInCollection ( ) ) { methodBuilder . addStatement ( "$L.writeFieldName($S)" , serializerName , property . label ) ; } if ( onString ) { methodBuilder . beginControlFlow ( "if ($L.serializeOnJacksonAsString($L, jacksonSerializer)==0)" , bindName , getter ( beanName , beanClass , property ) ) ; methodBuilder . addStatement ( "$L.writeNullField($S)" , serializerName , property . label ) ; methodBuilder . endControlFlow ( ) ; } else { methodBuilder . addStatement ( "$L.serializeOnJackson($L, jacksonSerializer)" , bindName , getter ( beanName , beanClass , property ) ) ; } if ( property . isNullable ( ) ) { methodBuilder . endControlFlow ( ) ; } }
|
Generate serialize internal .
|
4,689
|
public static String daoName ( SQLiteDaoDefinition value ) { String classTableName = value . getName ( ) ; classTableName = classTableName + SUFFIX ; return classTableName ; }
|
Dao name .
|
4,690
|
static List < String > extractAsArrayOfClassName ( String value ) { Matcher matcher = classPattern . matcher ( value ) ; List < String > result = new ArrayList < String > ( ) ; while ( matcher . find ( ) ) { result . add ( matcher . group ( 1 ) ) ; } return result ; }
|
Extract as array of class name .
|
4,691
|
public static List < String > extractAsArrayOfString ( String value ) { Matcher matcher = arrayPattern . matcher ( value ) ; List < String > result = new ArrayList < String > ( ) ; while ( matcher . find ( ) ) { result . add ( StringEscapeUtils . unescapeEcmaScript ( matcher . group ( 1 ) ) ) ; } return result ; }
|
Extract as array of string .
|
4,692
|
public static void forEachAnnotations ( Element currentElement , AnnotationFilter filter , AnnotationFoundListener listener ) { final Elements elementUtils = BaseProcessor . elementUtils ; List < ? extends AnnotationMirror > annotationList = elementUtils . getAllAnnotationMirrors ( currentElement ) ; String annotationClassName ; for ( AnnotationMirror annotation : annotationList ) { Map < String , String > values = new HashMap < String , String > ( ) ; annotationClassName = annotation . getAnnotationType ( ) . asElement ( ) . toString ( ) ; if ( filter != null && ! filter . isAccepted ( annotationClassName ) ) { continue ; } values . clear ( ) ; for ( Entry < ? extends ExecutableElement , ? extends AnnotationValue > annotationItem : elementUtils . getElementValuesWithDefaults ( annotation ) . entrySet ( ) ) { String value = annotationItem . getValue ( ) . toString ( ) ; if ( value . startsWith ( "\"" ) && value . endsWith ( "\"" ) ) { value = value . substring ( 1 ) ; value = value . substring ( 0 , value . length ( ) - 1 ) ; } values . put ( annotationItem . getKey ( ) . getSimpleName ( ) . toString ( ) , value ) ; } if ( listener != null ) { listener . onAcceptAnnotation ( currentElement , annotationClassName , values ) ; } } }
|
Iterate over annotations of currentElement . Accept only annotation in accepted set .
|
4,693
|
static void extractString ( Elements elementUtils , Element item , Class < ? extends Annotation > annotationClass , AnnotationAttributeType attribute , OnAttributeFoundListener listener ) { extractAttributeValue ( elementUtils , item , annotationClass . getCanonicalName ( ) , attribute , listener ) ; }
|
Extract string .
|
4,694
|
public static List < ModelAnnotation > buildAnnotationList ( final Element element , final AnnotationFilter filter ) { final List < ModelAnnotation > annotationList = new ArrayList < > ( ) ; forEachAnnotations ( element , filter , new AnnotationFoundListener ( ) { public void onAcceptAnnotation ( Element executableMethod , String annotationClassName , Map < String , String > attributes ) { ModelAnnotation annotation = new ModelAnnotation ( annotationClassName , attributes ) ; annotationList . add ( annotation ) ; } } ) ; return annotationList ; }
|
Builds the annotation list .
|
4,695
|
public static int extractAsInt ( Element item , Class < ? extends Annotation > annotationClass , AnnotationAttributeType attributeName ) { final Elements elementUtils = BaseProcessor . elementUtils ; final One < Integer > result = new One < Integer > ( ) ; result . value0 = 0 ; extractString ( elementUtils , item , annotationClass , attributeName , new OnAttributeFoundListener ( ) { public void onFound ( String value ) { result . value0 = Integer . parseInt ( value ) ; } } ) ; return result . value0 ; }
|
Extract as int .
|
4,696
|
public static boolean extractAsBoolean ( Element item , Class < ? extends Annotation > annotationClass , AnnotationAttributeType attribute ) { final Elements elementUtils = BaseProcessor . elementUtils ; final One < Boolean > result = new One < Boolean > ( false ) ; extractString ( elementUtils , item , annotationClass , attribute , new OnAttributeFoundListener ( ) { public void onFound ( String value ) { result . value0 = Boolean . parseBoolean ( value ) ; } } ) ; return result . value0 ; }
|
Extract as boolean .
|
4,697
|
public static < E extends ModelEntity < ? > > boolean extractAsBoolean ( E item , ModelAnnotation annotation , AnnotationAttributeType attribute ) { final Elements elementUtils = BaseProcessor . elementUtils ; final One < Boolean > result = new One < Boolean > ( false ) ; extractAttributeValue ( elementUtils , item . getElement ( ) , annotation . getName ( ) , attribute , new OnAttributeFoundListener ( ) { public void onFound ( String value ) { result . value0 = Boolean . valueOf ( value ) ; } } ) ; return result . value0 ; }
|
Estract from an annotation of a method the attribute value specified .
|
4,698
|
public static Boolean getAnnotationAttributeAsBoolean ( ModelWithAnnotation model , Class < ? extends Annotation > annotation , AnnotationAttributeType attribute , Boolean defaultValue ) { return getAnnotationAttribute ( model , annotation , attribute , defaultValue , new OnAnnotationAttributeListener < Boolean > ( ) { public Boolean onFound ( String value ) { return Boolean . valueOf ( value ) ; } } ) ; }
|
Gets the annotation attribute as boolean .
|
4,699
|
static < T > T getAnnotationAttribute ( ModelWithAnnotation model , Class < ? extends Annotation > annotation , AnnotationAttributeType attribute , T defaultValue , OnAnnotationAttributeListener < T > listener ) { String attributeResult ; ModelAnnotation item = model . getAnnotation ( annotation ) ; if ( item != null ) { attributeResult = item . getAttribute ( attribute ) ; return listener . onFound ( attributeResult ) ; } return defaultValue ; }
|
Gets the annotation attribute .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.