signature:
public class Files { /** * 在一个目录里列出所有的子文件或者目录
 * @ param d
 * 目录
 * @ param p
 * 正则表达式对象 , 如果为空 , 则是全部正则表达式
 * @ param exclude
 * true 正则表达式匹配的文件会被忽略 , false 正则表达式匹配的文件会被包含
 * @ param mode
 * 请参看 LsMode 枚举类说明 , null 表示 LsMode . ALL
 * @ return 得到文件对象数组
 * @ see LsMode */
public static File [ ] ls ( File d , final Pattern p , final boolean exclude , LsMode mode ) { } }

implementation:
if ( null == p ) { return d . listFiles ( ) ; } // 全部
else if ( null == mode || LsMode . ALL == mode ) { return d . listFiles ( new FileFilter ( ) { public boolean accept ( File f ) { return p . matcher ( f . getName ( ) ) . find ( ) ^ exclude ; } } ) ; } // 仅文件
else if ( LsMode . FILE == mode ) { return d . listFiles ( new FileFilter ( ) { public boolean accept ( File f ) { if ( ! f . isFile ( ) ) return false ; return p . matcher ( f . getName ( ) ) . find ( ) ^ exclude ; } } ) ; } // 仅目录
else if ( LsMode . DIR == mode ) { return d . listFiles ( new FileFilter ( ) { public boolean accept ( File f ) { if ( ! f . isDirectory ( ) ) return false ; return p . matcher ( f . getName ( ) ) . find ( ) ^ exclude ; } } ) ; } // 不可能
throw Lang . impossible ( ) ;


signature:
public class Files { /** * 列文件
 * @ param d
 * 目录对象
 * @ param regex
 * 正则表达式
 * @ param mode
 * 模式
 * @ return 文件列表对象
 * @ see # ls ( File , Pattern , boolean , LsMode ) */
public static File [ ] ls ( File d , String regex , LsMode mode ) { } }

implementation: boolean exclude = false ; Pattern p = null ; if ( ! Strings . isBlank ( regex ) ) { exclude = regex . startsWith ( "!" ) ; if ( exclude ) { regex = Strings . trim ( regex . substring ( 1 ) ) ; } p = Pattern . compile ( regex ) ; } return ls ( d , p , exclude , mode ) ;


signature:
public class Files { /** * 从 CLASSPATH 下或从指定的本机器路径下寻找一个文件
 * @ param path
 * 文件路径
 * @ return 文件对象 , 如果不存在 , 则为 null */
public static File findFile ( String path ) { } }

implementation: return findFile ( path , ClassTools . getClassLoader ( ) , Encoding . defaultEncoding ( ) ) ;


signature:
public class Files { /** * 从 CLASSPATH 下或从指定的本机器路径下寻找一个文件
 * @ param path
 * 文件路径
 * @ return 文件对象 , 如果不存在 , 则抛出一个运行时异常 */
public static File checkFile ( String path ) { } }

implementation: File f = findFile ( path ) ; if ( null == f ) throw Lang . makeThrow ( "Fail to found file '%s'" , path ) ; return f ;


signature:
public class Files { /** * 获取输出流
 * @ param path
 * 文件路径
 * @ param klass
 * 参考的类 , - - 会用这个类的 ClassLoader
 * @ param enc
 * 文件路径编码
 * @ return 输出流 */
public static InputStream findFileAsStream ( String path , Class < ? > klass , String enc ) { } }

implementation: File f = new File ( path ) ; if ( f . exists ( ) ) try { return new FileInputStream ( f ) ; } catch ( FileNotFoundException e1 ) { return null ; } if ( null != klass ) { InputStream ins = klass . getClassLoader ( ) . getResourceAsStream ( path ) ; if ( null == ins ) ins = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( path ) ; if ( null != ins ) return ins ; } return ClassLoader . getSystemResourceAsStream ( path ) ;


signature:
public class Files { /** * 获取输出流
 * @ param path
 * 文件路径
 * @ param enc
 * 文件路径编码
 * @ return 输出流 */
public static InputStream findFileAsStream ( String path , String enc ) { } }

implementation: return findFileAsStream ( path , Files . class , enc ) ;


signature:
public class Files { /** * 获取输出流
 * @ param path
 * 文件路径
 * @ param klass
 * 参考的类 , - - 会用这个类的 ClassLoader
 * @ return 输出流 */
public static InputStream findFileAsStream ( String path , Class < ? > klass ) { } }

implementation: return findFileAsStream ( path , klass , Encoding . defaultEncoding ( ) ) ;


signature:
public class Files { /** * 文件对象是否是目录 , 可接受 null */
public static boolean isDirectory ( File f ) { } }

implementation: if ( null == f ) return false ; if ( ! f . exists ( ) ) return false ; if ( ! f . isDirectory ( ) ) return false ; return true ;


signature:
public class Files { /** * 创建新文件 , 如果父目录不存在 , 也一并创建 。 可接受 null 参数
 * @ param f
 * 文件对象
 * @ return false , 如果文件已存在 。 true 创建成功
 * @ throws IOException */
public static boolean createNewFile ( File f ) throws IOException { } }

implementation: if ( null == f || f . exists ( ) ) return false ; makeDir ( f . getParentFile ( ) ) ; return f . createNewFile ( ) ;


signature:
public class Files { /** * 创建新目录 , 如果父目录不存在 , 也一并创建 。 可接受 null 参数
 * @ param dir
 * 目录对象
 * @ return false , 如果目录已存在 。 true 创建成功
 * @ throws IOException */
public static boolean makeDir ( File dir ) { } }

implementation: if ( null == dir || dir . exists ( ) ) return false ; return dir . mkdirs ( ) ;


signature:
public class Files { /** * 强行删除一个目录 , 包括这个目录下所有的子目录和文件
 * @ param dir
 * 目录
 * @ return 是否删除成功 */
public static boolean deleteDir ( File dir ) { } }

implementation: if ( null == dir || ! dir . exists ( ) ) return false ; if ( ! dir . isDirectory ( ) ) throw new RuntimeException ( "\"" + dir . getAbsolutePath ( ) + "\" should be a directory!" ) ; File [ ] files = dir . listFiles ( ) ; boolean re = false ; if ( null != files ) { if ( files . length == 0 ) return dir . delete ( ) ; for ( File f : files ) { if ( f . isDirectory ( ) ) re |= deleteDir ( f ) ; else re |= deleteFile ( f ) ; } re |= dir . delete ( ) ; } return re ;


signature:
public class Files { /** * 清除一个目录里所有的内容
 * @ param dir
 * 目录
 * @ return 是否清除成功 */
public static boolean clearDir ( File dir ) { } }

implementation: if ( null == dir ) return false ; if ( ! dir . exists ( ) ) return false ; File [ ] fs = dir . listFiles ( ) ; if ( fs != null ) { for ( File f : fs ) { if ( f . isFile ( ) ) Files . deleteFile ( f ) ; else if ( f . isDirectory ( ) ) Files . deleteDir ( f ) ; } } return true ;


signature:
public class Files { /** * 将一个文件 copy 一部分 ( 或者全部 ) 到另外一个文件 。 如果目标文件不存在 , 创建它先 。
 * @ param src
 * 源文件
 * @ param target
 * 目标文件
 * @ param count
 * 要 copy 的字节数 , 0 表示什么都不 copy , - 1 表示 copy 全部数据
 * @ return 是否成功
 * @ throws IOException */
public static boolean copyFile ( File src , File target , long count ) throws IOException { } }

implementation:
if ( src == null || target == null || ! src . exists ( ) ) return false ; if ( ! target . exists ( ) ) if ( ! createNewFile ( target ) ) return false ; // 0 字节 ? 那就啥都不做咯
if ( count == 0 ) return true ; FileInputStream ins = null ; FileOutputStream ops = null ; FileChannel in = null ; FileChannel out = null ; try { ins = new FileInputStream ( src ) ; ops = new FileOutputStream ( target ) ; in = ins . getChannel ( ) ; out = ops . getChannel ( ) ; long maxCount = in . size ( ) ; if ( count < 0 || count > maxCount ) count = maxCount ; in . transferTo ( 0 , count , out ) ; } finally { Streams . safeClose ( out ) ; Streams . safeFlush ( ops ) ; Streams . safeClose ( ops ) ; Streams . safeClose ( in ) ; Streams . safeClose ( ins ) ; } return target . setLastModified ( src . lastModified ( ) ) ;


signature:
public class Files { /** * 自动决定是 copy 文件还是目录
 * @ param src
 * @ param target
 * 目标
 * @ return 是否 copy 成功 */
public static boolean copy ( File src , File target ) { } }

implementation: try { if ( src . isDirectory ( ) ) return copyDir ( src , target ) ; return copyFile ( src , target ) ; } catch ( IOException e ) { throw Lang . wrapThrow ( e ) ; }


signature:
public class Files { /** * 拷贝一个目录
 * @ param src
 * 原始目录
 * @ param target
 * 新目录
 * @ return 是否拷贝成功
 * @ throws IOException */
public static boolean copyDir ( File src , File target ) throws IOException { } }

implementation: if ( src == null || target == null || ! src . exists ( ) ) return false ; if ( ! src . isDirectory ( ) ) throw new IOException ( src . getAbsolutePath ( ) + " should be a directory!" ) ; if ( ! target . exists ( ) ) if ( ! makeDir ( target ) ) return false ; boolean re = true ; File [ ] files = src . listFiles ( ) ; if ( null != files ) { for ( File f : files ) { if ( f . isFile ( ) ) re &= copyFile ( f , new File ( target . getAbsolutePath ( ) + "/" + f . getName ( ) ) ) ; else re &= copyDir ( f , new File ( target . getAbsolutePath ( ) + "/" + f . getName ( ) ) ) ; } } return re ;


signature:
public class Files { /** * 将文件移动到新的位置
 * @ param src
 * 原始文件
 * @ param target
 * 新文件
 * @ return 移动是否成功
 * @ throws IOException */
public static boolean move ( File src , File target ) throws IOException { } }

implementation: if ( src == null || target == null ) return false ; makeDir ( target . getParentFile ( ) ) ; if ( src . isDirectory ( ) ) { src = new File ( src . getCanonicalPath ( ) + File . separator ) ; target = new File ( target . getCanonicalPath ( ) + File . separator ) ; } return src . renameTo ( target ) ;


signature:
public class Files { /** * 将文件改名
 * @ param src
 * 文件
 * @ param newName
 * 新名称
 * @ return 改名是否成功 */
public static boolean rename ( File src , String newName ) { } }

implementation: if ( src == null || newName == null ) return false ; if ( src . exists ( ) ) { File newFile = new File ( src . getParent ( ) + "/" + newName ) ; if ( newFile . exists ( ) ) return false ; Files . makeDir ( newFile . getParentFile ( ) ) ; return src . renameTo ( newFile ) ; } return false ;


signature:
public class Files { /** * 修改路径
 * @ param path
 * 路径
 * @ param newName
 * 新名称
 * @ return 新路径 */
public static String renamePath ( String path , String newName ) { } }

implementation: if ( ! Strings . isBlank ( path ) ) { int pos = path . replace ( '\\' , '/' ) . lastIndexOf ( '/' ) ; if ( pos > 0 ) return path . substring ( 0 , pos ) + "/" + newName ; } return newName ;


signature:
public class Files { /** * 将一个目录下的特殊名称的目录彻底删除 , 比如 ' . svn ' 或者 ' . cvs '
 * @ param dir
 * 目录
 * @ param name
 * 要清除的目录名
 * @ throws IOException */
public static void cleanAllFolderInSubFolderes ( File dir , String name ) throws IOException { } }

implementation: File [ ] files = dir . listFiles ( ) ; if ( files == null ) return ; for ( File d : files ) { if ( d . isDirectory ( ) ) if ( d . getName ( ) . equalsIgnoreCase ( name ) ) deleteDir ( d ) ; else cleanAllFolderInSubFolderes ( d , name ) ; }


signature:
public class Files { /** * 精确比较两个文件是否相等
 * @ param f1
 * 文件1
 * @ param f2
 * 文件2
 * @ return
 * < ul >
 * < li > true : 两个文件内容完全相等
 * < li > false : 任何一个文件对象为 null , 不存在 或内容不相等
 * < / ul > */
public static boolean isEquals ( File f1 , File f2 ) { } }

implementation: if ( null == f1 || null == f2 || ! f1 . isFile ( ) || ! f2 . isFile ( ) ) return false ; InputStream ins1 = null ; InputStream ins2 = null ; try { ins1 = Streams . fileIn ( f1 ) ; ins2 = Streams . fileIn ( f2 ) ; return Streams . equals ( ins1 , ins2 ) ; } catch ( IOException e ) { return false ; } finally { Streams . safeClose ( ins1 ) ; Streams . safeClose ( ins2 ) ; }


signature:
public class Files { /** * 在一个目录下 , 获取一个文件对象
 * @ param dir
 * 目录
 * @ param path
 * 文件相对路径
 * @ return 文件 */
public static File getFile ( File dir , String path ) { } }

implementation: if ( dir . exists ( ) ) { if ( dir . isDirectory ( ) ) return new File ( dir . getAbsolutePath ( ) + "/" + path ) ; return new File ( dir . getParent ( ) + "/" + path ) ; } throw Lang . makeThrow ( "dir noexists: %s" , dir ) ;


signature:
public class Files { /** * 获取一个目录下所有子目录 。 子目录如果以 ' . ' 开头 , 将被忽略
 * @ param dir
 * 目录
 * @ return 子目录数组 */
public static File [ ] dirs ( File dir ) { } }

implementation: return dir . listFiles ( new FileFilter ( ) { public boolean accept ( File f ) { return ! f . isHidden ( ) && f . isDirectory ( ) && ! f . getName ( ) . startsWith ( "." ) ; } } ) ;


signature:
public class Files { /** * 递归查找获取一个目录下所有子目录 ( 及子目录的子目录 ) 。 子目录如果以 ' . ' 开头 , 将被忽略
 * < b > 包含传入的目录 < / b >
 * @ param dir
 * 目录
 * @ return 子目录数组 */
public static File [ ] scanDirs ( File dir ) { } }

implementation: ArrayList < File > list = new ArrayList < File > ( ) ; list . add ( dir ) ; scanDirs ( dir , list ) ; return list . toArray ( new File [ list . size ( ) ] ) ;


signature:
public class Files { /** * 获取一个目录下所有的文件 ( 不递归 , 仅仅一层 ) 。 隐藏文件会被忽略 。
 * @ param dir
 * 目录
 * @ param suffix
 * 文件后缀名 。 如果为 null , 则获取全部文件
 * @ return 文件数组 */
public static File [ ] files ( File dir , final String suffix ) { } }

implementation: return dir . listFiles ( new FileFilter ( ) { public boolean accept ( File f ) { return ! f . isHidden ( ) && f . isFile ( ) && ( null == suffix || f . getName ( ) . endsWith ( suffix ) ) ; } } ) ;


signature:
public class NutType { /** * 生成Map < key , value > 形式的泛型Type
 * @ param key
 * key的泛型
 * @ param value
 * value的泛型
 * @ return Map < key , value > 形式的泛型Type */
public static Type map ( Type key , Type value ) { } }

implementation: return new NutType ( Map . class , key , value ) ;


signature:
public class ObjConvertImpl { /** * 这个实现 , 主要将 List , Map 的对象结构转换成真实的对象 .
 * 规则 :
 * < ul >
 * < li > 对象以Map存储 , key为属性名 , value为属性值
 * < li > 数组以List存储
 * < li > Map直接存储为Map
 * < li > List直接存储为List
 * < li > 只要不是List , Map 存储的 , 都认为是可以直接写入对象的 . TODO 这点可以调整一下 .
 * < / ul > */
public Object convert ( Object model ) { } }

implementation:
if ( model == null ) return null ; if ( type == null ) return model ; // obj是基本数据类型或String
if ( ! ( model instanceof Map ) && ! ( model instanceof Iterable ) ) { return Castors . me ( ) . castTo ( model , Lang . getTypeClass ( type ) ) ; } return inject ( model , type ) ;


signature: public class NutDao { public < T > T getObject ( Class < T > classOfT , ResultSet rs , FieldMatcher fm ) { } }

implementation: return getObject ( classOfT , rs , fm , null ) ;


signature:
public class NutDao { /** * 专属于NutDao的一些帮助方法 */
public void setExpert ( Object obj ) throws Exception { } }

implementation:
if ( obj == null ) throw new NullPointerException ( "expert MUST NOT NULL!!" ) ; if ( obj instanceof JdbcExpert ) { this . expert = ( JdbcExpert ) obj ; } else { String name = obj . toString ( ) ; this . expert = Jdbcs . getExpert ( name , "" ) ; if ( this . expert == null ) { if ( name . contains ( "." ) ) { Class < ? > klass = Lang . loadClass ( name ) ; try { this . expert = ( JdbcExpert ) Mirror . me ( klass ) . born ( Jdbcs . getConf ( ) ) ; } catch ( Throwable e ) { this . expert = ( JdbcExpert ) Mirror . me ( klass ) . born ( ) ; } } else { throw new DaoException ( "not such expert=" + obj ) ; } } } DataSource ds = this . dataSource ; // 如果数据源比expert先设置 , 那么需要重新设置一次
if ( ds != null ) { this . dataSource = null ; setDataSource ( ds ) ; }


signature:
public class ViewProcessor { /** * 保存对象到attribute */
public static void putRequestAttribute ( HttpServletRequest req , Object re ) { } }

implementation: if ( null != re ) { if ( re instanceof Context ) { Context context = ( Context ) re ; for ( String key : context . keys ( ) ) { req . setAttribute ( key , context . get ( key ) ) ; } } else { req . setAttribute ( ViewProcessor . DEFAULT_ATTRIBUTE , re ) ; } }


signature:
public class Params { /** * 构造参数转换器
 * @ param type
 * 要转换的目标类型
 * @ param datefmt
 * 如果目标类型是 DateTime 类似的类型 , 可以声明一个特殊转换格式 , < br >
 * 如果为 null 表示用 Times . D 函数自动猜测 */
public static ParamConvertor makeParamConvertor ( Class < ? > type , String datefmt ) { } }

implementation: return makeParamConvertor ( type , datefmt , null ) ;


signature:
public class Params { /** * 构造参数提取器 */
@ SuppressWarnings ( "unchecked" ) public static ParamExtractor makeParamExtractor ( HttpServletRequest req , Object refer ) { } }

implementation: if ( refer != null && Map . class . isAssignableFrom ( refer . getClass ( ) ) ) { return new MapParamExtractor ( req , ( Map < String , Object > ) refer ) ; } return new BaseParamExtractor ( req ) ;


signature: public class MethodWriter { @ Override public void visitParameter ( String name , int access ) { } }

implementation: if ( methodParameters == null ) { methodParameters = new ByteVector ( ) ; } ++ methodParametersCount ; methodParameters . putShort ( ( name == null ) ? 0 : cw . newUTF8 ( name ) ) . putShort ( access ) ;


signature:
public class MethodWriter { /** * Adds a successor to the { @ link # currentBlock currentBlock } block .
 * @ param info
 * information about the control flow edge to be added .
 * @ param successor
 * the successor block to be added to the current block . */
private void addSuccessor ( final int info , final Label successor ) { } }

implementation:
// creates and initializes an Edge object . . .
Edge b = new Edge ( ) ; b . info = info ; b . successor = successor ; // . . . and adds it to the successor list of the currentBlock block
b . next = currentBlock . successors ; currentBlock . successors = b ;


signature:
public class MethodWriter { /** * Visit the implicit first frame of this method . */
private void visitImplicitFirstFrame ( ) { } }

implementation:
// There can be at most descriptor . length ( ) + 1 locals
int frameIndex = startFrame ( 0 , descriptor . length ( ) + 1 , 0 ) ; if ( ( access & Opcodes . ACC_STATIC ) == 0 ) { if ( ( access & ACC_CONSTRUCTOR ) == 0 ) { frame [ frameIndex ++ ] = Frame . OBJECT | cw . addType ( cw . thisName ) ; } else { frame [ frameIndex ++ ] = 6 ; // Opcodes . UNINITIALIZED _ THIS ;
} } int i = 1 ; loop : while ( true ) { int j = i ; switch ( descriptor . charAt ( i ++ ) ) { case 'Z' : case 'C' : case 'B' : case 'S' : case 'I' : frame [ frameIndex ++ ] = 1 ; // Opcodes . INTEGER ;
break ; case 'F' : frame [ frameIndex ++ ] = 2 ; // Opcodes . FLOAT ;
break ; case 'J' : frame [ frameIndex ++ ] = 4 ; // Opcodes . LONG ;
break ; case 'D' : frame [ frameIndex ++ ] = 3 ; // Opcodes . DOUBLE ;
break ; case '[' : while ( descriptor . charAt ( i ) == '[' ) { ++ i ; } if ( descriptor . charAt ( i ) == 'L' ) { ++ i ; while ( descriptor . charAt ( i ) != ';' ) { ++ i ; } } frame [ frameIndex ++ ] = Frame . OBJECT | cw . addType ( descriptor . substring ( j , ++ i ) ) ; break ; case 'L' : while ( descriptor . charAt ( i ) != ';' ) { ++ i ; } frame [ frameIndex ++ ] = Frame . OBJECT | cw . addType ( descriptor . substring ( j + 1 , i ++ ) ) ; break ; default : break loop ; } } frame [ 1 ] = frameIndex - 3 ; endFrame ( ) ;


signature:
public class MethodWriter { /** * Starts the visit of a stack map frame .
 * @ param offset
 * the offset of the instruction to which the frame corresponds .
 * @ param nLocal
 * the number of local variables in the frame .
 * @ param nStack
 * the number of stack elements in the frame .
 * @ return the index of the next element to be written in this frame . */
private int startFrame ( final int offset , final int nLocal , final int nStack ) { } }

implementation: int n = 3 + nLocal + nStack ; if ( frame == null || frame . length < n ) { frame = new int [ n ] ; } frame [ 0 ] = offset ; frame [ 1 ] = nLocal ; frame [ 2 ] = nStack ; return 3 ;


signature:
public class MethodWriter { /** * Checks if the visit of the current frame { @ link # frame } is finished , and
 * if yes , write it in the StackMapTable attribute . */
private void endFrame ( ) { } }

implementation:
if ( previousFrame != null ) { // do not write the first frame
if ( stackMap == null ) { stackMap = new ByteVector ( ) ; } writeFrame ( ) ; ++ frameCount ; } previousFrame = frame ; frame = null ;


signature:
public class MethodWriter { /** * Compress and writes the current frame { @ link # frame } in the StackMapTable
 * attribute . */
private void writeFrame ( ) { } }

implementation:
int clocalsSize = frame [ 1 ] ; int cstackSize = frame [ 2 ] ; if ( ( cw . version & 0xFFFF ) < Opcodes . V1_6 ) { stackMap . putShort ( frame [ 0 ] ) . putShort ( clocalsSize ) ; writeFrameTypes ( 3 , 3 + clocalsSize ) ; stackMap . putShort ( cstackSize ) ; writeFrameTypes ( 3 + clocalsSize , 3 + clocalsSize + cstackSize ) ; return ; } int localsSize = previousFrame [ 1 ] ; int type = FULL_FRAME ; int k = 0 ; int delta ; if ( frameCount == 0 ) { delta = frame [ 0 ] ; } else { delta = frame [ 0 ] - previousFrame [ 0 ] - 1 ; } if ( cstackSize == 0 ) { k = clocalsSize - localsSize ; switch ( k ) { case - 3 : case - 2 : case - 1 : type = CHOP_FRAME ; localsSize = clocalsSize ; break ; case 0 : type = delta < 64 ? SAME_FRAME : SAME_FRAME_EXTENDED ; break ; case 1 : case 2 : case 3 : type = APPEND_FRAME ; break ; } } else if ( clocalsSize == localsSize && cstackSize == 1 ) { type = delta < 63 ? SAME_LOCALS_1_STACK_ITEM_FRAME : SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED ; } if ( type != FULL_FRAME ) { // verify if locals are the same
int l = 3 ; for ( int j = 0 ; j < localsSize ; j ++ ) { if ( frame [ l ] != previousFrame [ l ] ) { type = FULL_FRAME ; break ; } l ++ ; } } switch ( type ) { case SAME_FRAME : stackMap . putByte ( delta ) ; break ; case SAME_LOCALS_1_STACK_ITEM_FRAME : stackMap . putByte ( SAME_LOCALS_1_STACK_ITEM_FRAME + delta ) ; writeFrameTypes ( 3 + clocalsSize , 4 + clocalsSize ) ; break ; case SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED : stackMap . putByte ( SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED ) . putShort ( delta ) ; writeFrameTypes ( 3 + clocalsSize , 4 + clocalsSize ) ; break ; case SAME_FRAME_EXTENDED : stackMap . putByte ( SAME_FRAME_EXTENDED ) . putShort ( delta ) ; break ; case CHOP_FRAME : stackMap . putByte ( SAME_FRAME_EXTENDED + k ) . putShort ( delta ) ; break ; case APPEND_FRAME : stackMap . putByte ( SAME_FRAME_EXTENDED + k ) . putShort ( delta ) ; writeFrameTypes ( 3 + localsSize , 3 + clocalsSize ) ; break ; // case FULL _ FRAME :
default : stackMap . putByte ( FULL_FRAME ) . putShort ( delta ) . putShort ( clocalsSize ) ; writeFrameTypes ( 3 , 3 + clocalsSize ) ; stackMap . putShort ( cstackSize ) ; writeFrameTypes ( 3 + clocalsSize , 3 + clocalsSize + cstackSize ) ; }


signature:
public class MethodWriter { /** * Writes some types of the current frame { @ link # frame } into the
 * StackMapTableAttribute . This method converts types from the format used
 * in { @ link Label } to the format used in StackMapTable attributes . In
 * particular , it converts type table indexes to constant pool indexes .
 * @ param start
 * index of the first type in { @ link # frame } to write .
 * @ param end
 * index of last type in { @ link # frame } to write ( exclusive ) . */
private void writeFrameTypes ( final int start , final int end ) { } }

implementation: for ( int i = start ; i < end ; ++ i ) { int t = frame [ i ] ; int d = t & Frame . DIM ; if ( d == 0 ) { int v = t & Frame . BASE_VALUE ; switch ( t & Frame . BASE_KIND ) { case Frame . OBJECT : stackMap . putByte ( 7 ) . putShort ( cw . newClass ( cw . typeTable [ v ] . strVal1 ) ) ; break ; case Frame . UNINITIALIZED : stackMap . putByte ( 8 ) . putShort ( cw . typeTable [ v ] . intVal ) ; break ; default : stackMap . putByte ( v ) ; } } else { StringBuilder sb = new StringBuilder ( ) ; d >>= 28 ; while ( d -- > 0 ) { sb . append ( '[' ) ; } if ( ( t & Frame . BASE_KIND ) == Frame . OBJECT ) { sb . append ( 'L' ) ; sb . append ( cw . typeTable [ t & Frame . BASE_VALUE ] . strVal1 ) ; sb . append ( ';' ) ; } else { switch ( t & 0xF ) { case 1 : sb . append ( 'I' ) ; break ; case 2 : sb . append ( 'F' ) ; break ; case 3 : sb . append ( 'D' ) ; break ; case 9 : sb . append ( 'Z' ) ; break ; case 10 : sb . append ( 'B' ) ; break ; case 11 : sb . append ( 'C' ) ; break ; case 12 : sb . append ( 'S' ) ; break ; default : sb . append ( 'J' ) ; } } stackMap . putByte ( 7 ) . putShort ( cw . newClass ( sb . toString ( ) ) ) ; } }


signature:
public class MethodWriter { /** * Puts the bytecode of this method in the given byte vector .
 * @ param out
 * the byte vector into which the bytecode of this method must be
 * copied . */
final void put ( final ByteVector out ) { } }

implementation: final int FACTOR = ClassWriter . TO_ACC_SYNTHETIC ; int mask = ACC_CONSTRUCTOR | Opcodes . ACC_DEPRECATED | ClassWriter . ACC_SYNTHETIC_ATTRIBUTE | ( ( access & ClassWriter . ACC_SYNTHETIC_ATTRIBUTE ) / FACTOR ) ; out . putShort ( access & ~ mask ) . putShort ( name ) . putShort ( desc ) ; if ( classReaderOffset != 0 ) { out . putByteArray ( cw . cr . b , classReaderOffset , classReaderLength ) ; return ; } int attributeCount = 0 ; if ( code . length > 0 ) { ++ attributeCount ; } if ( exceptionCount > 0 ) { ++ attributeCount ; } if ( ( access & Opcodes . ACC_SYNTHETIC ) != 0 ) { if ( ( cw . version & 0xFFFF ) < Opcodes . V1_5 || ( access & ClassWriter . ACC_SYNTHETIC_ATTRIBUTE ) != 0 ) { ++ attributeCount ; } } if ( ( access & Opcodes . ACC_DEPRECATED ) != 0 ) { ++ attributeCount ; } if ( ClassReader . SIGNATURES && signature != null ) { ++ attributeCount ; } if ( methodParameters != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && annd != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && anns != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && ianns != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && tanns != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && itanns != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && panns != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && ipanns != null ) { ++ attributeCount ; } if ( attrs != null ) { attributeCount += attrs . getCount ( ) ; } out . putShort ( attributeCount ) ; if ( code . length > 0 ) { int size = 12 + code . length + 8 * handlerCount ; if ( localVar != null ) { size += 8 + localVar . length ; } if ( localVarType != null ) { size += 8 + localVarType . length ; } if ( lineNumber != null ) { size += 8 + lineNumber . length ; } if ( stackMap != null ) { size += 8 + stackMap . length ; } if ( ClassReader . ANNOTATIONS && ctanns != null ) { size += 8 + ctanns . getSize ( ) ; } if ( ClassReader . ANNOTATIONS && ictanns != null ) { size += 8 + ictanns . getSize ( ) ; } if ( cattrs != null ) { size += cattrs . getSize ( cw , code . data , code . length , maxStack , maxLocals ) ; } out . putShort ( cw . newUTF8 ( "Code" ) ) . putInt ( size ) ; out . putShort ( maxStack ) . putShort ( maxLocals ) ; out . putInt ( code . length ) . putByteArray ( code . data , 0 , code . length ) ; out . putShort ( handlerCount ) ; if ( handlerCount > 0 ) { Handler h = firstHandler ; while ( h != null ) { out . putShort ( h . start . position ) . putShort ( h . end . position ) . putShort ( h . handler . position ) . putShort ( h . type ) ; h = h . next ; } } attributeCount = 0 ; if ( localVar != null ) { ++ attributeCount ; } if ( localVarType != null ) { ++ attributeCount ; } if ( lineNumber != null ) { ++ attributeCount ; } if ( stackMap != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && ctanns != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && ictanns != null ) { ++ attributeCount ; } if ( cattrs != null ) { attributeCount += cattrs . getCount ( ) ; } out . putShort ( attributeCount ) ; if ( localVar != null ) { out . putShort ( cw . newUTF8 ( "LocalVariableTable" ) ) ; out . putInt ( localVar . length + 2 ) . putShort ( localVarCount ) ; out . putByteArray ( localVar . data , 0 , localVar . length ) ; } if ( localVarType != null ) { out . putShort ( cw . newUTF8 ( "LocalVariableTypeTable" ) ) ; out . putInt ( localVarType . length + 2 ) . putShort ( localVarTypeCount ) ; out . putByteArray ( localVarType . data , 0 , localVarType . length ) ; } if ( lineNumber != null ) { out . putShort ( cw . newUTF8 ( "LineNumberTable" ) ) ; out . putInt ( lineNumber . length + 2 ) . putShort ( lineNumberCount ) ; out . putByteArray ( lineNumber . data , 0 , lineNumber . length ) ; } if ( stackMap != null ) { boolean zip = ( cw . version & 0xFFFF ) >= Opcodes . V1_6 ; out . putShort ( cw . newUTF8 ( zip ? "StackMapTable" : "StackMap" ) ) ; out . putInt ( stackMap . length + 2 ) . putShort ( frameCount ) ; out . putByteArray ( stackMap . data , 0 , stackMap . length ) ; } if ( ClassReader . ANNOTATIONS && ctanns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeVisibleTypeAnnotations" ) ) ; ctanns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && ictanns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeInvisibleTypeAnnotations" ) ) ; ictanns . put ( out ) ; } if ( cattrs != null ) { cattrs . put ( cw , code . data , code . length , maxLocals , maxStack , out ) ; } } if ( exceptionCount > 0 ) { out . putShort ( cw . newUTF8 ( "Exceptions" ) ) . putInt ( 2 * exceptionCount + 2 ) ; out . putShort ( exceptionCount ) ; for ( int i = 0 ; i < exceptionCount ; ++ i ) { out . putShort ( exceptions [ i ] ) ; } } if ( ( access & Opcodes . ACC_SYNTHETIC ) != 0 ) { if ( ( cw . version & 0xFFFF ) < Opcodes . V1_5 || ( access & ClassWriter . ACC_SYNTHETIC_ATTRIBUTE ) != 0 ) { out . putShort ( cw . newUTF8 ( "Synthetic" ) ) . putInt ( 0 ) ; } } if ( ( access & Opcodes . ACC_DEPRECATED ) != 0 ) { out . putShort ( cw . newUTF8 ( "Deprecated" ) ) . putInt ( 0 ) ; } if ( ClassReader . SIGNATURES && signature != null ) { out . putShort ( cw . newUTF8 ( "Signature" ) ) . putInt ( 2 ) . putShort ( cw . newUTF8 ( signature ) ) ; } if ( methodParameters != null ) { out . putShort ( cw . newUTF8 ( "MethodParameters" ) ) ; out . putInt ( methodParameters . length + 1 ) . putByte ( methodParametersCount ) ; out . putByteArray ( methodParameters . data , 0 , methodParameters . length ) ; } if ( ClassReader . ANNOTATIONS && annd != null ) { out . putShort ( cw . newUTF8 ( "AnnotationDefault" ) ) ; out . putInt ( annd . length ) ; out . putByteArray ( annd . data , 0 , annd . length ) ; } if ( ClassReader . ANNOTATIONS && anns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeVisibleAnnotations" ) ) ; anns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && ianns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeInvisibleAnnotations" ) ) ; ianns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && tanns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeVisibleTypeAnnotations" ) ) ; tanns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && itanns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeInvisibleTypeAnnotations" ) ) ; itanns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && panns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeVisibleParameterAnnotations" ) ) ; AnnotationWriter . put ( panns , synthetics , out ) ; } if ( ClassReader . ANNOTATIONS && ipanns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeInvisibleParameterAnnotations" ) ) ; AnnotationWriter . put ( ipanns , synthetics , out ) ; } if ( attrs != null ) { attrs . put ( cw , null , 0 , - 1 , - 1 , out ) ; }


signature:
public class ClassWriter { /** * Returns the bytecode of the class that was build with this class writer .
 * @ return the bytecode of the class that was build with this class writer . */
public byte [ ] toByteArray ( ) { } }

implementation:
if ( index > 0xFFFF ) { throw new RuntimeException ( "Class file too large!" ) ; } // computes the real size of the bytecode of this class
int size = 24 + 2 * interfaceCount ; int nbFields = 0 ; FieldWriter fb = firstField ; while ( fb != null ) { ++ nbFields ; size += fb . getSize ( ) ; fb = ( FieldWriter ) fb . fv ; } int nbMethods = 0 ; MethodWriter mb = firstMethod ; while ( mb != null ) { ++ nbMethods ; size += mb . getSize ( ) ; mb = ( MethodWriter ) mb . mv ; } int attributeCount = 0 ; if ( bootstrapMethods != null ) { // we put it as first attribute in order to improve a bit
// ClassReader . copyBootstrapMethods
++ attributeCount ; size += 8 + bootstrapMethods . length ; newUTF8 ( "BootstrapMethods" ) ; } if ( ClassReader . SIGNATURES && signature != 0 ) { ++ attributeCount ; size += 8 ; newUTF8 ( "Signature" ) ; } if ( sourceFile != 0 ) { ++ attributeCount ; size += 8 ; newUTF8 ( "SourceFile" ) ; } if ( sourceDebug != null ) { ++ attributeCount ; size += sourceDebug . length + 6 ; newUTF8 ( "SourceDebugExtension" ) ; } if ( enclosingMethodOwner != 0 ) { ++ attributeCount ; size += 10 ; newUTF8 ( "EnclosingMethod" ) ; } if ( ( access & Opcodes . ACC_DEPRECATED ) != 0 ) { ++ attributeCount ; size += 6 ; newUTF8 ( "Deprecated" ) ; } if ( ( access & Opcodes . ACC_SYNTHETIC ) != 0 ) { if ( ( version & 0xFFFF ) < Opcodes . V1_5 || ( access & ACC_SYNTHETIC_ATTRIBUTE ) != 0 ) { ++ attributeCount ; size += 6 ; newUTF8 ( "Synthetic" ) ; } } if ( innerClasses != null ) { ++ attributeCount ; size += 8 + innerClasses . length ; newUTF8 ( "InnerClasses" ) ; } if ( ClassReader . ANNOTATIONS && anns != null ) { ++ attributeCount ; size += 8 + anns . getSize ( ) ; newUTF8 ( "RuntimeVisibleAnnotations" ) ; } if ( ClassReader . ANNOTATIONS && ianns != null ) { ++ attributeCount ; size += 8 + ianns . getSize ( ) ; newUTF8 ( "RuntimeInvisibleAnnotations" ) ; } if ( ClassReader . ANNOTATIONS && tanns != null ) { ++ attributeCount ; size += 8 + tanns . getSize ( ) ; newUTF8 ( "RuntimeVisibleTypeAnnotations" ) ; } if ( ClassReader . ANNOTATIONS && itanns != null ) { ++ attributeCount ; size += 8 + itanns . getSize ( ) ; newUTF8 ( "RuntimeInvisibleTypeAnnotations" ) ; } if ( attrs != null ) { attributeCount += attrs . getCount ( ) ; size += attrs . getSize ( this , null , 0 , - 1 , - 1 ) ; } size += pool . length ; // allocates a byte vector of this size , in order to avoid unnecessary
// arraycopy operations in the ByteVector . enlarge ( ) method
ByteVector out = new ByteVector ( size ) ; out . putInt ( 0xCAFEBABE ) . putInt ( version ) ; out . putShort ( index ) . putByteArray ( pool . data , 0 , pool . length ) ; int mask = Opcodes . ACC_DEPRECATED | ACC_SYNTHETIC_ATTRIBUTE | ( ( access & ACC_SYNTHETIC_ATTRIBUTE ) / TO_ACC_SYNTHETIC ) ; out . putShort ( access & ~ mask ) . putShort ( name ) . putShort ( superName ) ; out . putShort ( interfaceCount ) ; for ( int i = 0 ; i < interfaceCount ; ++ i ) { out . putShort ( interfaces [ i ] ) ; } out . putShort ( nbFields ) ; fb = firstField ; while ( fb != null ) { fb . put ( out ) ; fb = ( FieldWriter ) fb . fv ; } out . putShort ( nbMethods ) ; mb = firstMethod ; while ( mb != null ) { mb . put ( out ) ; mb = ( MethodWriter ) mb . mv ; } out . putShort ( attributeCount ) ; if ( bootstrapMethods != null ) { out . putShort ( newUTF8 ( "BootstrapMethods" ) ) ; out . putInt ( bootstrapMethods . length + 2 ) . putShort ( bootstrapMethodsCount ) ; out . putByteArray ( bootstrapMethods . data , 0 , bootstrapMethods . length ) ; } if ( ClassReader . SIGNATURES && signature != 0 ) { out . putShort ( newUTF8 ( "Signature" ) ) . putInt ( 2 ) . putShort ( signature ) ; } if ( sourceFile != 0 ) { out . putShort ( newUTF8 ( "SourceFile" ) ) . putInt ( 2 ) . putShort ( sourceFile ) ; } if ( sourceDebug != null ) { int len = sourceDebug . length ; out . putShort ( newUTF8 ( "SourceDebugExtension" ) ) . putInt ( len ) ; out . putByteArray ( sourceDebug . data , 0 , len ) ; } if ( enclosingMethodOwner != 0 ) { out . putShort ( newUTF8 ( "EnclosingMethod" ) ) . putInt ( 4 ) ; out . putShort ( enclosingMethodOwner ) . putShort ( enclosingMethod ) ; } if ( ( access & Opcodes . ACC_DEPRECATED ) != 0 ) { out . putShort ( newUTF8 ( "Deprecated" ) ) . putInt ( 0 ) ; } if ( ( access & Opcodes . ACC_SYNTHETIC ) != 0 ) { if ( ( version & 0xFFFF ) < Opcodes . V1_5 || ( access & ACC_SYNTHETIC_ATTRIBUTE ) != 0 ) { out . putShort ( newUTF8 ( "Synthetic" ) ) . putInt ( 0 ) ; } } if ( innerClasses != null ) { out . putShort ( newUTF8 ( "InnerClasses" ) ) ; out . putInt ( innerClasses . length + 2 ) . putShort ( innerClassesCount ) ; out . putByteArray ( innerClasses . data , 0 , innerClasses . length ) ; } if ( ClassReader . ANNOTATIONS && anns != null ) { out . putShort ( newUTF8 ( "RuntimeVisibleAnnotations" ) ) ; anns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && ianns != null ) { out . putShort ( newUTF8 ( "RuntimeInvisibleAnnotations" ) ) ; ianns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && tanns != null ) { out . putShort ( newUTF8 ( "RuntimeVisibleTypeAnnotations" ) ) ; tanns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && itanns != null ) { out . putShort ( newUTF8 ( "RuntimeInvisibleTypeAnnotations" ) ) ; itanns . put ( out ) ; } if ( attrs != null ) { attrs . put ( this , null , 0 , - 1 , - 1 , out ) ; } if ( hasAsmInsns ) { anns = null ; ianns = null ; attrs = null ; innerClassesCount = 0 ; innerClasses = null ; firstField = null ; lastField = null ; firstMethod = null ; lastMethod = null ; compute = MethodWriter . INSERTED_FRAMES ; hasAsmInsns = false ; new ClassReader ( out . data ) . accept ( this , ClassReader . EXPAND_FRAMES | ClassReader . EXPAND_ASM_INSNS ) ; return toByteArray ( ) ; } return out . data ;


signature:
public class ClassWriter { /** * Adds an UTF8 string to the constant pool of the class being build . Does
 * nothing if the constant pool already contains a similar item . < i > This
 * method is intended for { @ link Attribute } sub classes , and is normally not
 * needed by class generators or adapters . < / i >
 * @ param value
 * the String value .
 * @ return the index of a new or already existing UTF8 item . */
public int newUTF8 ( final String value ) { } }

implementation: key . set ( UTF8 , value , null , null ) ; Item result = get ( key ) ; if ( result == null ) { pool . putByte ( UTF8 ) . putUTF8 ( value ) ; result = new Item ( index ++ , key ) ; put ( result ) ; } return result . index ;


signature:
public class ClassWriter { /** * Adds a class reference to the constant pool of the class being build .
 * Does nothing if the constant pool already contains a similar item .
 * < i > This method is intended for { @ link Attribute } sub classes , and is
 * normally not needed by class generators or adapters . < / i >
 * @ param value
 * the internal name of the class .
 * @ return a new or already existing class reference item . */
Item newClassItem ( final String value ) { } }

implementation: key2 . set ( CLASS , value , null , null ) ; Item result = get ( key2 ) ; if ( result == null ) { pool . put12 ( CLASS , newUTF8 ( value ) ) ; result = new Item ( index ++ , key2 ) ; put ( result ) ; } return result ;


signature:
public class ClassWriter { /** * Adds a method type reference to the constant pool of the class being
 * build . Does nothing if the constant pool already contains a similar item .
 * < i > This method is intended for { @ link Attribute } sub classes , and is
 * normally not needed by class generators or adapters . < / i >
 * @ param methodDesc
 * method descriptor of the method type .
 * @ return a new or already existing method type reference item . */
Item newMethodTypeItem ( final String methodDesc ) { } }

implementation: key2 . set ( MTYPE , methodDesc , null , null ) ; Item result = get ( key2 ) ; if ( result == null ) { pool . put12 ( MTYPE , newUTF8 ( methodDesc ) ) ; result = new Item ( index ++ , key2 ) ; put ( result ) ; } return result ;


signature:
public class ClassWriter { /** * Adds a handle to the constant pool of the class being build . Does nothing
 * if the constant pool already contains a similar item . < i > This method is
 * intended for { @ link Attribute } sub classes , and is normally not needed by
 * class generators or adapters . < / i >
 * @ param tag
 * the kind of this handle . Must be { @ link Opcodes # H _ GETFIELD } ,
 * { @ link Opcodes # H _ GETSTATIC } , { @ link Opcodes # H _ PUTFIELD } ,
 * { @ link Opcodes # H _ PUTSTATIC } , { @ link Opcodes # H _ INVOKEVIRTUAL } ,
 * { @ link Opcodes # H _ INVOKESTATIC } ,
 * { @ link Opcodes # H _ INVOKESPECIAL } ,
 * { @ link Opcodes # H _ NEWINVOKESPECIAL } or
 * { @ link Opcodes # H _ INVOKEINTERFACE } .
 * @ param owner
 * the internal name of the field or method owner class .
 * @ param name
 * the name of the field or method .
 * @ param desc
 * the descriptor of the field or method .
 * @ param itf
 * true if the owner is an interface .
 * @ return a new or an already existing method type reference item . */
Item newHandleItem ( final int tag , final String owner , final String name , final String desc , final boolean itf ) { } }

implementation: key4 . set ( HANDLE_BASE + tag , owner , name , desc ) ; Item result = get ( key4 ) ; if ( result == null ) { if ( tag <= Opcodes . H_PUTSTATIC ) { put112 ( HANDLE , tag , newField ( owner , name , desc ) ) ; } else { put112 ( HANDLE , tag , newMethod ( owner , name , desc , itf ) ) ; } result = new Item ( index ++ , key4 ) ; put ( result ) ; } return result ;


signature:
public class ClassWriter { /** * Adds a handle to the constant pool of the class being build . Does nothing
 * if the constant pool already contains a similar item . < i > This method is
 * intended for { @ link Attribute } sub classes , and is normally not needed by
 * class generators or adapters . < / i >
 * @ param tag
 * the kind of this handle . Must be { @ link Opcodes # H _ GETFIELD } ,
 * { @ link Opcodes # H _ GETSTATIC } , { @ link Opcodes # H _ PUTFIELD } ,
 * { @ link Opcodes # H _ PUTSTATIC } , { @ link Opcodes # H _ INVOKEVIRTUAL } ,
 * { @ link Opcodes # H _ INVOKESTATIC } ,
 * { @ link Opcodes # H _ INVOKESPECIAL } ,
 * { @ link Opcodes # H _ NEWINVOKESPECIAL } or
 * { @ link Opcodes # H _ INVOKEINTERFACE } .
 * @ param owner
 * the internal name of the field or method owner class .
 * @ param name
 * the name of the field or method .
 * @ param desc
 * the descriptor of the field or method .
 * @ return the index of a new or already existing method type reference
 * item .
 * @ deprecated this method is superseded by
 * { @ link # newHandle ( int , String , String , String , boolean ) } . */
@ Deprecated public int newHandle ( final int tag , final String owner , final String name , final String desc ) { } }

implementation: return newHandle ( tag , owner , name , desc , tag == Opcodes . H_INVOKEINTERFACE ) ;


signature:
public class ClassWriter { /** * Adds a handle to the constant pool of the class being build . Does nothing
 * if the constant pool already contains a similar item . < i > This method is
 * intended for { @ link Attribute } sub classes , and is normally not needed by
 * class generators or adapters . < / i >
 * @ param tag
 * the kind of this handle . Must be { @ link Opcodes # H _ GETFIELD } ,
 * { @ link Opcodes # H _ GETSTATIC } , { @ link Opcodes # H _ PUTFIELD } ,
 * { @ link Opcodes # H _ PUTSTATIC } , { @ link Opcodes # H _ INVOKEVIRTUAL } ,
 * { @ link Opcodes # H _ INVOKESTATIC } ,
 * { @ link Opcodes # H _ INVOKESPECIAL } ,
 * { @ link Opcodes # H _ NEWINVOKESPECIAL } or
 * { @ link Opcodes # H _ INVOKEINTERFACE } .
 * @ param owner
 * the internal name of the field or method owner class .
 * @ param name
 * the name of the field or method .
 * @ param desc
 * the descriptor of the field or method .
 * @ param itf
 * true if the owner is an interface .
 * @ return the index of a new or already existing method type reference
 * item . */
public int newHandle ( final int tag , final String owner , final String name , final String desc , final boolean itf ) { } }

implementation: return newHandleItem ( tag , owner , name , desc , itf ) . index ;


signature:
public class ClassWriter { /** * Adds an invokedynamic reference to the constant pool of the class being
 * build . Does nothing if the constant pool already contains a similar item .
 * < i > This method is intended for { @ link Attribute } sub classes , and is
 * normally not needed by class generators or adapters . < / i >
 * @ param name
 * name of the invoked method .
 * @ param desc
 * descriptor of the invoke method .
 * @ param bsm
 * the bootstrap method .
 * @ param bsmArgs
 * the bootstrap method constant arguments .
 * @ return a new or an already existing invokedynamic type reference item . */
Item newInvokeDynamicItem ( final String name , final String desc , final Handle bsm , final Object ... bsmArgs ) { } }

implementation:
// cache for performance
ByteVector bootstrapMethods = this . bootstrapMethods ; if ( bootstrapMethods == null ) { bootstrapMethods = this . bootstrapMethods = new ByteVector ( ) ; } int position = bootstrapMethods . length ; // record current position
int hashCode = bsm . hashCode ( ) ; bootstrapMethods . putShort ( newHandle ( bsm . tag , bsm . owner , bsm . name , bsm . desc , bsm . isInterface ( ) ) ) ; int argsLength = bsmArgs . length ; bootstrapMethods . putShort ( argsLength ) ; for ( int i = 0 ; i < argsLength ; i ++ ) { Object bsmArg = bsmArgs [ i ] ; hashCode ^= bsmArg . hashCode ( ) ; bootstrapMethods . putShort ( newConst ( bsmArg ) ) ; } byte [ ] data = bootstrapMethods . data ; int length = ( 1 + 1 + argsLength ) << 1 ; // ( bsm + argCount + arguments )
hashCode &= 0x7FFFFFFF ; Item result = items [ hashCode % items . length ] ; loop : while ( result != null ) { if ( result . type != BSM || result . hashCode != hashCode ) { result = result . next ; continue ; } // because the data encode the size of the argument
// we don ' t need to test if these size are equals
int resultPosition = result . intVal ; for ( int p = 0 ; p < length ; p ++ ) { if ( data [ position + p ] != data [ resultPosition + p ] ) { result = result . next ; continue loop ; } } break ; } int bootstrapMethodIndex ; if ( result != null ) { bootstrapMethodIndex = result . index ; bootstrapMethods . length = position ; // revert to old position
} else { bootstrapMethodIndex = bootstrapMethodsCount ++ ; result = new Item ( bootstrapMethodIndex ) ; result . set ( position , hashCode ) ; put ( result ) ; } // now , create the InvokeDynamic constant
key3 . set ( name , desc , bootstrapMethodIndex ) ; result = get ( key3 ) ; if ( result == null ) { put122 ( INDY , bootstrapMethodIndex , newNameType ( name , desc ) ) ; result = new Item ( index ++ , key3 ) ; put ( result ) ; } return result ;


signature:
public class ClassWriter { /** * Adds an invokedynamic reference to the constant pool of the class being
 * build . Does nothing if the constant pool already contains a similar item .
 * < i > This method is intended for { @ link Attribute } sub classes , and is
 * normally not needed by class generators or adapters . < / i >
 * @ param name
 * name of the invoked method .
 * @ param desc
 * descriptor of the invoke method .
 * @ param bsm
 * the bootstrap method .
 * @ param bsmArgs
 * the bootstrap method constant arguments .
 * @ return the index of a new or already existing invokedynamic reference
 * item . */
public int newInvokeDynamic ( final String name , final String desc , final Handle bsm , final Object ... bsmArgs ) { } }

implementation: return newInvokeDynamicItem ( name , desc , bsm , bsmArgs ) . index ;


signature:
public class ClassWriter { /** * Adds a field reference to the constant pool of the class being build .
 * Does nothing if the constant pool already contains a similar item .
 * < i > This method is intended for { @ link Attribute } sub classes , and is
 * normally not needed by class generators or adapters . < / i >
 * @ param owner
 * the internal name of the field ' s owner class .
 * @ param name
 * the field ' s name .
 * @ param desc
 * the field ' s descriptor .
 * @ return the index of a new or already existing field reference item . */
public int newField ( final String owner , final String name , final String desc ) { } }

implementation: return newFieldItem ( owner , name , desc ) . index ;


signature:
public class ClassWriter { /** * Adds a method reference to the constant pool of the class being build .
 * Does nothing if the constant pool already contains a similar item .
 * @ param owner
 * the internal name of the method ' s owner class .
 * @ param name
 * the method ' s name .
 * @ param desc
 * the method ' s descriptor .
 * @ param itf
 * < tt > true < / tt > if < tt > owner < / tt > is an interface .
 * @ return a new or already existing method reference item . */
Item newMethodItem ( final String owner , final String name , final String desc , final boolean itf ) { } }

implementation: int type = itf ? IMETH : METH ; key3 . set ( type , owner , name , desc ) ; Item result = get ( key3 ) ; if ( result == null ) { put122 ( type , newClass ( owner ) , newNameType ( name , desc ) ) ; result = new Item ( index ++ , key3 ) ; put ( result ) ; } return result ;


signature:
public class ClassWriter { /** * Adds a method reference to the constant pool of the class being build .
 * Does nothing if the constant pool already contains a similar item .
 * < i > This method is intended for { @ link Attribute } sub classes , and is
 * normally not needed by class generators or adapters . < / i >
 * @ param owner
 * the internal name of the method ' s owner class .
 * @ param name
 * the method ' s name .
 * @ param desc
 * the method ' s descriptor .
 * @ param itf
 * < tt > true < / tt > if < tt > owner < / tt > is an interface .
 * @ return the index of a new or already existing method reference item . */
public int newMethod ( final String owner , final String name , final String desc , final boolean itf ) { } }

implementation: return newMethodItem ( owner , name , desc , itf ) . index ;


signature:
public class ClassWriter { /** * Adds a float to the constant pool of the class being build . Does nothing
 * if the constant pool already contains a similar item .
 * @ param value
 * the float value .
 * @ return a new or already existing float item . */
Item newFloat ( final float value ) { } }

implementation: key . set ( value ) ; Item result = get ( key ) ; if ( result == null ) { pool . putByte ( FLOAT ) . putInt ( key . intVal ) ; result = new Item ( index ++ , key ) ; put ( result ) ; } return result ;


signature:
public class ClassWriter { /** * Adds a string to the constant pool of the class being build . Does nothing
 * if the constant pool already contains a similar item .
 * @ param value
 * the String value .
 * @ return a new or already existing string item . */
private Item newString ( final String value ) { } }

implementation: key2 . set ( STR , value , null , null ) ; Item result = get ( key2 ) ; if ( result == null ) { pool . put12 ( STR , newUTF8 ( value ) ) ; result = new Item ( index ++ , key2 ) ; put ( result ) ; } return result ;


signature:
public class ClassWriter { /** * Adds a name and type to the constant pool of the class being build . Does
 * nothing if the constant pool already contains a similar item .
 * @ param name
 * a name .
 * @ param desc
 * a type descriptor .
 * @ return a new or already existing name and type item . */
Item newNameTypeItem ( final String name , final String desc ) { } }

implementation: key2 . set ( NAME_TYPE , name , desc , null ) ; Item result = get ( key2 ) ; if ( result == null ) { put122 ( NAME_TYPE , newUTF8 ( name ) , newUTF8 ( desc ) ) ; result = new Item ( index ++ , key2 ) ; put ( result ) ; } return result ;


signature:
public class ClassWriter { /** * Adds the given internal name to { @ link # typeTable } and returns its index .
 * Does nothing if the type table already contains this internal name .
 * @ param type
 * the internal name to be added to the type table .
 * @ return the index of this internal name in the type table . */
int addType ( final String type ) { } }

implementation: key . set ( TYPE_NORMAL , type , null , null ) ; Item result = get ( key ) ; if ( result == null ) { result = addType ( key ) ; } return result . index ;


signature:
public class ClassWriter { /** * Adds the given " uninitialized " type to { @ link # typeTable } and returns its
 * index . This method is used for UNINITIALIZED types , made of an internal
 * name and a bytecode offset .
 * @ param type
 * the internal name to be added to the type table .
 * @ param offset
 * the bytecode offset of the NEW instruction that created this
 * UNINITIALIZED type value .
 * @ return the index of this internal name in the type table . */
int addUninitializedType ( final String type , final int offset ) { } }

implementation: key . type = TYPE_UNINIT ; key . intVal = offset ; key . strVal1 = type ; key . hashCode = 0x7FFFFFFF & ( TYPE_UNINIT + type . hashCode ( ) + offset ) ; Item result = get ( key ) ; if ( result == null ) { result = addType ( key ) ; } return result . index ;


signature:
public class ClassWriter { /** * Adds the given Item to { @ link # typeTable } .
 * @ param item
 * the value to be added to the type table .
 * @ return the added Item , which a new Item instance with the same value as
 * the given Item . */
private Item addType ( final Item item ) { } }

implementation: ++ typeCount ; Item result = new Item ( typeCount , key ) ; put ( result ) ; if ( typeTable == null ) { typeTable = new Item [ 16 ] ; } if ( typeCount == typeTable . length ) { Item [ ] newTable = new Item [ 2 * typeTable . length ] ; System . arraycopy ( typeTable , 0 , newTable , 0 , typeTable . length ) ; typeTable = newTable ; } typeTable [ typeCount ] = result ; return result ;


signature:
public class ClassWriter { /** * Returns the index of the common super type of the two given types . This
 * method calls { @ link # getCommonSuperClass } and caches the result in the
 * { @ link # items } hash table to speedup future calls with the same
 * parameters .
 * @ param type1
 * index of an internal name in { @ link # typeTable } .
 * @ param type2
 * index of an internal name in { @ link # typeTable } .
 * @ return the index of the common super type of the two given types . */
int getMergedType ( final int type1 , final int type2 ) { } }

implementation: key2 . type = TYPE_MERGED ; key2 . longVal = type1 | ( ( ( long ) type2 ) << 32 ) ; key2 . hashCode = 0x7FFFFFFF & ( TYPE_MERGED + type1 + type2 ) ; Item result = get ( key2 ) ; if ( result == null ) { String t = typeTable [ type1 ] . strVal1 ; String u = typeTable [ type2 ] . strVal1 ; key2 . intVal = addType ( getCommonSuperClass ( t , u ) ) ; result = new Item ( ( short ) 0 , key2 ) ; put ( result ) ; } return result . intVal ;


signature:
public class ClassWriter { /** * Returns the common super type of the two given types . The default
 * implementation of this method < i > loads < / i > the two given classes and uses
 * the java . lang . Class methods to find the common super class . It can be
 * overridden to compute this common super type in other ways , in particular
 * without actually loading any class , or to take into account the class
 * that is currently being generated by this ClassWriter , which can of
 * course not be loaded since it is under construction .
 * @ param type1
 * the internal name of a class .
 * @ param type2
 * the internal name of another class .
 * @ return the internal name of the common super class of the two given
 * classes . */
protected String getCommonSuperClass ( final String type1 , final String type2 ) { } }

implementation: Class < ? > c , d ; ClassLoader classLoader = getClass ( ) . getClassLoader ( ) ; try { c = Class . forName ( type1 . replace ( '/' , '.' ) , false , classLoader ) ; d = Class . forName ( type2 . replace ( '/' , '.' ) , false , classLoader ) ; } catch ( Exception e ) { throw new RuntimeException ( e . toString ( ) ) ; } if ( c . isAssignableFrom ( d ) ) { return type1 ; } if ( d . isAssignableFrom ( c ) ) { return type2 ; } if ( c . isInterface ( ) || d . isInterface ( ) ) { return "java/lang/Object" ; } else { do { c = c . getSuperclass ( ) ; } while ( ! c . isAssignableFrom ( d ) ) ; return c . getName ( ) . replace ( '.' , '/' ) ; }


signature:
public class ClassWriter { /** * Returns the constant pool ' s hash table item which is equal to the given
 * item .
 * @ param key
 * a constant pool item .
 * @ return the constant pool ' s hash table item which is equal to the given
 * item , or < tt > null < / tt > if there is no such item . */
private Item get ( final Item key ) { } }

implementation: Item i = items [ key . hashCode % items . length ] ; while ( i != null && ( i . type != key . type || ! key . isEqualTo ( i ) ) ) { i = i . next ; } return i ;


signature:
public class ClassWriter { /** * Puts one byte and two shorts into the constant pool .
 * @ param b
 * a byte .
 * @ param s1
 * a short .
 * @ param s2
 * another short . */
private void put122 ( final int b , final int s1 , final int s2 ) { } }

implementation: pool . put12 ( b , s1 ) . putShort ( s2 ) ;


signature:
public class ClassWriter { /** * Puts two bytes and one short into the constant pool .
 * @ param b1
 * a byte .
 * @ param b2
 * another byte .
 * @ param s
 * a short . */
private void put112 ( final int b1 , final int b2 , final int s ) { } }

implementation: pool . put11 ( b1 , b2 ) . putShort ( s ) ;


signature:
public class EntityHolder { /** * 根据类型获取实体
 * @ param classOfT
 * 实体类型
 * @ return 实体 */
@ SuppressWarnings ( "unchecked" ) public < T > Entity < T > getEntity ( Class < T > classOfT ) { } }

implementation: Entity < ? > re = map . get ( classOfT ) ; if ( null == re || ! re . isComplete ( ) ) { synchronized ( map ) { re = map . get ( classOfT ) ; if ( null == re ) { re = maker . make ( classOfT ) ; } } } return ( Entity < T > ) re ;


signature:
public class EntityHolder { /** * 根据一个对象获取实体
 * 对象如果是集合或者数组 , 则取其第一个元素进行判断
 * @ param obj
 * 对象
 * @ return 实体 */
@ SuppressWarnings ( "unchecked" ) public Entity < ? > getEntityBy ( Object obj ) { } }

implementation:
// 正常的构建一个 Entity
Object first = Lang . first ( obj ) ; // 对象为空 , 不能构建实体
if ( first == null ) return null ; // 这是一个 Map , 试图构建一个 entity
if ( first instanceof Map < ? , ? > ) { Object tableName = ( ( Map < String , ? > ) first ) . get ( ".table" ) ; if ( null == tableName ) throw Lang . makeThrow ( "Can not insert map without key '.table' : \n%s" , Json . toJson ( first , JsonFormat . forLook ( ) ) ) ; return makeEntity ( tableName . toString ( ) , ( Map < String , ? > ) first ) ; } // 作为 POJO 构建
return getEntity ( first . getClass ( ) ) ;


signature:
public class Logs { /** * 返回以调用者的类命名的Log , 是获取Log对象最简单的方法 ! */
public static Log get ( ) { } }

implementation: StackTraceElement [ ] sts = Thread . currentThread ( ) . getStackTrace ( ) ; if ( Lang . isAndroid ) { for ( int i = 0 ; i < sts . length ; i ++ ) { if ( sts [ i ] . getClassName ( ) . equals ( Logs . class . getName ( ) ) ) { return adapter . getLogger ( sts [ i + 1 ] . getClassName ( ) ) ; } } } return adapter . getLogger ( sts [ 2 ] . getClassName ( ) ) ;


signature:
public class Logs { /** * 初始化NutLog , 检查全部Log的可用性 , 选择可用的Log适配器
 * < b > 加载本类时 , 该方法已经在静态构造函数中调用 , 用户无需主动调用 . < / b >
 * < b > 除非迫不得已 , 请不要调用本方法 < b / > */
public static void init ( ) { } }

implementation: try { String packageName = Logs . class . getPackage ( ) . getName ( ) + ".impl." ; adapter = new SimplePluginManager < LogAdapter > ( packageName + "CustomLogAdapter" , packageName + "Slf4jLogAdapter" , packageName + "Log4jLogAdapter" , packageName + "SystemLogAdapter" ) . get ( ) ; } catch ( Throwable e ) { try { Log4jLogAdapter tmp = new Log4jLogAdapter ( ) ; if ( tmp . canWork ( ) ) adapter = tmp ; else adapter = new SystemLogAdapter ( ) ; } catch ( Throwable _e ) { adapter = new SystemLogAdapter ( ) ; } }


signature:
public class BufferRing { /** * 根据给定的字节数组 , 在环中作标记 , 以便 dump
 * @ param bs
 * 数组
 * @ return 标记模式
 * @ throws IOException */
private MarkMode mark ( byte [ ] bs , int [ ] fails ) throws IOException { } }

implementation:
RingItem ri = item ; int re ; while ( ( re = ri . mark ( bs , fails ) ) >= 0 && ri . isDone4Mark ( ) ) { // 结尾匹配 bs 的开始 , 看不出这是否是一个结束 , 所以暂时当作
// 结束标记 , 并看看下一个节点 。 如果不是结束 , 则需要将 r 置到 max
if ( re > 0 ) { // 下一个节点没有加载 , 加载一下
if ( ! ri . next . isLoaded ) { ri . next . load ( ins ) ; readed += ri . next . max ; } // 如果当前的环节点的 next指向最初节点 , 说明整个当前的环已经被读满了 ,
// 因此所以不能判断这个位置是不是边界
// 因此做一下记录 , 下次加载时 , 本节点应该为头部
else if ( ri . next == this . item ) { ri . nextmark = ri . r ; return MarkMode . NOT_FOUND ; } // 匹配头部
if ( ri . next . matchHeadingWithRemain ( bs , re ) ) { return MarkMode . FOUND ; } // 没有匹配上 , 重置当前节点
else { ri . r = ri . max ; ri . nextmark = ri . max ; } } if ( ri . isStreamEnd ) break ; // 指向下一个节点
ri = ri . next ; // 保证该节点已经加载了
if ( ! ri . isLoaded ) { ri . load ( ins ) ; readed += ri . max ; } // 如果已经循环了一圈 , 退出
if ( ri == item ) break ; } if ( re == - 1 ) return MarkMode . FOUND ; return ri . isStreamEnd ? MarkMode . STREAM_END : MarkMode . NOT_FOUND ;


signature:
public class BufferRing { /** * 被 Dump 的节点将会通过标志表示可以再次加载
 * @ param ops
 * 输出流 , 如果为 null , 则不会输出 , 直接改变标志
 * @ throws IOException */
public void dump ( OutputStream ops ) throws IOException { } }

implementation:
while ( item . isLoaded ) { item . dump ( ops ) ; // All content had been dumped , move to next
if ( ! item . isLoaded ) item = item . next ; // Else break the loop and waiting for next ' mark '
else break ; } ops . flush ( ) ;


signature:
public class BufferRing { /** * 将标记的内容 Dump 成一个字符串 , 使用默认字符集
 * @ return 字符串
 * @ throws IOException */
String dumpAsString ( ) throws IOException { } }

implementation: StringBuilder sb = new StringBuilder ( ) ; OutputStream ops = new StringOutputStream ( sb , Encoding . defaultEncoding ( ) ) ; dump ( ops ) ; return sb . toString ( ) ;


signature:
public class BufferRing { /** * 将标记的内容 Dump 成一个字符串
 * @ return 字符串
 * @ throws IOException */
public String dumpAsString ( String charset ) throws IOException { } }

implementation: StringBuilder sb = new StringBuilder ( ) ; OutputStream ops = new StringOutputStream ( sb , charset ) ; dump ( ops ) ; return sb . toString ( ) ;


signature:
public class BufferRing { /** * 不输出 , 直接跳过 Mark , 相当于将当前的 Mark dump 到一个空的输出流
 * @ throws IOException */
public void skipMark ( ) throws IOException { } }

implementation: dump ( new OutputStream ( ) { public void write ( int b ) throws IOException { } public void close ( ) throws IOException { } public void flush ( ) throws IOException { } public void write ( byte [ ] b , int off , int len ) throws IOException { } public void write ( byte [ ] b ) throws IOException { } } ) ;


signature:
public class BufferRing { /** * 从当前节点的 next 开始 , 依次将所有可用的节点全部加载满
 * @ return 一共读去的字节数
 * @ throws IOException */
public long load ( ) throws IOException { } }

implementation: if ( item . isStreamEnd ) return readed ; RingItem ri = item ; while ( ! ri . isLoaded ) { ri . load ( ins ) ; if ( ri . max > 0 ) readed += ri . max ; ri = ri . next ; } return readed ;


signature:
public class TableName { /** * 代码模板 , 这个模板保证了 , 在 atom 中运行的 POJO 的动态表名 , 都会被参考对象所影响
 * @ param refer
 * 参考对象
 * @ param atom
 * 你的业务逻辑 */
public static void run ( Object refer , Runnable atom ) { } }

implementation: if ( null != atom ) { if ( log . isTraceEnabled ( ) ) log . tracef ( "TableName.run: [%s]->[%s]" , object , object . get ( ) ) ; Object old = get ( ) ; set ( refer ) ; try { atom . run ( ) ; } catch ( Exception e ) { throw Lang . wrapThrow ( e ) ; } finally { set ( old ) ; if ( log . isTraceEnabled ( ) ) log . tracef ( "TableName.finally: [%s]->[%s]" , object , object . get ( ) ) ; } }


signature:
public class TableName { /** * 为当前线程设置动态表名参考对象
 * @ param obj
 * 参考对象
 * @ return 旧的动态表名参考对象 */
public static Object set ( Object obj ) { } }

implementation: Object re = get ( ) ; object . set ( obj ) ; return re ;


signature:
public class TableName { /** * 根据当前线程的参考对象 , 渲染一个动态表名
 * @ param tableName
 * 动态表名
 * @ return 渲染后的表名 */
public static String render ( Segment tableName ) { } }

implementation: Object obj = get ( ) ; if ( null == obj || ! tableName . hasKey ( ) ) return tableName . toString ( ) ; Context context = Lang . context ( ) ; if ( isPrimitive ( obj ) ) { for ( String key : tableName . keys ( ) ) context . set ( key , obj ) ; } else if ( obj instanceof Context ) { for ( String key : tableName . keys ( ) ) context . set ( key , ( ( Context ) obj ) . get ( key ) ) ; } else if ( obj instanceof Map < ? , ? > ) { for ( String key : tableName . keys ( ) ) context . set ( key , ( ( Map < ? , ? > ) obj ) . get ( key ) ) ; } else { Mirror < ? > mirror = Mirror . me ( obj ) ; for ( String key : tableName . keys ( ) ) context . set ( key , mirror . getValue ( obj , key ) ) ; } return tableName . render ( context ) . toString ( ) ;


signature:
public class Mapl { /** * 这个实现 , 主要将 List , Map 的对象结构转换成真实的对象 .
 * 规则 :
 * < ul >
 * < li > 对象以Map存储 , key为属性名 , value为属性值
 * < li > 数组以List存储
 * < li > Map直接存储为Map
 * < li > List直接存储为List
 * < li > 只要不是List , Map 存储的 , 都认为是可以直接写入对象的 . TODO 这点可以调整一下 .
 * < / ul > */
public static Object maplistToObj ( Object maplist , Type type ) { } }

implementation: return new ObjConvertImpl ( type ) . convert ( maplist ) ;


signature:
public class Mapl { /** * 与maplistToObj实现一样 , 少了一步强制转换而已 */
@ SuppressWarnings ( "unchecked" ) public static < T > T maplistToT ( Object maplist , Class < T > clz ) { } }

implementation: return ( T ) new ObjConvertImpl ( clz ) . convert ( maplist ) ;


signature:
public class Mapl { /** * 访问MAP , List结构的数据 , 通过 uers [ 2 ] . name 这种形式 .
 * @ param maplist
 * @ param path
 * 路径 */
public static Object cell ( Object maplist , String path ) { } }

implementation: MaplRebuild mr = new MaplRebuild ( maplist ) ; return mr . cell ( path ) ;


signature:
public class Mapl { /** * 包含MapList过滤器 , 详情参见 : { @ link FilterConvertImpl }
 * @ param maplist
 * maplist结构的对象
 * @ param paths
 * 过滤列表 */
public static Object includeFilter ( Object maplist , List < String > paths ) { } }

implementation: FilterConvertImpl filter = new FilterConvertImpl ( paths ) ; filter . useIncludeModel ( ) ; return filter . convert ( maplist ) ;


signature:
public class Mapl { /** * 排除MapList过滤器 , 详情参见 : { @ link FilterConvertImpl }
 * @ param maplist
 * maplist结构的对象
 * @ param paths
 * 过滤列表 */
public static Object excludeFilter ( Object maplist , List < String > paths ) { } }

implementation: FilterConvertImpl filter = new FilterConvertImpl ( paths ) ; filter . useExcludeModel ( ) ; return filter . convert ( maplist ) ;


signature:
public class Mapl { /** * 结构转换 , 详情参见 : { @ link StructureConvert }
 * @ param maplist
 * maplist结构的对象
 * @ param model
 * 转换模板 , 也是一个规定格式的maplist结构 */
public static Object convert ( Object maplist , Object model ) { } }

implementation: StructureConvert convert = new StructureConvert ( model ) ; return convert . convert ( maplist ) ;


signature:
public class Mapl { /** * 将对象转换成Maplist结构
 * @ param obj
 * 待转换的对象 */
public static Object toMaplist ( Object obj ) { } }

implementation: ObjCompileImpl convert = new ObjCompileImpl ( ) ; return convert . parse ( obj ) ;


signature:
public class Mapl { /** * 添加新的结点
 * @ param obj
 * 原始的MapList
 * @ param path
 * 路径
 * @ param val */
public static void put ( Object obj , String path , Object val ) { } }

implementation: Object mapList = Mapl . toMaplist ( val ) ; MaplRebuild rebuild = new MaplRebuild ( obj ) ; rebuild . put ( path , mapList ) ;


signature:
public class Mapl { /** * 删除一个结点
 * @ param obj
 * 原始的Maplist
 * @ param path
 * 路径 */
public static void del ( Object obj , String path ) { } }

implementation: MaplRebuild rebuild = new MaplRebuild ( obj ) ; rebuild . remove ( path ) ;


signature:
public class Mapl { /** * 更新
 * @ param obj
 * 原始的Maplist
 * @ param path
 * 路径
 * @ param val
 * 新的值 */
public static void update ( Object obj , String path , Object val ) { } }

implementation: put ( obj , path , val ) ;


signature:
public class AnnotationVisitor { /** * Visits an enumeration value of the annotation .
 * @ param name
 * the value name .
 * @ param desc
 * the class descriptor of the enumeration class .
 * @ param value
 * the actual enumeration value . */
public void visitEnum ( String name , String desc , String value ) { } }

implementation: if ( av != null ) { av . visitEnum ( name , desc , value ) ; }


signature:
public class AnnotationVisitor { /** * Visits a nested annotation value of the annotation .
 * @ param name
 * the value name .
 * @ param desc
 * the class descriptor of the nested annotation class .
 * @ return a visitor to visit the actual nested annotation value , or
 * < tt > null < / tt > if this visitor is not interested in visiting this
 * nested annotation . < i > The nested annotation value must be fully
 * visited before calling other methods on this annotation
 * visitor < / i > . */
public AnnotationVisitor visitAnnotation ( String name , String desc ) { } }

implementation: if ( av != null ) { return av . visitAnnotation ( name , desc ) ; } return null ;


signature:
public class AnnotationVisitor { /** * Visits an array value of the annotation . Note that arrays of primitive
 * types ( such as byte , boolean , short , char , int , long , float or double )
 * can be passed as value to { @ link # visit visit } . This is what
 * { @ link ClassReader } does .
 * @ param name
 * the value name .
 * @ return a visitor to visit the actual array value elements , or
 * < tt > null < / tt > if this visitor is not interested in visiting these
 * values . The ' name ' parameters passed to the methods of this
 * visitor are ignored . < i > All the array values must be visited
 * before calling other methods on this annotation visitor < / i > . */
public AnnotationVisitor visitArray ( String name ) { } }

implementation: if ( av != null ) { return av . visitArray ( name ) ; } return null ;


signature:
public class IdEntityService { /** * 是否存在 @ Id所在属性的值为指定值的记录
 * @ param id 属性的值
 * @ return true , 如果存在的话 */
public boolean exists ( long id ) { } }

implementation: EntityField ef = getEntity ( ) . getIdField ( ) ; if ( null == ef ) return false ; return dao ( ) . count ( getEntityClass ( ) , Cnd . where ( ef . getName ( ) , "=" , id ) ) > 0 ;


signature:
public class CmdParams { /** * 解析传入的参数表
 * < pre >
 * 如果参数以 " - " 开头 , 则所谓名值对的键 。
 * 如果后面接着一个 " - " 开头的参数 , 则认为当前项目是布尔
 * 当然 , 如果给入的参数 boolChars 或者 boolRegex 匹配上了这个参数 , 也认为是布尔
 * < / pre >
 * @ param args
 * 参数表
 * @ param boolChars
 * 指明一个键的哪个字符是布尔值 。 一个键如果全部内容都是布尔值 , 则分别记录 。 否则认为是一个普通键 < br >
 * 你可以直接给一个正则表达式来匹配 boolChar , 但是你的正则表达式必须得有 group ( 1 ) 表示内容
 * @ param boolRegex
 * 用一个正则表达式来描述哪些键 ( 参数的整体 ) 为布尔值
 * @ return 参数表 */
public static CmdParams parse ( String [ ] args , String boolChars , String boolRegex ) { } }

implementation:
CmdParams params = new CmdParams ( ) ; List < String > list = new ArrayList < String > ( args . length ) ; params . map = new NutMap ( ) ; if ( args . length > 0 ) { // 预编译 boolRegex
Pattern bool_key = null ; if ( ! Strings . isBlank ( boolRegex ) ) { bool_key = Pattern . compile ( boolRegex ) ; } // 预编译 boolChars , 如果匹配这个正则表达式的参数 , 将被认为是一个布尔参数
// 支持 - bish 这样的组合形式
Pattern bool_char = null ; if ( ! Strings . isBlank ( boolChars ) ) { bool_char = Pattern . compile ( "^-([" + boolChars + "]+)$" ) ; } // 参数表 . . .
int i = 0 ; Matcher m ; for ( ; i < args . length ; i ++ ) { String s = args [ i ] ; // boolChars
// 是否是布尔值表
if ( null != bool_char ) { m = bool_char . matcher ( s ) ; if ( m . find ( ) ) { char [ ] cs = m . group ( m . groupCount ( ) ) . toCharArray ( ) ; for ( char c : cs ) { params . map . put ( "" + c , true ) ; } continue ; } } // 键值
m = PARAM_KEY . matcher ( s ) ; if ( m . find ( ) ) { String key = m . group ( m . groupCount ( ) ) ; // 键就是布尔值
if ( null != bool_key && bool_key . matcher ( key ) . matches ( ) ) { params . map . put ( key , true ) ; } // 木有后面的值了 , 那么作为 boolean
else if ( i >= args . length - 1 ) { params . map . put ( key , true ) ; break ; } // 如果有值 . . .
else { s = args [ i + 1 ] ; if ( s . matches ( "^-[a-zA-Z_].*$" ) ) { params . map . put ( key , true ) ; continue ; } params . map . put ( key , s ) ; // 跳过下一个值
i ++ ; } } // 嗯 , 是普通值 . . .
else { list . add ( s ) ; } } } params . vals = list . toArray ( new String [ list . size ( ) ] ) ; return params ;


signature:
public class FieldWriter { /** * Puts the content of this field into the given byte vector .
 * @ param out
 * where the content of this field must be put . */
void put ( final ByteVector out ) { } }

implementation: final int FACTOR = ClassWriter . TO_ACC_SYNTHETIC ; int mask = Opcodes . ACC_DEPRECATED | ClassWriter . ACC_SYNTHETIC_ATTRIBUTE | ( ( access & ClassWriter . ACC_SYNTHETIC_ATTRIBUTE ) / FACTOR ) ; out . putShort ( access & ~ mask ) . putShort ( name ) . putShort ( desc ) ; int attributeCount = 0 ; if ( value != 0 ) { ++ attributeCount ; } if ( ( access & Opcodes . ACC_SYNTHETIC ) != 0 ) { if ( ( cw . version & 0xFFFF ) < Opcodes . V1_5 || ( access & ClassWriter . ACC_SYNTHETIC_ATTRIBUTE ) != 0 ) { ++ attributeCount ; } } if ( ( access & Opcodes . ACC_DEPRECATED ) != 0 ) { ++ attributeCount ; } if ( ClassReader . SIGNATURES && signature != 0 ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && anns != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && ianns != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && tanns != null ) { ++ attributeCount ; } if ( ClassReader . ANNOTATIONS && itanns != null ) { ++ attributeCount ; } if ( attrs != null ) { attributeCount += attrs . getCount ( ) ; } out . putShort ( attributeCount ) ; if ( value != 0 ) { out . putShort ( cw . newUTF8 ( "ConstantValue" ) ) ; out . putInt ( 2 ) . putShort ( value ) ; } if ( ( access & Opcodes . ACC_SYNTHETIC ) != 0 ) { if ( ( cw . version & 0xFFFF ) < Opcodes . V1_5 || ( access & ClassWriter . ACC_SYNTHETIC_ATTRIBUTE ) != 0 ) { out . putShort ( cw . newUTF8 ( "Synthetic" ) ) . putInt ( 0 ) ; } } if ( ( access & Opcodes . ACC_DEPRECATED ) != 0 ) { out . putShort ( cw . newUTF8 ( "Deprecated" ) ) . putInt ( 0 ) ; } if ( ClassReader . SIGNATURES && signature != 0 ) { out . putShort ( cw . newUTF8 ( "Signature" ) ) ; out . putInt ( 2 ) . putShort ( signature ) ; } if ( ClassReader . ANNOTATIONS && anns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeVisibleAnnotations" ) ) ; anns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && ianns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeInvisibleAnnotations" ) ) ; ianns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && tanns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeVisibleTypeAnnotations" ) ) ; tanns . put ( out ) ; } if ( ClassReader . ANNOTATIONS && itanns != null ) { out . putShort ( cw . newUTF8 ( "RuntimeInvisibleTypeAnnotations" ) ) ; itanns . put ( out ) ; } if ( attrs != null ) { attrs . put ( cw , null , 0 , - 1 , - 1 , out ) ; }


signature:
public class JsonFormat { /** * 判断该字段是否是指定输出方式中的字段
 * @ param name
 * 字段名
 * @ return true : 该字段在忽略字段中 , false : 该字段不在忽略字段中 */
public boolean ignore ( String name ) { } }

implementation: if ( null != getActived ( ) ) return ! getActived ( ) . matcher ( name ) . find ( ) ; if ( null != getLocked ( ) ) return getLocked ( ) . matcher ( name ) . find ( ) ; return false ;


signature:
public class JsonFormat { /** * 设置Json输出格式中输出的字段
 * @ param regex
 * 输出的字段的正则表达式
 * @ return 该Json输出格式 */
public JsonFormat setActived ( String regex ) { } }

implementation: put ( Function . actived , Pattern . compile ( regex ) ) ; return this ;


signature:
public class JsonFormat { /** * 设置Json输出格式中不输出的字段
 * @ param regex
 * 不输出的字段的正则表达式
 * @ return 该Json输出格式 */
public JsonFormat setLocked ( String regex ) { } }

implementation: put ( Function . locked , Pattern . compile ( regex ) ) ; return this ;


signature:
public class JsonFormat { /** * Json输出格式的分隔符
 * @ return 分隔符 */
public char getSeparator ( ) { } }

implementation: Character separator = getAs ( Function . separator , Character . class ) ; if ( separator != null ) return separator ; return DEFAULT_SEPARATOR ;


signature:
public class JsonFormat { /** * 设置Json输出格式的设置日期格式
 * @ param df
 * 日期格式
 * @ return 该Json输出格式 */
public JsonFormat setDateFormat ( String df ) { } }

implementation: if ( df == null ) { remove ( Function . dateFormat ) ; } else if ( DATEFORMAT_TIMESTAMP . equals ( df ) ) { put ( Function . dateFormat , new TimeStampDateFormat ( ) ) ; } else { put ( Function . dateFormat , new SimpleDateFormat ( df ) ) ; put ( Function . dateFormatRaw , df ) ; } return this ;


signature:
public class JsonFormat { /** * Json输出格式的日期格式
 * @ return 日期格式 */
public DateFormat getDateFormat ( ) { } }

implementation: DateFormat df = getAs ( Function . dateFormat , DateFormat . class ) ; return df == null ? null : ( DateFormat ) df . clone ( ) ;


signature:
public class JsonFormat { /** * Json输出格式的数字格式
 * @ return 数字格式 */
public NumberFormat getNumberFormat ( ) { } }

implementation: NumberFormat nf = getAs ( Function . numberFormat , NumberFormat . class ) ; return nf == null ? null : ( NumberFormat ) nf . clone ( ) ;


signature:
public class Json { /** * 从文本输入流中生成 JAVA 对象 。
 * @ param reader
 * 文本输入流
 * @ return JAVA 对象
 * @ throws JsonException */
public static Object fromJson ( Reader reader ) throws JsonException { } }

implementation:
// return new org . nutz . json . impl . JsonCompileImpl ( ) . parse ( reader ) ;
return new org . nutz . json . impl . JsonCompileImplV2 ( ) . parse ( reader ) ;


signature:
public class Json { /** * 根据指定的类型 , 从文本输入流中生成 JAVA 对象 。 指定的类型可以是任意 JAVA 对象 。
 * @ param type
 * 对象类型
 * @ param reader
 * 文本输入流
 * @ return 指定类型的 JAVA 对象
 * @ throws JsonException */
@ SuppressWarnings ( "unchecked" ) public static < T > T fromJson ( Class < T > type , Reader reader ) throws JsonException { } }

implementation: return ( T ) parse ( type , reader ) ;


signature:
public class Json { /** * 根据指定的类型 , 从文本输入流中生成 JAVA 对象 。 指定的类型可以是任意 JAVA 对象 。
 * @ param type
 * 对象类型 , 可以是范型
 * @ param reader
 * 文本输入流
 * @ return 指定类型的 JAVA 对象
 * @ throws JsonException */
public static Object fromJson ( Type type , Reader reader ) throws JsonException { } }

implementation: return parse ( type , reader ) ;


signature:
public class Json { /** * 根据指定的类型 , 从字符串中生成 JAVA 对象 。 指定的类型可以是任意 JAVA 对象 。
 * @ param type
 * 对象类型 , 可以是范型
 * @ param cs
 * JSON 字符串
 * @ return 指定类型的 JAVA 对象
 * @ throws JsonException */
public static Object fromJson ( Type type , CharSequence cs ) throws JsonException { } }

implementation: return fromJson ( type , Lang . inr ( cs ) ) ;


signature:
public class Json { /** * 根据指定的类型 , 读取指定的 JSON 文件生成 JAVA 对象 。 指定的类型可以是任意 JAVA 对象 。
 * @ param type
 * 对象类型
 * @ param f
 * 文件对象
 * @ return 指定类型的 JAVA 对象
 * @ throws JsonException */
public static < T > T fromJsonFile ( Class < T > type , File f ) { } }

implementation: BufferedReader br = null ; try { br = buffr ( fileInr ( f ) ) ; return Json . fromJson ( type , br ) ; } finally { Streams . safeClose ( br ) ; }


signature:
public class Json { /** * 根据指定的类型 , 从字符串中生成 JAVA 对象 。 指定的类型可以是任意 JAVA 对象 。
 * 请参看函数 ‘ < T > T fromJson ( Class < T > type , Reader reader ) ’ 的描述
 * @ param type
 * 对象类型
 * @ param cs
 * JSON 字符串
 * @ return 特定类型的 JAVA 对象
 * @ throws JsonException
 * @ see # fromJson ( Class type , Reader reader ) */
public static < T > T fromJson ( Class < T > type , CharSequence cs ) throws JsonException { } }


signature:
public class Json { /** * 将一个 JAVA 对象转换成 JSON 字符串 , 并且可以设定 JSON 字符串的格式化方式
 * @ param obj
 * JAVA 对象
 * @ param format
 * JSON 字符串格式化方式 , 若 format 为 null , 则以 JsonFormat . nice ( ) 格式输出
 * @ return JSON 字符串 */
public static String toJson ( Object obj , JsonFormat format ) { } }

implementation: StringBuilder sb = new StringBuilder ( ) ; toJson ( Lang . opw ( sb ) , obj , format ) ; return sb . toString ( ) ;


signature:
public class Json { /** * 将一个 JAVA 对象以 JSON 的形式写到一个文本输出流里 , 并且可以设定 JSON 字符串的格式化方式
 * @ param writer
 * 文本输出流
 * @ param obj
 * JAVA 对象
 * @ param format
 * JSON 字符串格式化方式 , 若 format 为 null , 则以 JsonFormat . nice ( ) 格式输出 */
public static void toJson ( Writer writer , Object obj , JsonFormat format ) { } }

implementation: try { if ( format == null ) format = deft ; JsonRender jr ; Class < ? extends JsonRender > jrCls = getJsonRenderCls ( ) ; if ( jrCls == null ) jr = new JsonRenderImpl ( ) ; else jr = Mirror . me ( jrCls ) . born ( ) ; jr . setWriter ( writer ) ; jr . setFormat ( format ) ; jr . render ( obj ) ; writer . flush ( ) ; } catch ( IOException e ) { throw Lang . wrapThrow ( e , JsonException . class ) ; }


signature:
public class Json { /** * 将一个 JAVA 对象以 JSON 的形式写到一个文件里 , 并且可以设定 JSON 字符串的格式化方式
 * @ param f
 * 文本文件
 * @ param obj
 * JAVA 对象
 * @ param format
 * JSON 字符串格式化方式 , 若 format 为 null , 则以 JsonFormat . nice ( ) 格式输出 */
public static void toJsonFile ( File f , Object obj , JsonFormat format ) { } }

implementation: Writer writer = null ; try { Files . createFileIfNoExists ( f ) ; writer = Streams . fileOutw ( f ) ; Json . toJson ( writer , obj , format ) ; writer . append ( '\n' ) ; } catch ( IOException e ) { throw Lang . wrapThrow ( e ) ; } finally { Streams . safeClose ( writer ) ; }


signature:
public class Json { /** * 获取一个 Json 实体 */
public static JsonEntity getEntity ( Mirror < ? > mirror ) { } }

implementation: JsonEntity je = entities . get ( mirror . getTypeId ( ) ) ; if ( null == je ) { je = new JsonEntity ( mirror ) ; entities . put ( mirror . getTypeId ( ) , je ) ; } return je ;


signature:
public class Json { /** * 从 JSON 字符串中 , 根据获取某种指定类型的 List 对象 。
 * 请参看函数 ‘ Object fromJson ( Type type , CharSequence cs ) ’ 的描述
 * @ param eleType
 * 对象类型
 * @ param cs
 * JSON 字符串
 * @ return 特定类型的 JAVA 对象
 * @ throws JsonException
 * @ see # fromJson ( Type type , CharSequence cs ) */
@ SuppressWarnings ( "unchecked" ) public static < T > List < T > fromJsonAsList ( Class < T > eleType , CharSequence cs ) { } }

implementation: return ( List < T > ) fromJson ( NutType . list ( eleType ) , cs ) ;


signature:
public class Json { /** * 从 JSON 输入流中 , 根据获取某种指定类型的 List 对象 。
 * 请参看函数 ‘ Object fromJson ( Type type , Reader reader ) ’ 的描述
 * @ param eleType
 * 对象类型
 * @ param reader
 * JSON 输入流
 * @ return 特定类型的 JAVA 对象
 * @ throws JsonException
 * @ see # fromJson ( Type type , Reader reader ) */
@ SuppressWarnings ( "unchecked" ) public static < T > List < T > fromJsonAsList ( Class < T > eleType , Reader reader ) { } }

implementation: return ( List < T > ) fromJson ( NutType . list ( eleType ) , reader ) ;


signature:
public class Json { /** * 从 JSON 字符串中 , 根据获取某种指定类型的 数组 对象 。
 * 请参看函数 ‘ Object fromJson ( Type type , CharSequence cs ) ’ 的描述
 * @ param eleType
 * 对象类型
 * @ param cs
 * JSON 字符串
 * @ return 特定类型的 JAVA 对象
 * @ throws JsonException
 * @ see # fromJson ( Type type , CharSequence cs ) */
@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] fromJsonAsArray ( Class < T > eleType , CharSequence cs ) { } }

implementation: return ( T [ ] ) fromJson ( NutType . array ( eleType ) , cs ) ;


signature:
public class Json { /** * 从 JSON 输入流中 , 根据获取某种指定类型的 数组 对象 。
 * 请参看函数 ‘ Object fromJson ( Type type , Reader reader ) ’ 的描述
 * @ param eleType
 * 对象类型
 * @ param reader
 * JSON 输入流
 * @ return 特定类型的 JAVA 对象
 * @ throws JsonException
 * @ see # fromJson ( Class type , Reader reader ) */
@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] fromJsonAsArray ( Class < T > eleType , Reader reader ) { } }

implementation: return ( T [ ] ) fromJson ( NutType . array ( eleType ) , reader ) ;


signature:
public class Json { /** * 从 JSON 字符串中 , 根据获取某种指定类型的 Map 对象 。
 * 请参看函数 ‘ Object fromJson ( Type type , CharSequence cs ) ’ 的描述
 * @ param eleType
 * 对象类型
 * @ param cs
 * JSON 字符串
 * @ return 特定类型的 JAVA 对象
 * @ throws JsonException
 * @ see # fromJson ( Type type , CharSequence cs ) */
@ SuppressWarnings ( "unchecked" ) public static < T > Map < String , T > fromJsonAsMap ( Class < T > eleType , CharSequence cs ) { } }

implementation: return ( Map < String , T > ) fromJson ( NutType . mapStr ( eleType ) , cs ) ;


signature:
public class Json { /** * 从 JSON 输入流中 , 根据获取某种指定类型的 Map 对象 。
 * 请参看函数 ‘ Object fromJson ( Type type , Reader reader ) ’ 的描述
 * @ param eleType
 * 对象类型
 * @ param reader
 * JSON 输入流
 * @ return 特定类型的 JAVA 对象
 * @ throws JsonException
 * @ see # fromJson ( Type type , Reader reader ) */
@ SuppressWarnings ( "unchecked" ) public static < T > Map < String , T > fromJsonAsMap ( Class < T > eleType , Reader reader ) { } }

implementation: return ( Map < String , T > ) fromJson ( NutType . mapStr ( eleType ) , reader ) ;


signature: public class Pojos { public static Pojo createRun ( PojoCallback callback ) { } }

implementation: return new NutPojo ( ) . setSqlType ( SqlType . RUN ) . setAfter ( callback ) ;


signature:
public class Converter { /** * 初始化解析器 */
private void initParse ( ) { } }

implementation: parses . add ( new OptParse ( ) ) ; parses . add ( new StringParse ( ) ) ; parses . add ( new IdentifierParse ( ) ) ; parses . add ( new ValParse ( ) ) ;


signature:
public class Converter { /** * 初始化EL项 */
public void initItems ( ) { } }

implementation:
while ( ! exp . isEmpty ( ) ) { Object obj = parseItem ( ) ; // 处理数组的情况
if ( obj . getClass ( ) . isArray ( ) ) { for ( Object o : ( Object [ ] ) obj ) { itemCache . add ( o ) ; } continue ; } itemCache . add ( obj ) ; } itemCache = clearUp ( itemCache ) ;


signature:
public class Converter { /** * 清理转换后的结果 , 主要做一些标识性的转换
 * @ param rpn
 * @ return */
private LinkedList < Object > clearUp ( LinkedList < Object > rpn ) { } }

implementation:
LinkedList < Object > dest = new LinkedList < Object > ( ) ; while ( ! rpn . isEmpty ( ) ) { if ( ! ( rpn . getFirst ( ) instanceof Elobj ) ) { dest . add ( rpn . removeFirst ( ) ) ; continue ; } Elobj obj = ( Elobj ) rpn . removeFirst ( ) ; // 方法对象
if ( ! rpn . isEmpty ( ) && rpn . getFirst ( ) instanceof MethodOpt ) { dest . add ( new MethodObj ( obj . getVal ( ) ) ) ; continue ; } // 属性对象
if ( dest . size ( ) > 0 && dest . getLast ( ) instanceof AccessOpt && rpn . size ( ) > 0 && rpn . getFirst ( ) instanceof AccessOpt ) { dest . add ( new FieldObj ( obj . getVal ( ) ) ) ; continue ; } // / / 普通的对象
// if ( ! ( dest . getLast ( ) instanceof AccessOpt ) & & ! ( rpn . peekFirst ( )
// instanceof MethodOpt ) ) {
// continue ;
dest . add ( new IdentifierObj ( obj . getVal ( ) ) ) ; } return dest ;


signature:
public class Converter { /** * 解析数据 */
private Object parseItem ( ) { } }

implementation: Object obj = Parse . nullobj ; for ( Parse parse : parses ) { obj = parse . fetchItem ( exp ) ; if ( obj != Parse . nullobj ) { skipSpace ( ) ; return parseItem ( obj ) ; } } throw new ElException ( "无法解析!" ) ;


signature:
public class Converter { /** * 转换数据 , 主要是转换负号 , 方法执行 */
private Object parseItem ( Object item ) { } }

implementation:
// 处理参数个数
if ( methods . peek ( ) != null ) { MethodOpt opt = methods . peek ( ) ; if ( opt . getSize ( ) <= 0 ) { if ( ! ( item instanceof CommaOpt ) && ! ( item instanceof RBracketOpt ) ) { opt . setSize ( 1 ) ; } } else { if ( item instanceof CommaOpt ) { opt . setSize ( opt . getSize ( ) + 1 ) ; } } } // 左括号
if ( item instanceof LBracketOpt ) { if ( prev instanceof Elobj ) { MethodOpt prem = new MethodOpt ( ) ; item = new Object [ ] { prem , new LBracketOpt ( ) } ; methods . addFirst ( prem ) ; } else { methods . addFirst ( null ) ; } } // 右括号
if ( item instanceof RBracketOpt ) { if ( methods . poll ( ) != null ) { item = new Object [ ] { new RBracketOpt ( ) , new InvokeMethodOpt ( ) } ; } } // 转换负号 ' - '
if ( item instanceof SubOpt && NegativeOpt . isNegetive ( prev ) ) { item = new NegativeOpt ( ) ; } prev = item ; return item ;


signature:
public class Converter { /** * 跳过空格 , 并返回是否跳过空格 ( 是否存在空格 ) */
private boolean skipSpace ( ) { } }

implementation: boolean space = false ; while ( ! exp . isEmpty ( ) && Character . isWhitespace ( exp . peek ( ) ) ) { space = true ; exp . poll ( ) ; } return space ;


signature:
public class Iocs { /** * 查看一下 me 中有没有缺少的属性 , 没有的话 , 从 it 补充 */
public static IocObject mergeWith ( IocObject me , IocObject it ) { } }

implementation:
// merge type
if ( me . getType ( ) == null ) me . setType ( it . getType ( ) ) ; // don ' t need merge singleton
// merge events
if ( me . getEvents ( ) == null ) { me . setEvents ( it . getEvents ( ) ) ; } else if ( it . getEvents ( ) != null ) { IocEventSet eventSet = it . getEvents ( ) ; IocEventSet myEventSet = me . getEvents ( ) ; if ( Strings . isBlank ( myEventSet . getCreate ( ) ) ) myEventSet . setCreate ( eventSet . getCreate ( ) ) ; if ( Strings . isBlank ( myEventSet . getDepose ( ) ) ) myEventSet . setDepose ( eventSet . getDepose ( ) ) ; if ( Strings . isBlank ( myEventSet . getFetch ( ) ) ) myEventSet . setFetch ( eventSet . getFetch ( ) ) ; } // merge scope
if ( Strings . isBlank ( me . getScope ( ) ) ) { me . setScope ( it . getScope ( ) ) ; } // merge arguments
if ( ! me . hasArgs ( ) ) me . copyArgys ( it . getArgs ( ) ) ; // merge fields
for ( IocField fld : it . getFields ( ) . values ( ) ) if ( ! me . hasField ( fld . getName ( ) ) ) me . addField ( fld ) ; return me ;


signature:
public class AdaptorErrorContext { /** * 设置当前参数的错误信息 , 是子类可以无限扩展的地方
 * @ param index 参数的索引号
 * @ param err 参数注入器抛出的异常 , 建议先用Lang . unwarp ( err ) 解开 , 获取真正的异常
 * @ param method 入口方法
 * @ param value 期待转换的值
 * @ param inj 参数注入器 */
public void setError ( int index , Throwable err , Method method , Object value , ParamInjector inj ) { } }

implementation: errors [ index ] = err ;


signature:
public class Tmpl { /** * 解析模板对象
 * @ param tmpl
 * 模板字符串
 * @ return 解析好的模板对象
 * @ see # parse ( String , Pattern , int , int ) */
public static Tmpl parse ( String tmpl ) { } }

implementation: if ( null == tmpl ) return null ; return new Tmpl ( tmpl , null , - 1 , - 1 , null ) ;


signature:
public class Tmpl { /** * 解析模板对象 , 并用上下文进行渲染 。
 * 你可以通过参数 ptn 指定自定义的正则表达式来声明自己的模板占位符形式 。 < br >
 * 默认的模板占位符是 < code > ( ? & lt ; ! [ $ ] ) [ $ ] [ { ] ( [ ^ } ] + ) [ } ] < / code >
 * 即 , 形式如 < code > $ { xxxx } < / code > 的会被当做占位符 , 同时 < code > $ $ < / code > 可以逃逸
 * @ param tmpl
 * 模板字符串
 * @ param ptn
 * 一个正则表达式 , 指明占位符的形式 。
 * @ param groupIndex
 * 指定正则表达式 , 哪个匹配组作为你的占位符内容
 * @ param escapeIndex
 * 指明了逃逸字符的组 , 如果为 - 1 则表示没有逃逸字符
 * @ param getEscapeStr
 * 给定如何显示逃逸字符的回调
 * @ return 模板对象 */
public static Tmpl parse ( String tmpl , Pattern ptn , int groupIndex , int escapeIndex , TmplEscapeStr getEscapeStr ) { } }

implementation: if ( null == tmpl ) return null ; return new Tmpl ( tmpl , ptn , groupIndex , escapeIndex , getEscapeStr ) ;


signature:
public class Tmpl { /** * 解析模板对象 , 并用上下文进行渲染 。
 * @ param tmpl
 * 模板字符串
 * @ param startChar
 * 占位符起始标示符
 * @ param leftBrace
 * 左侧括号
 * @ param rightBrace
 * 右侧括号
 * @ return 模板对象 */
public static Tmpl parse ( String tmpl , final String startChar , String leftBrace , String rightBrace ) { } }

implementation: if ( null == tmpl ) return null ; String regex = "((?<![" + startChar + "])[" + startChar + "][" + ( "[" . equals ( leftBrace ) ? "\\[" : leftBrace ) + "]([^" + ( "]" . equals ( rightBrace ) ? "\\]" : rightBrace ) + "]+)[" + rightBrace + "])|([" + startChar + "][" + startChar + "])" ; Pattern ptn = Pattern . compile ( regex ) ; return new Tmpl ( tmpl , ptn , 2 , 3 , new TmplEscapeStr ( ) { public String get ( Matcher m ) { return startChar ; } } ) ;


signature:
public class Images { /** * 对一个图像进行旋转
 * @ param srcIm
 * 原图像文件
 * @ param taIm
 * 转换后的图像文件
 * @ param degree
 * 旋转角度 , 90 为顺时针九十度 , - 90 为逆时针九十度
 * @ return 旋转后得图像对象 */
public static BufferedImage rotate ( Object srcIm , File taIm , int degree ) { } }

implementation: BufferedImage im = Images . read ( srcIm ) ; BufferedImage im2 = Images . rotate ( im , degree ) ; Images . write ( im2 , taIm ) ; return im2 ;


signature:
public class Images { /** * 对一个图像进行旋转
 * @ param srcPath
 * 原图像文件路径
 * @ param taPath
 * 转换后的图像文件路径
 * @ param degree
 * 旋转角度 , 90 为顺时针九十度 , - 90 为逆时针九十度
 * @ return 旋转后得图像对象 */
public static BufferedImage rotate ( String srcPath , String taPath , int degree ) throws IOException { } }

implementation: File srcIm = Files . findFile ( srcPath ) ; if ( null == srcIm ) throw Lang . makeThrow ( "Fail to find image file '%s'!" , srcPath ) ; File taIm = Files . createFileIfNoExists ( taPath ) ; return rotate ( srcIm , taIm , degree ) ;


signature:
public class Images { /** * 自动等比缩放一个图片 , 并将其保存成目标图像文件 < br / >
 * 多余的部分 , 用给定背景颜色补上 < br / >
 * 如果参数中的宽度或高度为 < b > - 1 < / b > 的话 , 着按照指定的高度或宽度对原图等比例缩放图片 , 不添加背景颜色
 * 图片格式支持 png | gif | jpg | bmp | wbmp
 * @ param srcIm
 * 源图像文件对象
 * @ param taIm
 * 目标图像文件对象
 * @ param w
 * 宽度
 * @ param h
 * 高度
 * @ param bgColor
 * 背景颜色
 * @ return 被转换前的图像对象
 * @ throws IOException
 * 当读写文件失败时抛出 */
public static BufferedImage zoomScale ( Object srcIm , File taIm , int w , int h , Color bgColor ) throws IOException { } }

implementation: BufferedImage old = read ( srcIm ) ; BufferedImage im = Images . zoomScale ( old , w , h , bgColor ) ; write ( im , taIm ) ; return old ;


signature:
public class Images { /** * 自动等比缩放一个图片 , 并将其保存成目标图像文件 < br / >
 * 多余的部分 , 用给定背景颜色补上 < br / >
 * 如果参数中的宽度或高度为 < b > - 1 < / b > 的话 , 着按照指定的高度或宽度对原图等比例缩放图片 , 不添加背景颜色
 * 图片格式支持 png | gif | jpg | bmp | wbmp
 * @ param srcPath
 * 源图像路径
 * @ param taPath
 * 目标图像路径 , 如果不存在 , 则创建
 * @ param w
 * 宽度
 * @ param h
 * 高度
 * @ param bgColor
 * 背景颜色
 * @ return 被转换前的图像对象
 * @ throws IOException
 * 当读写文件失败时抛出 */
public static BufferedImage zoomScale ( String srcPath , String taPath , int w , int h , Color bgColor ) throws IOException { } }

implementation: File srcIm = Files . findFile ( srcPath ) ; if ( null == srcIm ) throw Lang . makeThrow ( "Fail to find image file '%s'!" , srcPath ) ; File taIm = Files . createFileIfNoExists ( taPath ) ; return zoomScale ( srcIm , taIm , w , h , bgColor ) ;


signature:
public class Images { /** * 自动等比缩放一个图片 , 多余的部分 , 用给定背景颜色补上 < br / >
 * 如果参数中的宽度或高度为 < b > - 1 < / b > 的话 , 着按照指定的高度或宽度对原图等比例缩放图片 , 不添加背景颜色
 * @ param im
 * 图像对象
 * @ param w
 * 宽度
 * @ param h
 * 高度
 * @ param bgColor
 * 背景颜色
 * @ return 被转换后的图像 */
public static BufferedImage zoomScale ( BufferedImage im , int w , int h , Color bgColor ) { } }

implementation:
if ( w == - 1 || h == - 1 ) { return scale ( im , w , h ) ; } // 检查背景颜色
// bgColor = null = = bgColor ? Color . black : bgColor ;
// 获得尺寸
int oW = im . getWidth ( ) ; int oH = im . getHeight ( ) ; float oR = ( float ) oW / ( float ) oH ; float nR = ( float ) w / ( float ) h ; int nW , nH , x , y ; /* * 缩放 */
// 原图太宽 , 计算当原图与画布同高时 , 原图的等比宽度
if ( oR > nR ) { nW = w ; nH = ( int ) ( ( w ) / oR ) ; x = 0 ; y = ( h - nH ) / 2 ; } // 原图太高
else if ( oR < nR ) { nH = h ; nW = ( int ) ( ( h ) * oR ) ; x = ( w - nW ) / 2 ; y = 0 ; } // 比例相同
else { nW = w ; nH = h ; x = 0 ; y = 0 ; } // 创建图像
BufferedImage re = new BufferedImage ( w , h , im . getType ( ) == 0 ? BufferedImage . TYPE_3BYTE_BGR : im . getType ( ) ) ; Graphics2D gc = re . createGraphics ( ) ; if ( null != bgColor ) { gc . setColor ( bgColor ) ; gc . fillRect ( 0 , 0 , w , h ) ; } // 绘制图像
gc . drawImage ( im , x , y , nW , nH , bgColor , null ) ; // 释放
gc . dispose ( ) ; // 返回
return re ;


signature:
public class Images { /** * 自动等比缩放一个图片
 * @ param im
 * 图像对象
 * @ param w
 * 宽度
 * @ param h
 * 高度
 * @ return 被转换后的图像 */
public static BufferedImage scale ( BufferedImage im , int w , int h ) { } }

implementation:
// 获得尺寸
int oW = im . getWidth ( ) ; int oH = im . getHeight ( ) ; int nW = w , nH = h ; /* * 缩放 */
// 未指定图像高度 , 根据原图尺寸计算出高度
if ( h == - 1 ) { nH = ( int ) ( ( float ) w / oW * oH ) ; } // 未指定图像宽度 , 根据原图尺寸计算出宽度
else if ( w == - 1 ) { nW = ( int ) ( ( float ) h / oH * oW ) ; } // 创建图像
BufferedImage re = new BufferedImage ( nW , nH , im . getType ( ) ) ; Graphics2D gc = re . createGraphics ( ) ; gc . drawImage ( im , 0 , 0 , nW , nH , null ) ; gc . dispose ( ) ; // 返回
return re ;


signature:
public class Images { /** * 自动缩放剪切一个图片 , 令其符合给定的尺寸 , 并将其保存成目标图像文件
 * 图片格式支持 png | gif | jpg | bmp | wbmp
 * @ param srcIm
 * 源图像文件对象
 * @ param taIm
 * 目标图像文件对象
 * @ param w
 * 宽度
 * @ param h
 * 高度
 * @ return 被转换前的图像对象
 * @ throws IOException
 * 当读写文件失败时抛出 */
public static BufferedImage clipScale ( Object srcIm , File taIm , int w , int h ) throws IOException { } }

implementation: BufferedImage old = read ( srcIm ) ; BufferedImage im = Images . clipScale ( old , w , h ) ; write ( im , taIm ) ; return old ;


signature:
public class Images { /** * 根据给定的起始坐标点与结束坐标点来剪切一个图片 , 令其符合给定的尺寸 , 并将其保存成目标图像文件
 * 图片格式支持 png | gif | jpg | bmp | wbmp
 * @ param srcIm
 * 源图像文件对象
 * @ param taIm
 * 目标图像文件对象
 * @ param startPoint
 * 起始坐标点 , 其值 [ x , y ] 为相对原图片左上角的坐标
 * @ param endPoint
 * 结束坐标点 , 其值 [ x , y ] 为相对原图片左上角的坐标
 * @ return 被转换前的图像对象
 * @ throws IOException
 * 当读写文件失败时抛出 */
public static BufferedImage clipScale ( Object srcIm , File taIm , int [ ] startPoint , int [ ] endPoint ) throws IOException { } }

implementation: BufferedImage old = read ( srcIm ) ; BufferedImage im = clipScale ( old , startPoint , endPoint ) ; write ( im , taIm ) ; return old ;


signature:
public class Images { /** * 根据给定的起始坐标点与结束坐标点来剪切一个图片 , 令其符合给定的尺寸 , 并将其保存成目标图像文件
 * 图片格式支持 png | gif | jpg | bmp | wbmp
 * @ param srcPath
 * 源图像文件对象
 * @ param taPath
 * 目标图像文件对象
 * @ param startPoint
 * 起始坐标点 , 其值 [ x , y ] 为相对原图片左上角的坐标
 * @ param endPoint
 * 结束坐标点 , 其值 [ x , y ] 为相对原图片左上角的坐标
 * @ return 被转换前的图像对象
 * @ throws IOException
 * 当读写文件失败时抛出 */
public static BufferedImage clipScale ( String srcPath , String taPath , int [ ] startPoint , int [ ] endPoint ) throws IOException { } }

implementation: File srcIm = Files . findFile ( srcPath ) ; if ( null == srcIm ) throw Lang . makeThrow ( "Fail to find image file '%s'!" , srcPath ) ; File taIm = Files . createFileIfNoExists ( taPath ) ; return clipScale ( srcIm , taIm , startPoint , endPoint ) ;


signature:
public class Images { /** * 自动缩放剪切一个图片 , 令其符合给定的尺寸
 * 如果图片太大 , 则将其缩小 , 如果图片太小 , 则将其放大 , 多余的部分被裁减
 * @ param im
 * 图像对象
 * @ param w
 * 宽度
 * @ param h
 * 高度
 * @ return 被转换后的图像 */
public static BufferedImage clipScale ( BufferedImage im , int w , int h ) { } }

implementation:
// 获得尺寸
int oW = im . getWidth ( ) ; int oH = im . getHeight ( ) ; float oR = ( float ) oW / ( float ) oH ; float nR = ( float ) w / ( float ) h ; int nW , nH , x , y ; /* * 裁减 */
// 原图太宽 , 计算当原图与画布同高时 , 原图的等比宽度
if ( oR > nR ) { nW = ( h * oW ) / oH ; nH = h ; x = ( w - nW ) / 2 ; y = 0 ; } // 原图太长
else if ( oR < nR ) { nW = w ; nH = ( w * oH ) / oW ; x = 0 ; y = ( h - nH ) / 2 ; } // 比例相同
else { nW = w ; nH = h ; x = 0 ; y = 0 ; } // 创建图像
BufferedImage re = new BufferedImage ( w , h , ColorSpace . TYPE_RGB ) ; re . createGraphics ( ) . drawImage ( im , x , y , nW , nH , Color . black , null ) ; // 返回
return re ;


signature:
public class Images { /** * 水平翻转一张图片
 * @ param srcIm
 * 源图片
 * @ return 被转换后的图像 */
public static BufferedImage flipHorizontal ( Object srcIm ) { } }

implementation: BufferedImage im1 = read ( srcIm ) ; int w = im1 . getWidth ( ) ; int h = im1 . getHeight ( ) ; BufferedImage flipImage = new BufferedImage ( w , h , im1 . getType ( ) ) ; Graphics2D gs = flipImage . createGraphics ( ) ; gs . drawImage ( im1 , 0 , 0 , w , h , w , 0 , 0 , h , null ) ; gs . dispose ( ) ; return flipImage ;


signature:
public class Images { /** * 水平翻转一张图片
 * @ param srcIm
 * 源图片
 * @ param tarIm
 * 目标图片
 * @ return 被转换后的图像 */
public static BufferedImage flipHorizontal ( Object srcIm , File tarIm ) { } }

implementation: BufferedImage flipImage = flipHorizontal ( srcIm ) ; Images . write ( flipImage , tarIm ) ; return flipImage ;


signature:
public class Images { /** * 扭曲图片
 * @ param srcIm
 * 源图片
 * @ param twistRank
 * 扭曲程度 , 默认为1 , 数值越大扭曲程度越高
 * @ param bgColor
 * 扭曲后露出的底图填充色 , 一般选择要源图片的背景色
 * @ return 被扭曲后的图片 */
public static BufferedImage twist ( Object srcIm , double twistRank , String bgColor ) { } }

implementation:
if ( twistRank <= 0 ) { twistRank = 1 ; } BufferedImage bufImg = read ( srcIm ) ; double period = R . random ( 0 , 7 ) + 3 ; // 波形的幅度倍数 , 越大扭曲的程序越高 , 一般为3
double phase = R . random ( 0 , 6 ) ; // 波形的起始相位 , 取值区间 ( 0-2 * PI )
int width = bufImg . getWidth ( ) ; int height = bufImg . getHeight ( ) ; BufferedImage tarIm = new BufferedImage ( width , height , BufferedImage . TYPE_INT_RGB ) ; Graphics2D gc = tarIm . createGraphics ( ) ; gc . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; gc . setBackground ( Strings . isBlank ( bgColor ) ? Colors . randomColor ( ) : Colors . as ( bgColor ) ) ; gc . clearRect ( 0 , 0 , width , height ) ; for ( int i = 0 ; i < width ; i ++ ) { for ( int j = 0 ; j < height ; j ++ ) { int nX = pos4twist ( twistRank , phase , period , height , i , j ) ; int nY = j ; if ( nX >= 0 && nX < width && nY >= 0 && nY < height ) { tarIm . setRGB ( nX , nY , bufImg . getRGB ( i , j ) ) ; } } } return tarIm ;


signature:
public class Images { /** * 2 . width , y , x */
private static int pos4twist ( double rank , double phase , double period , int hOrW , int xOrY , int yOrX ) { } }

implementation: double dyOrX = Math . PI * rank * yOrX / hOrW + phase ; double dxOrY = Math . sin ( dyOrX ) ; return xOrY + ( int ) ( dxOrY * period ) ;