private Code parseCode ( Element codeElement , Map < String , Scope > scopes ) { // Code name Code code = new Code ( nodeAttribute ( codeElement , TAG_CODE_ATTR_NAME , Utils . generateRandomName ( ) ) ) ; // Code priority code . setPriority ( nodeAttribute ( codeElement , TAG_CODE_ATTR_PRIORITY , Code . DEFAULT_PRIORITY ) ) ; // Do show variables outside the code? code . setTransparent ( nodeAttribute ( codeElement , TAG_CODE_ATTR_TRANSPARENT , true ) ) ; // Template to building NodeList templateElements = codeElement . getElementsByTagNameNS ( SCHEMA_LOCATION , TAG_TEMPLATE ) ; if ( templateElements . getLength ( ) > 0 ) { code . setTemplate ( parseTemplate ( templateElements . item ( 0 ) ) ) ; } else { throw new TextProcessorFactoryException ( "Illegal configuration. Can't find template of code." ) ; } // Pattern to parsing NodeList patternElements = codeElement . getElementsByTagNameNS ( SCHEMA_LOCATION , TAG_PATTERN ) ; if ( patternElements . getLength ( ) > 0 ) { for ( int i = 0 ; i < patternElements . getLength ( ) ; i ++ ) { code . addPattern ( parsePattern ( patternElements . item ( i ) , scopes ) ) ; } } else { throw new TextProcessorFactoryException ( "Illegal configuration. Can't find pattern of code." ) ; } // return code return code ; }
Parse bb - code from DOM Node