idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
39,000 | public static String formatSQL ( String sql ) { if ( sql == null || sql . length ( ) == 0 ) return sql ; StringBuilder sb = new StringBuilder ( ) ; char [ ] chars = sql . toCharArray ( ) ; boolean addedSpace = false ; for ( char c : chars ) { if ( isInvisibleChar ( c ) ) { if ( ! addedSpace ) { sb . append ( " " ) ; addedSpace = true ; } } else { sb . append ( c ) ; addedSpace = false ; } } sb . append ( " " ) ; return sb . toString ( ) ; } | Format all \ t \ r ... to |
39,001 | public Object getNextID ( NormalJdbcTool jdbc , Dialect dialect , Type dataType ) { int countOfRec = ( ( Number ) jdbc . nQueryForObject ( "select count(*) from " + table + " where " + pkColumnName + "=?" , pkColumnValue ) ) . intValue ( ) ; if ( countOfRec == 0 ) { jdbc . nUpdate ( "insert into " + table + "( " + pkColumnName + "," + valueColumnName + " ) values(?,?)" , pkColumnValue , initialValue ) ; return initialValue ; } else { jdbc . nUpdate ( "update " + table + " set " + valueColumnName + "=" + valueColumnName + "+" + allocationSize + " where " + pkColumnName + " =?" , pkColumnValue ) ; int last = ( ( Number ) jdbc . nQueryForObject ( "select " + valueColumnName + " from " + table + " where " + pkColumnName + "=?" , pkColumnValue ) ) . intValue ( ) ; return last ; } } | Get the next Table Generator ID |
39,002 | private static List < Map < String , Object > > getEntityAnnos ( Object targetClass , String annotationName ) { Annotation [ ] anno = null ; if ( targetClass instanceof Field ) anno = ( ( Field ) targetClass ) . getAnnotations ( ) ; else anno = ( ( Class < ? > ) targetClass ) . getAnnotations ( ) ; List < Map < String , Object > > l = new ArrayList < Map < String , Object > > ( ) ; for ( Annotation annotation : anno ) { Class < ? extends Annotation > type = annotation . annotationType ( ) ; String cName = type . getName ( ) ; if ( matchNameCheck ( annotationName , cName ) ) { l . add ( changeAnnotationValuesToMap ( annotation , type ) ) ; } } return l ; } | Get all entity annotations started with annotationName |
39,003 | private static Map < String , Object > changeAnnotationValuesToMap ( Annotation annotation , Class < ? extends Annotation > type ) { Map < String , Object > result = new HashMap < String , Object > ( ) ; result . put ( "AnnotationExist" , true ) ; for ( Method method : type . getDeclaredMethods ( ) ) try { result . put ( method . getName ( ) , method . invoke ( annotation , ( Object [ ] ) null ) ) ; } catch ( Exception e ) { } return result ; } | Change Annotation fields values into a Map |
39,004 | public static TableModel entity2ReadOnlyModel ( Class < ? > entityClass ) { DialectException . assureNotNull ( entityClass , "Entity class can not be null" ) ; TableModel model = globalTableModelCache . get ( entityClass ) ; if ( model != null ) return model ; model = entity2ModelWithConfig ( entityClass ) ; model . setReadOnly ( true ) ; globalTableModelCache . put ( entityClass , model ) ; return model ; } | Convert entity class to a read - only TableModel instance |
39,005 | public static TableModel [ ] entity2ReadOnlyModel ( Class < ? > ... entityClasses ) { List < TableModel > l = new ArrayList < TableModel > ( ) ; for ( Class < ? > clazz : entityClasses ) { l . add ( entity2ReadOnlyModel ( clazz ) ) ; } return l . toArray ( new TableModel [ l . size ( ) ] ) ; } | Convert entity classes to a read - only TableModel instances |
39,006 | public static TableModel [ ] entity2EditableModels ( Class < ? > ... entityClasses ) { List < TableModel > l = new ArrayList < TableModel > ( ) ; for ( Class < ? > clazz : entityClasses ) { l . add ( entity2EditableModel ( clazz ) ) ; } return l . toArray ( new TableModel [ l . size ( ) ] ) ; } | Convert entity classes to a editable TableModel instances |
39,007 | public static Method checkMethodExist ( Class < ? > clazz , String uniqueMethodName ) { if ( clazz == null || StrUtils . isEmpty ( uniqueMethodName ) ) return null ; Map < String , Object > methodMap = uniqueMethodCache . get ( clazz ) ; if ( methodMap != null && ! methodMap . isEmpty ( ) ) { Object result = methodMap . get ( uniqueMethodName ) ; if ( result != null ) { if ( ClassOrMethodNotExist . class . equals ( result ) ) return null ; else return ( Method ) result ; } } if ( methodMap == null ) { methodMap = new HashMap < String , Object > ( ) ; uniqueMethodCache . put ( clazz , methodMap ) ; } Method [ ] methods = clazz . getMethods ( ) ; for ( Method method : methods ) if ( uniqueMethodName != null && uniqueMethodName . equals ( method . getName ( ) ) ) { methodMap . put ( uniqueMethodName , method ) ; return method ; } methodMap . put ( uniqueMethodName , ClassOrMethodNotExist . class ) ; return null ; } | Check if a unique method name exists in class if exist return the method otherwise return null |
39,008 | public static Map < String , Method > getClassReadMethods ( Class < ? > clazz ) { Map < String , Method > readMethods = classReadMethods . get ( clazz ) ; if ( readMethods == null ) { cacheReadWriteMethodsAndBoxField ( clazz ) ; return classReadMethods . get ( clazz ) ; } else return readMethods ; } | Return cached class read methods to avoid each time use reflect |
39,009 | public static Method getClassFieldReadMethod ( Class < ? > clazz , String fieldName ) { return getClassReadMethods ( clazz ) . get ( fieldName ) ; } | Return cached class field read method to avoid each time use reflect |
39,010 | public static Map < String , Method > getClassWriteMethods ( Class < ? > clazz ) { Map < String , Method > writeMethods = classWriteMethods . get ( clazz ) ; if ( writeMethods == null ) { cacheReadWriteMethodsAndBoxField ( clazz ) ; return classWriteMethods . get ( clazz ) ; } else return writeMethods ; } | Return cached class write methods to avoid each time use reflect |
39,011 | public static Method getClassFieldWriteMethod ( Class < ? > clazz , String fieldName ) { return getClassWriteMethods ( clazz ) . get ( fieldName ) ; } | Return cached class field write method to avoid each time use reflect |
39,012 | public static Object readValueFromBeanField ( Object entityBean , String fieldName ) { Method readMethod = ClassCacheUtils . getClassFieldReadMethod ( entityBean . getClass ( ) , fieldName ) ; if ( readMethod == null ) { throw new DialectException ( "No mapping found for field '" + fieldName + "' in '" + entityBean . getClass ( ) + "'" ) ; } else try { return readMethod . invoke ( entityBean ) ; } catch ( Exception e ) { throw new DialectException ( e ) ; } } | Read value from entityBean field |
39,013 | public static void writeValueToBeanField ( Object entityBean , String fieldName , Object value ) { Method writeMethod = ClassCacheUtils . getClassFieldWriteMethod ( entityBean . getClass ( ) , fieldName ) ; if ( writeMethod == null ) { throw new DialectException ( "Can not find Java bean read method '" + fieldName + "'" ) ; } else try { writeMethod . invoke ( entityBean , value ) ; } catch ( Exception e ) { throw new DialectException ( "FieldName '" + fieldName + "' can not write with value '" + value + "'" , e ) ; } } | write value to entityBean field |
39,014 | DialectSqlItem [ ] seperateCharsToItems ( char [ ] chars , int start , int end ) { List < DialectSqlItem > items = new ArrayList < DialectSqlItem > ( ) ; SearchResult result = findFirstResult ( chars , start , end ) ; while ( result != null ) { items . add ( result . item ) ; result = findFirstResult ( chars , result . leftStart , result . leftEnd ) ; } return items . toArray ( new DialectSqlItem [ items . size ( ) ] ) ; } | Separate chars to Items list |
39,015 | void correctType ( DialectSqlItem item ) { if ( item . type == 'U' ) { String valueStr = ( String ) item . value ; String valueUpcase = valueStr . toUpperCase ( ) ; String funPrefix = Dialect . getGlobalSqlFunctionPrefix ( ) ; if ( ! StrUtils . isEmpty ( valueUpcase ) ) { if ( ! StrUtils . isEmpty ( funPrefix ) && StrUtils . startsWithIgnoreCase ( valueUpcase , funPrefix ) && functionMap . containsKey ( valueUpcase . substring ( funPrefix . length ( ) ) ) ) { item . type = 'F' ; item . value = valueStr . substring ( funPrefix . length ( ) ) ; } if ( ( StrUtils . isEmpty ( funPrefix ) && functionMap . containsKey ( valueUpcase ) ) ) { item . type = 'F' ; item . value = valueStr ; } } if ( item . type == 'U' ) if ( "," . equals ( valueStr ) ) item . setTypeAndValue ( ',' , valueStr ) ; else item . setTypeAndValue ( 'S' , valueStr ) ; } if ( item . subItems != null ) for ( DialectSqlItem t : item . subItems ) correctType ( t ) ; } | if is U type use this method to correct type |
39,016 | String join ( Dialect d , boolean isTopLevel , DialectSqlItem function , DialectSqlItem [ ] items ) { int pos = 0 ; for ( DialectSqlItem item : items ) { if ( item . subItems != null ) { String value ; if ( pos > 0 && items [ pos - 1 ] != null && items [ pos - 1 ] . type == 'F' ) value = join ( d , false , items [ pos - 1 ] , item . subItems ) ; else value = join ( d , false , null , item . subItems ) ; item . type = 'S' ; item . value = value ; item . subItems = null ; } pos ++ ; } if ( function != null ) { List < String > l = new ArrayList < String > ( ) ; for ( DialectSqlItem item : items ) { if ( item . type != '0' ) l . add ( ( String ) item . value ) ; } return renderFunction ( d , function , l . toArray ( new String [ l . size ( ) ] ) ) ; } StringBuilder sb = new StringBuilder ( ) ; if ( ! isTopLevel ) sb . append ( "(" ) ; for ( DialectSqlItem item : items ) if ( item . type != '0' ) { sb . append ( item . value ) ; } if ( ! isTopLevel ) sb . append ( ")" ) ; return sb . toString ( ) ; } | Join items list into one String if function is null join as String otherwise treat as function parameters |
39,017 | public synchronized long nextId ( ) { long currTimestamp = timestampGen ( ) ; if ( currTimestamp < lastTimestamp ) { throw new IllegalStateException ( String . format ( "Clock moved backwards. Refusing to generate id for %d milliseconds" , lastTimestamp - currTimestamp ) ) ; } if ( currTimestamp == lastTimestamp ) { sequence = ( sequence + 1 ) & maxSequence ; if ( sequence == 0 ) { currTimestamp = waitNextMillis ( currTimestamp ) ; } } else { sequence = 0L ; } lastTimestamp = currTimestamp ; return ( ( currTimestamp - epoch ) << timestampShift ) | ( datacenterId << datacenterIdShift ) | ( workerId << workerIdShift ) | sequence ; } | generate an unique and incrementing id |
39,018 | public long [ ] parseId ( long id ) { long [ ] arr = new long [ 5 ] ; arr [ 4 ] = ( ( id & diode ( unusedBits , timestampBits ) ) >> timestampShift ) ; arr [ 0 ] = arr [ 4 ] + epoch ; arr [ 1 ] = ( id & diode ( unusedBits + timestampBits , datacenterIdBits ) ) >> datacenterIdShift ; arr [ 2 ] = ( id & diode ( unusedBits + timestampBits + datacenterIdBits , workerIdBits ) ) >> workerIdShift ; arr [ 3 ] = ( id & diode ( unusedBits + timestampBits + datacenterIdBits + workerIdBits , sequenceBits ) ) ; return arr ; } | extract time stamp datacenterId workerId and sequence number information from the given id |
39,019 | public String formatId ( long id ) { long [ ] arr = parseId ( id ) ; String tmf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss.SSS" ) . format ( new Date ( arr [ 0 ] ) ) ; return String . format ( "%s, #%d, @(%d,%d)" , tmf , arr [ 3 ] , arr [ 1 ] , arr [ 2 ] ) ; } | extract and display time stamp datacenterId workerId and sequence number information from the given id in humanization format |
39,020 | private long diode ( long offset , long length ) { int lb = ( int ) ( 64 - offset ) ; int rb = ( int ) ( 64 - ( offset + length ) ) ; return ( - 1L << lb ) ^ ( - 1L << rb ) ; } | a diode is a long value whose left and right margin are ZERO while middle bits are ONE in binary string layout . it looks like a diode in shape . |
39,021 | public static Type toType ( Class < ? > clazz ) { Type t = SQL_MAP_ABLE_TYPES . get ( clazz ) ; if ( t == null ) return Type . OTHER ; else return t ; } | Convert a Class type to Dialect s Type |
39,022 | public static Type toType ( String columnDef ) { if ( "BIGINT" . equalsIgnoreCase ( columnDef ) ) return Type . BIGINT ; if ( "BINARY" . equalsIgnoreCase ( columnDef ) ) return Type . BINARY ; if ( "BIT" . equalsIgnoreCase ( columnDef ) ) return Type . BIT ; if ( "BLOB" . equalsIgnoreCase ( columnDef ) ) return Type . BLOB ; if ( "BOOLEAN" . equalsIgnoreCase ( columnDef ) ) return Type . BOOLEAN ; if ( "CHAR" . equalsIgnoreCase ( columnDef ) ) return Type . CHAR ; if ( "CLOB" . equalsIgnoreCase ( columnDef ) ) return Type . CLOB ; if ( "DATE" . equalsIgnoreCase ( columnDef ) ) return Type . DATE ; if ( "DECIMAL" . equalsIgnoreCase ( columnDef ) ) return Type . DECIMAL ; if ( "DOUBLE" . equalsIgnoreCase ( columnDef ) ) return Type . DOUBLE ; if ( "FLOAT" . equalsIgnoreCase ( columnDef ) ) return Type . FLOAT ; if ( "INTEGER" . equalsIgnoreCase ( columnDef ) ) return Type . INTEGER ; if ( "JAVA_OBJECT" . equalsIgnoreCase ( columnDef ) ) return Type . JAVA_OBJECT ; if ( "LONGNVARCHAR" . equalsIgnoreCase ( columnDef ) ) return Type . LONGNVARCHAR ; if ( "LONGVARBINARY" . equalsIgnoreCase ( columnDef ) ) return Type . LONGVARBINARY ; if ( "LONGVARCHAR" . equalsIgnoreCase ( columnDef ) ) return Type . LONGVARCHAR ; if ( "NCHAR" . equalsIgnoreCase ( columnDef ) ) return Type . NCHAR ; if ( "NCLOB" . equalsIgnoreCase ( columnDef ) ) return Type . NCLOB ; if ( "NUMERIC" . equalsIgnoreCase ( columnDef ) ) return Type . NUMERIC ; if ( "NVARCHAR" . equalsIgnoreCase ( columnDef ) ) return Type . NVARCHAR ; if ( "OTHER" . equalsIgnoreCase ( columnDef ) ) return Type . OTHER ; if ( "REAL" . equalsIgnoreCase ( columnDef ) ) return Type . REAL ; if ( "SMALLINT" . equalsIgnoreCase ( columnDef ) ) return Type . SMALLINT ; if ( "TIME" . equalsIgnoreCase ( columnDef ) ) return Type . TIME ; if ( "TIMESTAMP" . equalsIgnoreCase ( columnDef ) ) return Type . TIMESTAMP ; if ( "TINYINT" . equalsIgnoreCase ( columnDef ) ) return Type . TINYINT ; if ( "VARBINARY" . equalsIgnoreCase ( columnDef ) ) return Type . VARBINARY ; if ( "VARCHAR" . equalsIgnoreCase ( columnDef ) ) return Type . VARCHAR ; throw new DialectException ( "'" + columnDef + "' is not a legal SQL column definition name" ) ; } | Convert column definition String to Dialect s Type |
39,023 | public static Type javaSqlTypeToDialectType ( int javaSqlType ) { switch ( javaSqlType ) { case java . sql . Types . BIT : return Type . BIT ; case java . sql . Types . TINYINT : return Type . TINYINT ; case java . sql . Types . SMALLINT : return Type . SMALLINT ; case java . sql . Types . INTEGER : return Type . INTEGER ; case java . sql . Types . BIGINT : return Type . BIGINT ; case java . sql . Types . FLOAT : return Type . FLOAT ; case java . sql . Types . REAL : return Type . REAL ; case java . sql . Types . DOUBLE : return Type . DOUBLE ; case java . sql . Types . NUMERIC : return Type . NUMERIC ; case java . sql . Types . DECIMAL : return Type . DECIMAL ; case java . sql . Types . CHAR : return Type . CHAR ; case java . sql . Types . VARCHAR : return Type . VARCHAR ; case java . sql . Types . LONGVARCHAR : return Type . LONGVARCHAR ; case java . sql . Types . DATE : return Type . DATE ; case java . sql . Types . TIME : return Type . TIME ; case java . sql . Types . TIMESTAMP : return Type . TIMESTAMP ; case java . sql . Types . BINARY : return Type . BINARY ; case java . sql . Types . VARBINARY : return Type . VARBINARY ; case java . sql . Types . LONGVARBINARY : return Type . LONGVARBINARY ; case java . sql . Types . OTHER : return Type . OTHER ; case java . sql . Types . JAVA_OBJECT : return Type . JAVA_OBJECT ; case java . sql . Types . BLOB : return Type . BLOB ; case java . sql . Types . CLOB : return Type . CLOB ; case java . sql . Types . BOOLEAN : return Type . BOOLEAN ; case java . sql . Types . NCHAR : return Type . NCHAR ; case java . sql . Types . NVARCHAR : return Type . NVARCHAR ; case java . sql . Types . LONGNVARCHAR : return Type . LONGNVARCHAR ; case java . sql . Types . NCLOB : return Type . NCLOB ; default : throw new DialectException ( "Not supported java.sql.Types value:" + javaSqlType ) ; } } | Convert java . sql . Types . xxx type to Dialect s Type |
39,024 | public ColumnModel sequenceGenerator ( String name , String sequenceName , Integer initialValue , Integer allocationSize ) { makeSureTableModelExist ( ) ; this . tableModel . sequenceGenerator ( name , sequenceName , initialValue , allocationSize ) ; this . idGenerationType = GenerationType . SEQUENCE ; this . idGeneratorName = name ; return this ; } | The value of this column will be generated by a sequence |
39,025 | public ColumnModel entityField ( String entityFieldName ) { DialectException . assureNotEmpty ( entityFieldName , "entityFieldName can not be empty" ) ; this . entityField = entityFieldName ; if ( this . tableModel != null ) { List < ColumnModel > oldColumns = this . tableModel . getColumns ( ) ; Iterator < ColumnModel > columnIter = oldColumns . iterator ( ) ; while ( columnIter . hasNext ( ) ) { ColumnModel column = columnIter . next ( ) ; if ( entityFieldName . equals ( column . getEntityField ( ) ) && ! this . getColumnName ( ) . equals ( column . getColumnName ( ) ) ) columnIter . remove ( ) ; } } return this ; } | Mark this column map to a Java entity field if exist other columns map to this field delete other columns . This method only designed for ORM tool |
39,026 | protected static String initializePaginSQLTemplate ( Dialect d ) { switch ( d ) { case Cache71Dialect : case DB2390Dialect : case DB2390V8Dialect : case FrontBaseDialect : case InformixDialect : case IngresDialect : case JDataStoreDialect : case MckoiDialect : case MimerSQLDialect : case PointbaseDialect : case ProgressDialect : case RDMSOS2200Dialect : case SAPDBDialect : case SQLServerDialect : case Sybase11Dialect : case SybaseASE15Dialect : case SybaseAnywhereDialect : case SybaseDialect : case Teradata14Dialect : case TeradataDialect : case TimesTenDialect : return Dialect . NOT_SUPPORT ; case SQLServer2005Dialect : case SQLServer2008Dialect : return "WITH query AS (SELECT TMP_.*, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as ROW_NUM_ FROM ( select ($DISTINCT) TOP($TOTAL_ROWS) $BODY ) TMP_ ) SELECT * FROM query WHERE ROW_NUM_ >$SKIP_ROWS AND ROW_NUM_ <= $TOTAL_ROWS" ; case H2Dialect : case HANAColumnStoreDialect : case HANARowStoreDialect : case PostgreSQL81Dialect : case PostgreSQL82Dialect : case PostgreSQL91Dialect : case PostgreSQL92Dialect : case PostgreSQL93Dialect : case PostgreSQL94Dialect : case PostgreSQL95Dialect : case PostgreSQL9Dialect : case PostgreSQLDialect : case PostgresPlusDialect : case SQLiteDialect : return "select $BODY limit $PAGESIZE offset $SKIP_ROWS" ; case AccessDialect : case CUBRIDDialect : case CobolDialect : case DbfDialect : case ExcelDialect : case MariaDB102Dialect : case MariaDB103Dialect : case MariaDB10Dialect : case MariaDB53Dialect : case MariaDBDialect : case MySQL55Dialect : case MySQL57Dialect : case MySQL57InnoDBDialect : case MySQL5Dialect : case MySQL5InnoDBDialect : case MySQL8Dialect : case MySQLDialect : case MySQLInnoDBDialect : case MySQLMyISAMDialect : case ParadoxDialect : case TextDialect : case XMLDialect : return "select $BODY limit $SKIP_ROWS, $PAGESIZE" ; case SQLServer2012Dialect : return "select $BODY offset $SKIP_ROWS rows fetch next $PAGESIZE rows only" ; case Ingres10Dialect : case Ingres9Dialect : return "select $BODY offset $skip_rows fetch first $pagesize rows only" ; case DerbyDialect : case DerbyTenFiveDialect : case DerbyTenSevenDialect : case DerbyTenSixDialect : return "select $BODY offset $skip_rows rows fetch next $pagesize rows only" ; case InterbaseDialect : return "select $BODY rows $SKIP_ROWS to $PAGESIZE" ; case SybaseASE157Dialect : return "select ($DISTINCT) top $total_rows $BODY" ; case DB2400Dialect : case DB297Dialect : case DB2Dialect : return "select * from ( select inner2_.*, rownumber() over(order by order of inner2_) as rownumber_ from ( select $BODY fetch first $total_rows rows only ) as inner2_ ) as inner1_ where rownumber_ > $skip_rows order by rownumber_" ; case Oracle8iDialect : case OracleDialect : return "select * from ( select row_.*, rownum rownum_ from ( select $BODY ) row_ ) where rownum_ <= $TOTAL_ROWS and rownum_ > $SKIP_ROWS" ; case DataDirectOracle9Dialect : case Oracle10gDialect : case Oracle12cDialect : case Oracle9Dialect : case Oracle9iDialect : return "select * from ( select row_.*, rownum rownum_ from ( select $BODY ) row_ where rownum <= $TOTAL_ROWS) where rownum_ > $SKIP_ROWS" ; case Informix10Dialect : return "select SKIP $skip_rows first $pagesize $BODY" ; case FirebirdDialect : return "select first $PAGESIZE skip $SKIP_ROWS $BODY" ; case HSQLDialect : return "select limit $SKIP_ROWS $PAGESIZE $BODY" ; default : return Dialect . NOT_SUPPORT ; } } | Return pagination template of this Dialect |
39,027 | public static void db2JavaSrcFiles ( DataSource ds , Dialect dialect , boolean linkStyle , boolean activeRecord , String packageName , String outputfolder ) { Connection conn = null ; try { conn = ds . getConnection ( ) ; TableModel [ ] models = db2Models ( conn , dialect ) ; for ( TableModel model : models ) { File writename = new File ( outputfolder + "/" + TableModelUtilsOfJavaSrc . getClassNameFromTableModel ( model ) + ".java" ) ; writename . createNewFile ( ) ; BufferedWriter out = new BufferedWriter ( new FileWriter ( writename ) ) ; String javaSrc = model2JavaSrc ( model , linkStyle , activeRecord , packageName ) ; out . write ( javaSrc ) ; out . flush ( ) ; out . close ( ) ; } } catch ( Exception e ) { if ( conn != null ) try { conn . close ( ) ; } catch ( SQLException e1 ) { e1 . printStackTrace ( ) ; } } } | Read database structure and write them to Java entity class source code |
39,028 | public static void bindGlobalModel ( Class < ? > entityClass , TableModel tableModel ) { TableModelUtilsOfEntity . globalTableModelCache . put ( entityClass , tableModel ) ; } | This method bind a tableModel to a entity class this is a global setting |
39,029 | public void tableGenerator ( String name , String tableName , String pkColumnName , String valueColumnName , String pkColumnValue , Integer initialValue , Integer allocationSize ) { checkReadOnly ( ) ; addGenerator ( new TableIdGenerator ( name , tableName , pkColumnName , valueColumnName , pkColumnValue , initialValue , allocationSize ) ) ; } | Add a TableGenerator |
39,030 | public void uuidAny ( String name , Integer length ) { checkReadOnly ( ) ; addGenerator ( new UUIDAnyGenerator ( name , length ) ) ; } | Add a UUIDAnyGenerator |
39,031 | public void addGenerator ( IdGenerator generator ) { checkReadOnly ( ) ; DialectException . assureNotNull ( generator ) ; DialectException . assureNotNull ( generator . getGenerationType ( ) ) ; DialectException . assureNotEmpty ( generator . getIdGenName ( ) , "IdGenerator name can not be empty" ) ; getIdGenerators ( ) . add ( generator ) ; } | Add a create table ... DDL to generate ID similar like JPA s TableGen |
39,032 | public TableModel addColumn ( ColumnModel column ) { checkReadOnly ( ) ; DialectException . assureNotNull ( column ) ; DialectException . assureNotEmpty ( column . getColumnName ( ) , "Column's columnName can not be empty" ) ; column . setTableModel ( this ) ; columns . add ( column ) ; return this ; } | Add a ColumnModel |
39,033 | public TableModel removeColumn ( String columnName ) { checkReadOnly ( ) ; List < ColumnModel > oldColumns = this . getColumns ( ) ; Iterator < ColumnModel > columnIter = oldColumns . iterator ( ) ; while ( columnIter . hasNext ( ) ) if ( columnIter . next ( ) . getColumnName ( ) . equalsIgnoreCase ( columnName ) ) columnIter . remove ( ) ; return this ; } | Remove a ColumnModel by given columnName |
39,034 | public TableModel removeFKey ( String fkeyName ) { checkReadOnly ( ) ; List < FKeyModel > fkeys = getFkeyConstraints ( ) ; Iterator < FKeyModel > fkeyIter = fkeys . iterator ( ) ; while ( fkeyIter . hasNext ( ) ) if ( fkeyIter . next ( ) . getFkeyName ( ) . equalsIgnoreCase ( fkeyName ) ) fkeyIter . remove ( ) ; return this ; } | Remove a FKey by given fkeyName |
39,035 | public ColumnModel column ( String columnName ) { for ( ColumnModel columnModel : columns ) { if ( columnModel . getColumnName ( ) != null && columnModel . getColumnName ( ) . equalsIgnoreCase ( columnName ) ) return columnModel ; if ( columnModel . getEntityField ( ) != null && columnModel . getEntityField ( ) . equalsIgnoreCase ( columnName ) ) return columnModel ; } return addColumn ( columnName ) ; } | find column in tableModel by given columnName if not found add a new column with columnName |
39,036 | public ColumnModel addColumn ( String columnName ) { checkReadOnly ( ) ; DialectException . assureNotEmpty ( columnName , "columnName can not be empty" ) ; for ( ColumnModel columnModel : columns ) if ( columnName . equalsIgnoreCase ( columnModel . getColumnName ( ) ) ) throw new DialectException ( "ColumnModel name '" + columnName + "' already existed" ) ; ColumnModel column = new ColumnModel ( columnName ) ; addColumn ( column ) ; return column ; } | Add a column with given columnName to tableModel |
39,037 | public ColumnModel getColumn ( String colOrFieldName ) { for ( ColumnModel columnModel : columns ) { if ( columnModel . getColumnName ( ) != null && columnModel . getColumnName ( ) . equalsIgnoreCase ( colOrFieldName ) ) return columnModel ; if ( columnModel . getEntityField ( ) != null && columnModel . getEntityField ( ) . equalsIgnoreCase ( colOrFieldName ) ) return columnModel ; } return null ; } | Get ColumnModel by column Name or field name ignore case if not found return null |
39,038 | public ColumnModel getColumnByColName ( String colName ) { for ( ColumnModel columnModel : columns ) { if ( columnModel . getColumnName ( ) != null && columnModel . getColumnName ( ) . equalsIgnoreCase ( colName ) ) return columnModel ; } return null ; } | Get ColumnModel by columnName ignore case if not found return null |
39,039 | public ColumnModel getColumnByFieldName ( String fieldName ) { for ( ColumnModel columnModel : columns ) if ( columnModel . getEntityField ( ) != null && columnModel . getEntityField ( ) . equalsIgnoreCase ( fieldName ) ) return columnModel ; return null ; } | Get ColumnModel by entity field name ignore case if not found return null |
39,040 | public FKeyModel getFkey ( String fkeyName ) { if ( fkeyConstraints == null ) return null ; for ( FKeyModel fkey : fkeyConstraints ) if ( ! StrUtils . isEmpty ( fkeyName ) && fkeyName . equalsIgnoreCase ( fkey . getFkeyName ( ) ) ) return fkey ; return null ; } | Get a FKeyModel by given fkeyName |
39,041 | public IdGenerator getIdGenerator ( GenerationType generationType , String name ) { return getIdGenerator ( generationType , name , getIdGenerators ( ) ) ; } | Search and return the IdGenerator in this TableModel by its generationType and name |
39,042 | public static IdGenerator getIdGenerator ( GenerationType generationType , String name , List < IdGenerator > idGeneratorList ) { IdGenerator idGen = getIdGeneratorByType ( generationType ) ; if ( idGen != null ) return idGen ; if ( StrUtils . isEmpty ( name ) ) return null ; for ( IdGenerator idGenerator : idGeneratorList ) { if ( generationType != null && name . equalsIgnoreCase ( idGenerator . getIdGenName ( ) ) ) return idGenerator ; if ( ( generationType == null || GenerationType . OTHER . equals ( generationType ) ) && name . equalsIgnoreCase ( idGenerator . getIdGenName ( ) ) ) return idGenerator ; } return null ; } | Get a IdGenerator by type if not found search by name |
39,043 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public List < ColumnModel > getPKeyColsSortByColumnName ( ) { List < ColumnModel > pkeyCols = new ArrayList < ColumnModel > ( ) ; for ( ColumnModel col : columns ) if ( col . getPkey ( ) && ! col . getTransientable ( ) ) pkeyCols . add ( col ) ; Collections . sort ( pkeyCols , new Comparator ( ) { public int compare ( Object o1 , Object o2 ) { return ( ( ColumnModel ) o1 ) . getColumnName ( ) . compareTo ( ( ( ColumnModel ) o1 ) . getColumnName ( ) ) ; } } ) ; return pkeyCols ; } | Get pkey columns sorted by column name |
39,044 | public static Reader createReaderForFile ( File source , Encoding encoding ) throws FileNotFoundException , UnsupportedEncodingException { return createReaderForInputStream ( new FileInputStream ( source ) , encoding ) ; } | Instanciate a Reader for a file using the given encoding . |
39,045 | public static Map < String , String > loadBundle ( List < URL > sources , Encoding encoding , String newline ) throws IOException , SyntaxErrorException { Map < String , String > _result = new HashMap < String , String > ( ) ; for ( URL _source : sources ) { Map < String , String > _properties = loadProperties ( _source . openStream ( ) , encoding , newline ) ; _result . putAll ( _properties ) ; } return _result ; } | Load a collection of properties files into the same Map supports multiple lines values . |
39,046 | public static Map < String , String > loadResourceBundle ( String bundleName , Encoding encoding , String newline ) throws IOException , SyntaxErrorException , MissingResourceException { return loadResourceBundle ( bundleName , encoding , newline , Locale . getDefault ( ) ) ; } | Load a properties file looking for localized versions like ResourceBundle using the default Locale supporting multiple line values . |
39,047 | public static Map < String , String > loadResourceBundle ( String bundleName , Encoding encoding , String newline , Locale locale ) throws IOException , SyntaxErrorException , MissingResourceException { String _baseName = bundleName . replace ( "." , "/" ) ; List < URL > _bundle = new ArrayList < URL > ( 3 ) ; URL _resource = FileTools . class . getClassLoader ( ) . getResource ( _baseName + FILE_EXTENSION__PROPERTIES ) ; if ( null != _resource ) { _bundle . add ( _resource ) ; } if ( null != locale && IS_NOT_EMPTY . test ( locale . getLanguage ( ) ) ) { _resource = FileTools . class . getClassLoader ( ) . getResource ( _baseName + "_" + locale . getLanguage ( ) + FILE_EXTENSION__PROPERTIES ) ; if ( null != _resource ) { _bundle . add ( _resource ) ; } if ( IS_NOT_EMPTY . test ( locale . getCountry ( ) ) ) { _resource = FileTools . class . getClassLoader ( ) . getResource ( _baseName + "_" + locale . getLanguage ( ) + "_" + locale . getCountry ( ) + FILE_EXTENSION__PROPERTIES ) ; if ( null != _resource ) { _bundle . add ( _resource ) ; } } } if ( _bundle . isEmpty ( ) ) { throw new MissingResourceException ( bundleName , null , null ) ; } return loadBundle ( _bundle , encoding , newline ) ; } | Load a properties file looking for localized versions like ResourceBundle supporting multiple line values . |
39,048 | public static void readPropertiesToListeners ( InputStream source , Encoding encoding , PropertiesParsingListener ... listeners ) throws IOException , SyntaxErrorException { BufferedReader _reader = new BufferedReader ( createReaderForInputStream ( source , encoding ) ) ; LineByLinePropertyParser _parser = new LineByLinePropertyParser ( ) ; for ( PropertiesParsingListener _listener : listeners ) { _parser . addListener ( _listener ) ; } for ( String _line = _reader . readLine ( ) ; _line != null ; ) { _parser . parseLine ( _line ) ; _line = _reader . readLine ( ) ; } _reader . close ( ) ; } | Read a file of properties and notifies all the listeners for each property . |
39,049 | public void setConfigurationProperty ( final String name , final Object value ) { if ( XIncProcConfiguration . ALLOW_FIXUP_BASE_URIS . equals ( name ) ) { if ( value instanceof Boolean ) { this . baseUrisFixup = ( Boolean ) value ; } else if ( value instanceof String ) { this . baseUrisFixup = Boolean . valueOf ( ( String ) value ) ; } } if ( XIncProcConfiguration . ALLOW_FIXUP_LANGUAGE . equals ( name ) ) { if ( value instanceof Boolean ) { this . languageFixup = ( Boolean ) value ; } else if ( value instanceof String ) { this . languageFixup = Boolean . valueOf ( ( String ) value ) ; } } } | Sets configuration property . |
39,050 | private static String translateEncoding ( final String encodingName ) throws UnsupportedEncodingException { try { String _encoding = encodingName . trim ( ) . toLowerCase ( ) ; String _encodingCode = theEncodingResource . getString ( _encoding ) ; return _encodingCode ; } catch ( MissingResourceException _exception ) { throw new UnsupportedEncodingException ( theMessageUnsupportedEncoding + encodingName ) ; } catch ( Exception _exception ) { throw new UnsupportedEncodingException ( theMessageErrorTranslatingEncoding + encodingName ) ; } } | Get the java encoding name from a standard encoding name . |
39,051 | public final void convertFile ( final String inputFileName , final String outputFileName ) throws IOException , ConversionException { openInputFile ( inputFileName ) ; openOutputFile ( outputFileName ) ; doConvertFile ( myLineReader , myBufferedWriter ) ; closeOutputFile ( ) ; closeInputFile ( ) ; } | The file conversion process . |
39,052 | private void openInputFile ( final String inputFileName ) throws IOException { myInputFile = new File ( inputFileName ) ; myInputStream = new FileInputStream ( myInputFile ) ; myStreamReader = new InputStreamReader ( myInputStream , getInputEncodingCode ( ) ) ; myBufferedReader = new BufferedReader ( myStreamReader ) ; myLineReader = new LineNumberReader ( myBufferedReader ) ; } | Prepare the input stream . |
39,053 | private void openOutputFile ( final String outputFileName ) throws IOException { myOutputFile = new File ( outputFileName ) ; myOutputStream = new FileOutputStream ( myOutputFile ) ; myStreamWriter = new OutputStreamWriter ( myOutputStream , getOutputEncodingCode ( ) ) ; myBufferedWriter = new BufferedWriter ( myStreamWriter ) ; } | Prepare the output stream . |
39,054 | public static Integer getKeyEvent ( String key ) throws NoSuchElementException { key = key . toUpperCase ( ) ; Integer _result = theKeyTable . get ( key ) ; if ( null == _result ) { throw new NoSuchElementException ( key ) ; } return ( _result ) ; } | Return an Integer representing a KeyEvent . |
39,055 | public static KeyStroke getKeyStroke ( String key ) throws NoSuchElementException { key = key . toUpperCase ( ) ; int _sep = key . indexOf ( "/" ) ; String _mask = key . substring ( 0 , _sep ) ; String _keyCode = key . substring ( _sep + 1 ) ; Integer _m = theMaskTable . get ( _mask ) ; Integer _t = theKeyTable . get ( _keyCode ) ; if ( null == _m || null == _t ) { throw new NoSuchElementException ( key ) ; } return ( KeyStroke . getKeyStroke ( _t . intValue ( ) , _m . intValue ( ) ) ) ; } | Return a KeyStroke corresponding to the given code . |
39,056 | public static void snapWindowTo ( Window win , int location ) { Dimension _screen = Toolkit . getDefaultToolkit ( ) . getScreenSize ( ) ; Dimension _window = win . getSize ( ) ; int _wx = 0 ; int _wy = 0 ; switch ( location ) { case TOP_LEFT : break ; case TOP_CENTER : _wx = ( _screen . width - _window . width ) / 2 ; break ; case TOP_RIGHT : _wx = _screen . width - _window . width ; break ; case MIDDLE_LEFT : _wy = ( _screen . height - _window . height ) / 2 ; break ; case MIDDLE_CENTER : _wx = ( _screen . width - _window . width ) / 2 ; _wy = ( _screen . height - _window . height ) / 2 ; break ; case MIDDLE_RIGHT : _wx = _screen . width - _window . width ; _wy = ( _screen . height - _window . height ) / 2 ; break ; case BOTTOM_LEFT : _wy = _screen . height - _window . height ; break ; case BOTTOM_CENTER : _wx = ( _screen . width - _window . width ) / 2 ; _wy = _screen . height - _window . height ; break ; case BOTTOM_RIGHT : _wx = _screen . width - _window . width ; _wy = _screen . height - _window . height ; break ; } win . setLocation ( new Point ( _wx , _wy ) ) ; } | Snap the Window Position to a special location . |
39,057 | public synchronized void parseLine ( String line ) throws SyntaxErrorException { if ( null != getParserOutcome ( ) && isParserOutcomeMultipleLine ( ) ) { parseLine__multipleLineMode ( line ) ; } else { parseLine__singleLineMode ( line ) ; } } | Parse the given line and update the internal state of the parser . |
39,058 | private void fireMultipleLinePropertyParsedEvent ( String name , String [ ] value ) { MultipleLinePropertyParsedEvent _event = new MultipleLinePropertyParsedEvent ( name , value ) ; for ( PropertiesParsingListener _listener : getListeners ( ) ) { _listener . onMultipleLinePropertyParsed ( _event ) ; } } | Notify listeners that a multiple line property has been parsed . |
39,059 | private void fireSingleLinePropertyParsedEvent ( String name , String value ) { SingleLinePropertyParsedEvent _event = new SingleLinePropertyParsedEvent ( name , value ) ; for ( PropertiesParsingListener _listener : getListeners ( ) ) { _listener . onSingleLinePropertyParsed ( _event ) ; } } | Notify listeners that a single line property has been parsed . |
39,060 | private void parseLine__multipleLineMode ( String line ) { boolean _leftTrim = ( FinalState . IS_MULTIPLE_LINE_LEFT_TRIM == getParserOutcome ( ) ) ; parseLine__multipleLineMode__appendLineUnlessEndTag ( line , _leftTrim ) ; } | Line parsing when inside a multiple line property definition . |
39,061 | private void parseLine__singleLineMode ( String line ) throws SyntaxErrorException { setPropertyNameStart ( POSITION__NOT_SET ) ; setPropertyNameEnd ( POSITION__NOT_SET ) ; setRestOfLineStart ( POSITION__NOT_SET ) ; int _nextStateIndex = 0 ; State _currentState = null ; char [ ] _nextChar = new char [ 1 ] ; for ( int _i = 0 ; _i <= line . length ( ) ; _i ++ ) { setCurrentChar ( _i ) ; _currentState = getAutomaton ( ) [ _nextStateIndex ] ; _currentState . execute ( ) ; if ( line . length ( ) == _i || ! _currentState . isFollowable ( ) ) break ; _nextChar [ 0 ] = line . charAt ( _i ) ; String _charToParse = new String ( _nextChar ) ; try { _nextStateIndex = _currentState . chooseNext ( _charToParse ) ; } catch ( SyntaxErrorException _exception ) { throw new SyntaxErrorException ( "Error at pos " + _i + " in line :'" + line + "'" ) ; } } if ( null == _currentState || ! _currentState . isFinal ( ) ) { throw new SyntaxErrorException ( "Undefined error at pos in line :'" + line + "'" ) ; } if ( null != getParserOutcome ( ) ) { if ( isParserOutcomeSingleLine ( ) ) { boolean _leftTrim = ( FinalState . IS_SINGLE_LINE_LEFT_TRIM == getParserOutcome ( ) ) ; parseLine__extractSingleLineProperty ( line , _leftTrim ) ; } else if ( isParserOutcomeMultipleLine ( ) ) { String _propertyName = line . substring ( getPropertyNameStart ( ) , getPropertyNameEnd ( ) ) ; setMultipleLinePropertyName ( _propertyName ) ; setMultipleLinePropertyValue ( new ArrayList < String > ( ) ) ; String _endTag = line . substring ( getRestOfLineStart ( ) ) . trim ( ) ; if ( ! getEndTagChecker ( ) . matcher ( _endTag ) . matches ( ) ) { throw new SyntaxErrorException ( "End tag MUST match the rule : '" + CharacterPattern . END_TAG + "', got '" + _endTag + "'" ) ; } setMultipleLineEndTag ( _endTag ) ; } } } | Default line parsing if a heredoc syntax is detected next lines will be parsed in multiple line mode . |
39,062 | public final void removeAttribute ( final Element root , final String selector , final String attribute ) { final Iterable < Element > elements ; checkNotNull ( root , "Received a null pointer as root element" ) ; checkNotNull ( selector , "Received a null pointer as selector" ) ; checkNotNull ( attribute , "Received a null pointer as attribute" ) ; elements = root . select ( selector ) ; for ( final Element element : elements ) { element . removeAttr ( attribute ) ; } } | Finds a set of elements through a CSS selector and removes the received attribute from them if they have it . |
39,063 | public final void retag ( final Element root , final String selector , final String tag ) { final Iterable < Element > elements ; checkNotNull ( root , "Received a null pointer as root element" ) ; checkNotNull ( selector , "Received a null pointer as selector" ) ; checkNotNull ( tag , "Received a null pointer as tag" ) ; elements = root . select ( selector ) ; for ( final Element element : elements ) { element . tagName ( tag ) ; } } | Finds a set of elements through a CSS selector and changes their tags . |
39,064 | public final void swapTagWithParent ( final Element root , final String selector ) { final Iterable < Element > elements ; Element parent ; String text ; checkNotNull ( root , "Received a null pointer as root element" ) ; checkNotNull ( selector , "Received a null pointer as selector" ) ; elements = root . select ( selector ) ; for ( final Element element : elements ) { parent = element . parent ( ) ; text = element . text ( ) ; element . text ( "" ) ; parent . replaceWith ( element ) ; element . appendChild ( parent ) ; parent . text ( text ) ; } } | Finds a set of elements through a CSS selector and swaps its tag with that from its parent . |
39,065 | public final void wrap ( final Element root , final String selector , final String wrapper ) { final Iterable < Element > elements ; checkNotNull ( root , "Received a null pointer as root element" ) ; checkNotNull ( selector , "Received a null pointer as selector" ) ; checkNotNull ( wrapper , "Received a null pointer as HTML wrap" ) ; elements = root . select ( selector ) ; for ( final Element element : elements ) { element . wrap ( wrapper ) ; } } | Finds a set of elements through a CSS selector and wraps them with the received wrapper element . |
39,066 | public static UnitConverter getCachedInstance ( int pixelPerInch ) { Integer _key = new Integer ( pixelPerInch ) ; if ( ! theCache . containsKey ( _key ) ) { theCache . put ( _key , new UnitConverter ( pixelPerInch ) ) ; } return theCache . get ( _key ) ; } | Retrieve from the cache or create if not cached yet a unit converter setted for the given pixel per inch value . |
39,067 | private void updateReadyness ( ) { StringBuffer _buffer = new StringBuffer ( ) ; if ( null == myMessageProvider ) { _buffer . append ( NO_MESSAGE_PROVIDER ) ; } if ( null == myIconProvider ) { if ( _buffer . length ( ) > 0 ) { _buffer . append ( COMMA ) ; } _buffer . append ( NO_ICON_PROVIDER ) ; } if ( _buffer . length ( ) > 0 ) { _buffer . append ( DOT ) ; } myReasonWhyNotReady = _buffer . toString ( ) ; myIsReady = ( _buffer . length ( ) == 0 ) ; } | Do the self diagnostic and update the status . |
39,068 | public static RadioButton create ( String name , String value , String idSuffix , String label , boolean isSelected , boolean isDisabled ) { RadioButton _result = new RadioButton ( ) ; _result . setName ( name ) ; _result . setValue ( value ) ; if ( IS_NOT_EMPTY . test ( idSuffix ) ) { _result . setIdSuffix ( idSuffix ) ; } _result . setLabel ( label ) ; _result . setSelected ( isSelected ) ; _result . setDisabled ( isDisabled ) ; return _result ; } | Create a fully specified radio button . |
39,069 | public String execute ( final String pointerStr , final Source source ) { try { final StringWriter stringWriter = new StringWriter ( ) ; final Serializer serializer = processor . newSerializer ( stringWriter ) ; serializer . setOutputProperty ( Serializer . Property . OMIT_XML_DECLARATION , "yes" ) ; executeToDestination ( pointerStr , source , serializer ) ; return stringWriter . toString ( ) ; } catch ( final XPointerException e ) { final String message = e . getLocalizedMessage ( ) ; if ( xPointerErrorHandler != null ) { xPointerErrorHandler . reportError ( message ) ; } else { LOG . error ( message , e ) ; } } return "" ; } | Execute xpointer expression on a xml source returning a xml string |
39,070 | public String verifyXPathExpression ( final Iterable < XmlNsScheme > xmlNsSchemes , final String xpathExpression ) { LOG . trace ( "verifyXPathExpression: {}" , xpathExpression ) ; final XPathCompiler xPathCompiler = processor . newXPathCompiler ( ) ; for ( final XmlNsScheme xmlNsScheme : xmlNsSchemes ) { final String localPart = xmlNsScheme . getQName ( ) . getLocalPart ( ) ; final String namespaceUri = xmlNsScheme . getQName ( ) . getNamespaceURI ( ) ; LOG . trace ( "declareNamespace {}:{}" , localPart , namespaceUri ) ; xPathCompiler . declareNamespace ( localPart , namespaceUri ) ; } try { xPathCompiler . compile ( xpathExpression ) ; } catch ( final SaxonApiException e ) { return e . getCause ( ) . getMessage ( ) ; } return "" ; } | Utility method for verifying xpath expression |
39,071 | public static XIncludeContext newContext ( final XIncludeContext contextToCopy ) { final XIncludeContext newContext = new XIncludeContext ( contextToCopy . configuration ) ; newContext . currentBaseURI = contextToCopy . currentBaseURI ; newContext . basesURIDeque . addAll ( contextToCopy . basesURIDeque ) ; newContext . language = contextToCopy . language ; newContext . xincludeDeque . addAll ( contextToCopy . xincludeDeque ) ; newContext . docType = DocType . copy ( contextToCopy . docType ) ; return newContext ; } | Create a new context by deep copy of an existant one . |
39,072 | public void updateContextWithElementAttributes ( final Attributes attributes ) throws XIncludeFatalException { extractCurrentBaseURI ( attributes ) ; if ( ofNullable ( this . currentBaseURI ) . isPresent ( ) ) { addBaseURIPath ( this . currentBaseURI ) ; } } | Update context with element attributes . |
39,073 | public void addInInclusionChain ( final URI path , final String pointer ) throws XIncludeFatalException { final String xincludePath = path . toASCIIString ( ) + ( ( null != pointer ) ? ( '#' + pointer ) : "" ) ; if ( this . xincludeDeque . contains ( xincludePath ) ) { throw new XIncludeFatalException ( "Inclusion Loop on path: " + xincludePath ) ; } this . xincludeDeque . addLast ( xincludePath ) ; } | Add in inclusion chain . |
39,074 | public Node find ( String nodeName ) { if ( IS_EMPTY . test ( nodeName ) ) { throw new IllegalArgumentException ( "The node name should not be empty" ) ; } Node _result = null ; while ( hasMoreAvailableElement ( ) && ( null == _result ) ) { int _position = getPosition ( ) ; Node _current = getSource ( ) . item ( _position ) ; _position ++ ; setPosition ( _position ) ; if ( nodeName . equals ( _current . getNodeName ( ) ) ) { _result = _current ; } } return _result ; } | Find the next node having the specified node name . |
39,075 | public static Option create ( String value , String label , boolean isSelected ) { Option _result = new Option ( ) ; _result . setValue ( value ) ; _result . setLabel ( label ) ; _result . setSelected ( isSelected ) ; return _result ; } | Create a fully specified option . |
39,076 | public String getHtmlCode ( ) { Object [ ] _params = { SgmlUtils . generateAttribute ( HtmlUtils . AttributeNames . VALUE , getValue ( ) ) } ; MessageFormat _format = ( isSelected ( ) ) ? FORMAT__SELECTED : FORMAT__NOT_SELECTED ; return _format . format ( _params ) ; } | Generate the html code for the option . |
39,077 | public T orElseDoAndReturnDefault ( Consumer < Result < T > > consumer , T defaultVal ) { if ( isSuccessAndNotNull ( ) ) { return data ; } consumer . accept ( this ) ; return defaultVal ; } | The consumer function receives the entire result object as parameter in case you want to log or manage the error message or code in any way . |
39,078 | public static Charset getCharset ( final InputStream inputStream ) throws IOException { final Charset resultCharset ; final byte [ ] buffer = new byte [ 192 ] ; final int reading = ByteStreams . read ( inputStream , buffer , 0 , 192 ) ; if ( 4 > reading ) { resultCharset = Charset . forName ( EncodingUtils . DEFAULT_ENCODING ) ; } else { final long computed = ( 0xFF000000 & ( buffer [ 0 ] << 24 ) ) | ( 0x00FF0000 & ( buffer [ 1 ] << 16 ) ) | ( 0x0000FF00 & ( buffer [ 2 ] << 8 ) ) | ( 0x000000FF & buffer [ 3 ] ) ; if ( 0x0000FEFFL == computed || 0xFFFE0000L == computed ) { resultCharset = Charset . forName ( "UCS-4" ) ; } else if ( 0x0000003CL == computed ) { resultCharset = Charset . forName ( "UCS-4BE" ) ; } else if ( 0x3C000000L == computed ) { resultCharset = Charset . forName ( "UCS-4LE" ) ; } else if ( 0x003C003FL == computed ) { resultCharset = Charset . forName ( "UTF-16BE" ) ; } else if ( 0x3C003F00L == computed ) { resultCharset = Charset . forName ( "UTF-16LE" ) ; } else if ( 0x3C3F786DL == computed || 0x4C6FA794L == computed ) { resultCharset = EncodingUtils . getXmlCharsetEncoding ( buffer ) ; } else if ( 0xFEFF0000L == ( computed & 0xFFFF0000L ) ) { resultCharset = Charset . forName ( "UTF-16" ) ; } else if ( 0xFFFE0000L == ( computed & 0xFFFF0000L ) ) { resultCharset = Charset . forName ( "UTF-16" ) ; } else { resultCharset = Charset . forName ( EncodingUtils . DEFAULT_ENCODING ) ; } } return resultCharset ; } | Gets charset of an inputstream . |
39,079 | public static FluidFlowPanelModel createFluidFlowPanel ( int horizontalGap , int verticalGap ) { FlowLayout _flowLayout = new FlowLayout ( FlowLayout . LEFT , horizontalGap , verticalGap ) ; return FluidFlowPanelModel . createFluidFlowPanel ( _flowLayout ) ; } | Create a scrollable panel . |
39,080 | public static JPanel createPanelWithHorizontalLayout ( ) { JPanel _panel = new JPanel ( ) ; _panel . setLayout ( new BoxLayout ( _panel , BoxLayout . X_AXIS ) ) ; return _panel ; } | Create a panel that lays out components horizontally . |
39,081 | public static JPanel createPanelWithVerticalLayout ( ) { JPanel _panel = new JPanel ( ) ; _panel . setLayout ( new BoxLayout ( _panel , BoxLayout . Y_AXIS ) ) ; return _panel ; } | Create a panel that lays out components vertically . |
39,082 | public static Icon getImageIcon ( ClassLoader objectLoader , String fileName ) throws UrlProviderException { return getImageIcon ( new ClassLoaderUrlProvider ( objectLoader ) , fileName ) ; } | Create an Image icon from a String . |
39,083 | public static Icon getImageIcon ( UrlProvider urlProvider , String fileName ) throws UrlProviderException { URL _icon = urlProvider . getUrl ( fileName ) ; return new ImageIcon ( _icon ) ; } | Create an Image based icon from a String . |
39,084 | public static String encloseInParagraphe ( String value ) { Object [ ] _params = { value } ; return FORMAT_PARAGRAPH . format ( _params ) ; } | Create a HTML paragraph from the given text . |
39,085 | public static String generateAttribute ( String attributeName , String value ) { return SgmlUtils . generateAttribute ( attributeName , value ) ; } | Generate the HTML code for an attribute . |
39,086 | public static final boolean matchSequence ( byte [ ] sequence , byte [ ] buffer , int offset ) { boolean _result = ( sequence . length < ( buffer . length - offset ) ) ; if ( _result ) { for ( int _index = 0 ; _index < sequence . length ; _index ++ ) { if ( buffer [ _index ] != sequence [ _index ] ) { _result = false ; break ; } } } return _result ; } | Verify that each byte of a buffer match the corresponding byte of a given sequence starting from an offset . |
39,087 | public static StringBuffer appendByteAsPaddedHexString ( byte value , StringBuffer buffer ) { return buffer . append ( printHexBinary ( new byte [ ] { value } ) . toLowerCase ( ) ) ; } | Convert a byte into a padded hexadecimal string . |
39,088 | public static StringBuffer appendBytesAsPaddedHexString ( byte [ ] values , StringBuffer buffer ) { return buffer . append ( printHexBinary ( values ) . toLowerCase ( ) ) ; } | Convert a sequence of bytes into a padded hexadecimal string . |
39,089 | private void refreshId ( ) { if ( null == getName ( ) ) { setId ( null ) ; } else { if ( null == getIdSuffix ( ) ) { setId ( getName ( ) ) ; } else { setId ( getName ( ) + getIdSuffix ( ) ) ; } } } | Re - compute the id of the element . |
39,090 | private void outputReportLine ( List < String > report , MessageFormat template , String [ ] textLines , int currentLine ) { Object [ ] _args = { currentLine , textLines [ currentLine ] } ; report . add ( template . format ( _args ) ) ; } | Add a report line the designated line . |
39,091 | private void outputRangeOfTextInReport ( List < String > report , MessageFormat template , String [ ] textLines , int startLine , int endLine ) { for ( int _temp = startLine ; _temp < endLine ; _temp ++ ) { outputReportLine ( report , template , textLines , _temp ) ; } } | Add a report line for each designated line . |
39,092 | private int findNextMatchingLine ( String [ ] textLines , int startingLine , String textToMatch ) { int _foundLeft = - 1 ; { int _tempLine = startingLine + 1 ; while ( _tempLine < textLines . length ) { String _tempText = getTextLine ( textLines , _tempLine ) ; if ( _tempText . equals ( textToMatch ) ) { _foundLeft = _tempLine ; break ; } ++ _tempLine ; } } return _foundLeft ; } | Find the matching line if any . |
39,093 | private String getTextLine ( String [ ] textLines , int line ) { return ( isIgnoreTrailingWhiteSpaces ( ) ) ? textLines [ line ] . trim ( ) : textLines [ line ] ; } | Return the specified line from the text . |
39,094 | public static String [ ] reportDiff ( String [ ] textOnLeft , String [ ] textOnRight , boolean ignoreEmptyLines , boolean ignoreTrailingWhiteSpaces ) { QuickDiff _instance = new QuickDiff ( ) ; _instance . setIgnoreEmptyLines ( ignoreEmptyLines ) ; _instance . setIgnoreTrailingWhiteSpaces ( ignoreTrailingWhiteSpaces ) ; return _instance . reportDiff ( textOnLeft , textOnRight ) ; } | Macro to compute a diff report . |
39,095 | public static Object getObject ( final ResourceBundle source , final String key , final Object defaultValue ) { try { return source . getObject ( key ) ; } catch ( Exception _exception ) { return defaultValue ; } } | Return an object from a ResourceBundle . |
39,096 | public static Object getObject ( final Map < String , Object > source , final String key , final Object defaultValue ) { try { return source . get ( key ) ; } catch ( Exception _exception ) { return defaultValue ; } } | Return an object from a Map . |
39,097 | public static String getString ( final ResourceBundle source , final String key , final String defaultValue ) { try { return source . getString ( key ) ; } catch ( Exception _exception ) { return defaultValue ; } } | Return an string from a ResourceBundle . |
39,098 | public static String generateAttribute ( String attributeName , String value ) { Object [ ] _args = { attributeName , SGML_VALUE_ENCODER . apply ( value ) } ; return MESSAGE_FORMAT__ATTRIBUT . format ( _args ) ; } | Generate an attribute of the specified name and value . |
39,099 | public void addDefaultProcessor ( NodeProcessor processor ) { if ( null == processor ) { throw new IllegalArgumentException ( "Processor should not be null." ) ; } getActionPool ( ) . put ( NODE_NAME__DEFAULT , processor ) ; } | Add a default processing that will be applied when no specific processor is found . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.