idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
23,000 | public static int contrast ( Color left , Color right ) throws ServletException { return ( Math . max ( left . getRed ( ) , right . getRed ( ) ) - Math . min ( left . getRed ( ) , right . getRed ( ) ) ) + ( Math . max ( left . getGreen ( ) , right . getGreen ( ) ) - Math . min ( left . getGreen ( ) , right . getGreen ( ) ) ) + ( Math . max ( left . getBlue ( ) , right . getBlue ( ) ) - Math . max ( left . getBlue ( ) , right . getBlue ( ) ) ) ; } | calculate the contrast between 2 colors |
23,001 | public void setAction ( String action ) throws ApplicationException { action = action . toLowerCase ( ) . trim ( ) ; if ( action . equals ( "getall" ) ) this . action = ACTION_GET_ALL ; else if ( action . equals ( "get" ) ) this . action = ACTION_GET ; else if ( action . equals ( "set" ) ) this . action = ACTION_SET ; else if ( action . equals ( "delete" ) ) this . action = ACTION_DELETE ; else throw new ApplicationException ( "attribute action of the tag registry has an invalid value [" + action + "], valid values are [getAll, get, set, delete]" ) ; } | set the value action action to the registry |
23,002 | public static boolean operate ( PageContext pc , String [ ] varNames ) { int scope = VariableInterpreter . scopeString2Int ( pc . ignoreScopes ( ) , varNames [ 0 ] ) ; return _operate ( pc , scope , KeyImpl . toKeyArray ( varNames ) , scope == Scope . SCOPE_UNDEFINED ? 0 : 1 ) ; } | called by the Elvis operator from the interpreter |
23,003 | protected void setTldFile ( Resource fileTld , int dialect ) throws TagLibException { if ( dialect == CFMLEngine . DIALECT_BOTH ) { setTldFile ( fileTld , CFMLEngine . DIALECT_CFML ) ; setTldFile ( fileTld , CFMLEngine . DIALECT_LUCEE ) ; return ; } TagLib [ ] tlds = dialect == CFMLEngine . DIALECT_CFML ? cfmlTlds : luceeTlds ; if ( fileTld == null ) return ; this . tldFile = fileTld ; String key ; Map < String , TagLib > map = new HashMap < String , TagLib > ( ) ; for ( int i = 0 ; i < tlds . length ; i ++ ) { key = getKey ( tlds [ i ] ) ; map . put ( key , tlds [ i ] ) ; } TagLib tl ; if ( fileTld . isDirectory ( ) ) { Resource [ ] files = fileTld . listResources ( new ExtensionResourceFilter ( new String [ ] { "tld" , "tldx" } ) ) ; for ( int i = 0 ; i < files . length ; i ++ ) { try { tl = TagLibFactory . loadFromFile ( files [ i ] , getIdentification ( ) ) ; key = getKey ( tl ) ; if ( ! map . containsKey ( key ) ) map . put ( key , tl ) ; else overwrite ( map . get ( key ) , tl ) ; } catch ( TagLibException tle ) { SystemOut . printDate ( out , "can't load tld " + files [ i ] ) ; tle . printStackTrace ( getErrWriter ( ) ) ; } } } else if ( fileTld . isFile ( ) ) { tl = TagLibFactory . loadFromFile ( fileTld , getIdentification ( ) ) ; key = getKey ( tl ) ; if ( ! map . containsKey ( key ) ) map . put ( key , tl ) ; else overwrite ( map . get ( key ) , tl ) ; } tlds = new TagLib [ map . size ( ) ] ; if ( dialect == CFMLEngine . DIALECT_CFML ) cfmlTlds = tlds ; else luceeTlds = tlds ; int index = 0 ; Iterator < TagLib > it = map . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { tlds [ index ++ ] = it . next ( ) ; } } | set the optional directory of the tag library deskriptors |
23,004 | protected void setScheduler ( CFMLEngine engine , Resource scheduleDirectory ) throws PageException { if ( scheduleDirectory == null ) { if ( this . scheduler == null ) this . scheduler = new SchedulerImpl ( engine , "<?xml version=\"1.0\"?>\n<schedule></schedule>" , this ) ; return ; } if ( ! isDirectory ( scheduleDirectory ) ) throw new ExpressionException ( "schedule task directory " + scheduleDirectory + " doesn't exist or is not a directory" ) ; try { if ( this . scheduler == null ) this . scheduler = new SchedulerImpl ( engine , this , scheduleDirectory , SystemUtil . getCharset ( ) . name ( ) ) ; } catch ( Exception e ) { throw Caster . toPageException ( e ) ; } } | sets the Schedule Directory |
23,005 | protected void setLocale ( String strLocale ) { if ( strLocale == null ) { this . locale = Locale . US ; } else { try { this . locale = Caster . toLocale ( strLocale ) ; if ( this . locale == null ) this . locale = Locale . US ; } catch ( ExpressionException e ) { this . locale = Locale . US ; } } } | sets the locale |
23,006 | protected boolean isDirectory ( Resource directory ) { if ( directory . exists ( ) ) return directory . isDirectory ( ) ; try { directory . createDirectory ( true ) ; return true ; } catch ( IOException e ) { e . printStackTrace ( getErrWriter ( ) ) ; } return false ; } | is file a directory or not touch if not exist |
23,007 | public Cache createRAMCache ( Struct arguments ) throws IOException { RamCache rc = new RamCache ( ) ; if ( arguments == null ) arguments = new StructImpl ( ) ; rc . init ( this , "" + CreateUniqueId . invoke ( ) , arguments ) ; return rc ; } | creates a new RamCache please make sure to finalize . |
23,008 | public static MapPro duplicateDataMember ( ComponentImpl c , MapPro map , MapPro newMap , boolean deepCopy ) { Iterator it = map . entrySet ( ) . iterator ( ) ; Map . Entry entry ; Object value ; while ( it . hasNext ( ) ) { entry = ( Entry ) it . next ( ) ; value = entry . getValue ( ) ; if ( ! ( value instanceof UDF ) ) { if ( deepCopy ) value = Duplicator . duplicate ( value , deepCopy ) ; newMap . put ( entry . getKey ( ) , value ) ; } } return newMap ; } | duplicate the datamember in the map ignores the udfs |
23,009 | public void init ( PageContext pageContext , ComponentPageImpl componentPage , boolean executeConstr ) throws PageException { this . pageSource = componentPage . getPageSource ( ) ; if ( ! StringUtil . isEmpty ( properties . extend ) ) { base = ComponentLoader . searchComponent ( pageContext , componentPage . getPageSource ( ) , properties . extend , Boolean . TRUE , null , true , executeConstr ) ; } else { CIPage p = ( ( ConfigWebImpl ) pageContext . getConfig ( ) ) . getBaseComponentPage ( pageSource . getDialect ( ) , pageContext ) ; if ( ! componentPage . getPageSource ( ) . equals ( p . getPageSource ( ) ) ) { base = ComponentLoader . loadComponent ( pageContext , p , "Component" , false , false , true , executeConstr ) ; } } if ( base != null ) { this . dataMemberDefaultAccess = base . dataMemberDefaultAccess ; this . _static = new StaticScope ( base . _static , this , componentPage , dataMemberDefaultAccess ) ; this . absFin = base . absFin ; _data = base . _data ; _udfs = new HashMapPro < Key , UDF > ( base . _udfs ) ; setTop ( this , base ) ; } else { this . dataMemberDefaultAccess = pageContext . getCurrentTemplateDialect ( ) == CFMLEngine . DIALECT_CFML ? pageContext . getConfig ( ) . getComponentDataMemberDefaultAccess ( ) : Component . ACCESS_PRIVATE ; this . _static = new StaticScope ( null , this , componentPage , dataMemberDefaultAccess ) ; _udfs = new HashMapPro < Key , UDF > ( ) ; _data = MapFactory . getConcurrentMap ( ) ; } if ( ! StringUtil . isEmpty ( properties . implement ) ) { if ( absFin == null ) absFin = new AbstractFinal ( ) ; absFin . add ( InterfaceImpl . loadInterfaces ( pageContext , getPageSource ( ) , properties . implement ) ) ; } useShadow = base == null ? ( pageSource . getDialect ( ) == CFMLEngine . DIALECT_CFML ? pageContext . getConfig ( ) . useComponentShadow ( ) : false ) : base . useShadow ; if ( useShadow ) { if ( base == null ) scope = new ComponentScopeShadow ( this , MapFactory . getConcurrentMap ( ) ) ; else scope = new ComponentScopeShadow ( this , ( ComponentScopeShadow ) base . scope , false ) ; } else { scope = new ComponentScopeThis ( this ) ; } initProperties ( ) ; if ( ! componentPage . _static . isInit ( ) ) { componentPage . _static . setInit ( true ) ; try { componentPage . staticConstructor ( pageContext , this ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; componentPage . _static . setInit ( false ) ; throw Caster . toPageException ( t ) ; } } } | initalize the Component |
23,010 | public Variables beforeCall ( PageContext pc ) { Variables parent = pc . variablesScope ( ) ; pc . setVariablesScope ( scope ) ; return parent ; } | will be called before executing method or constructor |
23,011 | public Set < Key > keySet ( int access ) { Set < Key > set = new LinkedHashSet < Key > ( ) ; Map . Entry < Key , Member > entry ; Iterator < Entry < Key , Member > > it = _data . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { entry = it . next ( ) ; if ( entry . getValue ( ) . getAccess ( ) <= access ) set . add ( entry . getKey ( ) ) ; } return set ; } | list of keys |
23,012 | protected Member getMember ( PageContext pc , Collection . Key key , boolean dataMember , boolean superAccess ) { if ( dataMember && key . equalsIgnoreCase ( KeyConstants . _super ) && isPrivate ( pc ) ) { Component ac = ComponentUtil . getActiveComponent ( pc , this ) ; return SuperComponent . superMember ( ( ComponentImpl ) ac . getBaseComponent ( ) ) ; } if ( superAccess ) return _udfs . get ( key ) ; Member member = _data . get ( key ) ; if ( isAccessible ( pc , member ) ) return member ; return null ; } | get entry matching key |
23,013 | private int getAccess ( Collection . Key key ) { Member member = getMember ( ACCESS_PRIVATE , key , false , false ) ; if ( member == null ) return Component . ACCESS_PRIVATE ; return member . getAccess ( ) ; } | return the access of a member |
23,014 | int getAccess ( PageContext pc ) { if ( pc == null ) return ACCESS_PUBLIC ; if ( isPrivate ( pc ) ) return ACCESS_PRIVATE ; if ( isPackage ( pc ) ) return ACCESS_PACKAGE ; return ACCESS_PUBLIC ; } | returns current access to this component |
23,015 | private Object _set ( PageContext pc , Collection . Key key , Object value ) throws ExpressionException { if ( value instanceof Member ) { Member m = ( Member ) value ; if ( m instanceof UDFPlus ) { UDFPlus udf = ( UDFPlus ) m ; if ( udf . getAccess ( ) > Component . ACCESS_PUBLIC ) udf . setAccess ( Component . ACCESS_PUBLIC ) ; _data . put ( key , udf ) ; _udfs . put ( key , udf ) ; hasInjectedFunctions = true ; } else _data . put ( key , m ) ; } else { Member existing = _data . get ( key ) ; if ( loaded && ! isAccessible ( pc , existing != null ? existing . getAccess ( ) : dataMemberDefaultAccess ) ) throw new ExpressionException ( "Component [" + getCallName ( ) + "] has no accessible Member with name [" + key + "]" , "enable [trigger data member] in administrator to also invoke getters and setters" ) ; _data . put ( key , new DataMember ( existing != null ? existing . getAccess ( ) : dataMemberDefaultAccess , existing != null ? existing . getModifier ( ) : Member . MODIFIER_NONE , value ) ) ; } return value ; } | sets a value to the current Component dont to base Component |
23,016 | public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { boolean pcCreated = false ; PageContext pc = ThreadLocalPageContext . get ( ) ; try { if ( pc == null ) { pcCreated = true ; ConfigWeb config = ( ConfigWeb ) ThreadLocalPageContext . getConfig ( ) ; Pair [ ] parr = new Pair [ 0 ] ; pc = ThreadUtil . createPageContext ( config , DevNullOutputStream . DEV_NULL_OUTPUT_STREAM , "localhost" , "/" , "" , new Cookie [ 0 ] , parr , null , parr , new StructImpl ( ) , true , - 1 ) ; } String name = in . readUTF ( ) ; if ( name . startsWith ( "evaluateComponent('" ) && name . endsWith ( "})" ) ) { readExternalOldStyle ( pc , name ) ; return ; } String path = null ; int index = name . indexOf ( '|' ) ; if ( index != - 1 ) { path = name . substring ( index + 1 ) ; name = name . substring ( 0 , index ) ; } String md5 = in . readUTF ( ) ; Struct _this = Caster . toStruct ( in . readObject ( ) , null ) ; Struct _var = Caster . toStruct ( in . readObject ( ) , null ) ; String template = in . readUTF ( ) ; if ( pc != null && pc . getBasePageSource ( ) == null && ! StringUtil . isEmpty ( template ) ) { Resource res = ResourceUtil . toResourceNotExisting ( pc , template ) ; PageSource ps = pc . toPageSource ( res , null ) ; if ( ps != null ) { ( ( PageContextImpl ) pc ) . setBase ( ps ) ; } } try { ComponentImpl other = ( ComponentImpl ) EvaluateComponent . invoke ( pc , name , md5 , _this , _var ) ; _readExternal ( other ) ; } catch ( PageException pe ) { boolean done = false ; if ( ! StringUtil . isEmpty ( path ) ) { Resource res = ResourceUtil . toResourceExisting ( pc , path , false , null ) ; if ( res != null ) { PageSource ps = pc . toPageSource ( res , null ) ; if ( ps != null ) { try { ComponentImpl other = ComponentLoader . loadComponent ( pc , ps , name , false , true ) ; _readExternal ( other ) ; done = true ; } catch ( PageException pe2 ) { throw ExceptionUtil . toIOException ( pe2 ) ; } } } } if ( ! done ) throw ExceptionUtil . toIOException ( pe ) ; } } finally { if ( pcCreated ) ThreadLocalPageContext . release ( ) ; } } | MUST more native impl |
23,017 | public void add ( TagLibTag libTag , Tag tag , FunctionLib [ ] flibs , SourceCode cfml ) { tags . add ( new TagData ( libTag , tag , flibs , cfml ) ) ; } | add a tag to the pool to evaluate at the end |
23,018 | public void run ( ) throws TemplateException { { Iterator < TagData > it = tags . iterator ( ) ; while ( it . hasNext ( ) ) { TagData td = it . next ( ) ; SourceCode cfml = td . cfml ; cfml . setPos ( td . pos ) ; try { if ( td . libTag . getEvaluator ( ) != null ) td . libTag . getEvaluator ( ) . evaluate ( td . tag , td . libTag , td . flibs ) ; } catch ( EvaluatorException e ) { clear ( ) ; throw new TemplateException ( cfml , e ) ; } catch ( Throwable e ) { ExceptionUtil . rethrowIfNecessary ( e ) ; clear ( ) ; throw new TemplateException ( cfml , e ) ; } } tags . clear ( ) ; } Iterator < FunctionData > it = functions . iterator ( ) ; while ( it . hasNext ( ) ) { FunctionData td = it . next ( ) ; SourceCode cfml = td . cfml ; cfml . setPos ( td . pos ) ; try { if ( td . flf . getEvaluator ( ) != null ) td . flf . getEvaluator ( ) . evaluate ( td . bif , td . flf ) ; } catch ( EvaluatorException e ) { clear ( ) ; throw new TemplateException ( cfml , e ) ; } catch ( Throwable e ) { ExceptionUtil . rethrowIfNecessary ( e ) ; clear ( ) ; throw new TemplateException ( cfml , e ) ; } } functions . clear ( ) ; } | Die Methode run wird aufgerufen sobald der CFML Transformer den uebersetzungsprozess angeschlossen hat . Die metode run rauft darauf alle Evaluatoren auf die intern gespeicher wurden und loescht den internen Speicher . |
23,019 | public static Object [ ] getValue ( PageContext pc , Ref [ ] refs ) throws PageException { Object [ ] objs = new Object [ refs . length ] ; for ( int i = 0 ; i < refs . length ; i ++ ) { objs [ i ] = refs [ i ] . getValue ( pc ) ; } return objs ; } | transalte a Ref array to a Object array |
23,020 | public static Bundle installBundle ( BundleContext context , Resource bundle , boolean checkExistence ) throws IOException , BundleException { if ( checkExistence ) { BundleFile bf = new BundleFile ( bundle ) ; if ( ! bf . isBundle ( ) ) throw new BundleException ( bundle + " is not a valid bundle!" ) ; Bundle existing = loadBundleFromLocal ( context , bf . getSymbolicName ( ) , bf . getVersion ( ) , false , null ) ; if ( existing != null ) return existing ; } return _loadBundle ( context , bundle . getAbsolutePath ( ) , bundle . getInputStream ( ) , true ) ; } | only installs a bundle if the bundle does not already exist if the bundle exists the existing bundle is unloaded first . |
23,021 | private static Bundle _loadBundle ( BundleContext context , String path , InputStream is , boolean closeStream ) throws BundleException { log ( Log . LEVEL_INFO , "add bundle:" + path ) ; try { return context . installBundle ( path , is ) ; } finally { if ( closeStream && is != null ) { try { is . close ( ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; } } } } | does not check if the bundle already exists! |
23,022 | public static Bundle installBundle ( BundleContext context , InputStream bundleIS , boolean closeStream , boolean checkExistence ) throws IOException , BundleException { String name = System . currentTimeMillis ( ) + ".tmp" ; Resource dir = SystemUtil . getTempDirectory ( ) ; Resource tmp = dir . getRealResource ( name ) ; int count = 0 ; while ( tmp . exists ( ) ) tmp = dir . getRealResource ( ( count ++ ) + "_" + name ) ; IOUtil . copy ( bundleIS , tmp , closeStream ) ; try { return installBundle ( context , tmp , checkExistence ) ; } finally { tmp . delete ( ) ; } } | only installs a bundle if the bundle does not already exist if the bundle exists the existing bundle is unloaded first . the bundle is not stored physically on the system . |
23,023 | public static Class loadClass ( String className , Class defaultValue ) { className = className . trim ( ) ; CFMLEngine engine = CFMLEngineFactory . getInstance ( ) ; BundleCollection bc = engine . getBundleCollection ( ) ; try { return bc . core . loadClass ( className ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; } Bundle [ ] bundles = bc . getBundleContext ( ) . getBundles ( ) ; for ( Bundle b : bundles ) { if ( b == bc . core ) continue ; try { return b . loadClass ( className ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; } } CFMLEngineFactory factory = engine . getCFMLEngineFactory ( ) ; try { return factory . getClass ( ) . getClassLoader ( ) . loadClass ( className ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; } Set < String > loaded = new HashSet < String > ( ) ; for ( Bundle b : bundles ) { loaded . add ( b . getSymbolicName ( ) + "|" + b . getVersion ( ) ) ; } try { File dir = factory . getBundleDirectory ( ) ; File [ ] children = dir . listFiles ( JAR_EXT_FILTER ) ; BundleFile bf ; for ( int i = 0 ; i < children . length ; i ++ ) { try { bf = new BundleFile ( children [ i ] ) ; if ( bf . isBundle ( ) && ! loaded . contains ( bf . getSymbolicName ( ) + "|" + bf . getVersion ( ) ) && bf . hasClass ( className ) ) { Bundle b = null ; try { b = _loadBundle ( bc . getBundleContext ( ) , bf . getFile ( ) ) ; } catch ( IOException e ) { } if ( b != null ) { startIfNecessary ( b ) ; return b . loadClass ( className ) ; } } } catch ( Throwable t2 ) { ExceptionUtil . rethrowIfNecessary ( t2 ) ; } } } catch ( Throwable t1 ) { ExceptionUtil . rethrowIfNecessary ( t1 ) ; } return defaultValue ; } | tries to load a class with ni bundle definition |
23,024 | public static void removeLocalBundle ( String name , Version version , boolean removePhysical , boolean doubleTap ) throws BundleException { name = name . trim ( ) ; CFMLEngine engine = CFMLEngineFactory . getInstance ( ) ; CFMLEngineFactory factory = engine . getCFMLEngineFactory ( ) ; BundleFile bf = _getBundleFile ( factory , name , version , null ) ; if ( bf != null ) { BundleDefinition bd = bf . toBundleDefinition ( ) ; if ( bd != null ) { Bundle b = bd . getLocalBundle ( ) ; if ( b != null ) { stopIfNecessary ( b ) ; b . uninstall ( ) ; } } } if ( ! removePhysical ) return ; if ( bf != null ) { if ( ! bf . getFile ( ) . delete ( ) && doubleTap ) bf . getFile ( ) . deleteOnExit ( ) ; } } | get local bundle but does not download from update provider! |
23,025 | private void move ( Resource ext ) throws PageException { Resource trg ; Resource trgDir ; try { trg = getExtensionFile ( config , ext , id , name , version ) ; trgDir = trg . getParentResource ( ) ; trgDir . mkdirs ( ) ; if ( ! ext . getParentResource ( ) . equals ( trgDir ) ) { if ( trg . exists ( ) ) trg . delete ( ) ; ResourceUtil . moveTo ( ext , trg , true ) ; this . extensionFile = trg ; } } catch ( Exception e ) { throw Caster . toPageException ( e ) ; } } | copy the file to extension dir if it is not already there |
23,026 | public void setData ( byte [ ] data , boolean append ) { lastModified = System . currentTimeMillis ( ) ; if ( append ) { if ( this . data != null && data != null ) { byte [ ] newData = new byte [ this . data . length + data . length ] ; int i = 0 ; for ( ; i < this . data . length ; i ++ ) { newData [ i ] = this . data [ i ] ; } for ( ; i < this . data . length + data . length ; i ++ ) { newData [ i ] = data [ i - this . data . length ] ; } this . data = newData ; } else if ( data != null ) { this . data = data ; } } else { this . data = data ; } if ( this . data != null ) this . type = TYPE_FILE ; } | Setzt den Feldnamen data . |
23,027 | public static void translate ( Struct sct ) { Iterator < Entry < Key , Object > > it = sct . entryIterator ( ) ; Entry < Key , Object > e ; Object value ; while ( it . hasNext ( ) ) { e = it . next ( ) ; value = e . getValue ( ) ; if ( value instanceof String ) { sct . setEL ( e . getKey ( ) , translate ( ( String ) value ) ) ; } } } | translate all strig values of the struct i script - protected form |
23,028 | public static String translate ( String str ) { if ( str == null ) return "" ; int index , last = 0 , endIndex ; StringBuilder sb = null ; String tagName ; while ( ( index = str . indexOf ( '<' , last ) ) != - 1 ) { int len = str . length ( ) ; char c ; for ( endIndex = index + 1 ; endIndex < len ; endIndex ++ ) { c = str . charAt ( endIndex ) ; if ( ( c < 'a' || c > 'z' ) && ( c < 'A' || c > 'Z' ) ) break ; } tagName = str . substring ( index + 1 , endIndex ) ; if ( compareTagName ( tagName ) ) { if ( sb == null ) { sb = new StringBuilder ( ) ; last = 0 ; } sb . append ( str . substring ( last , index + 1 ) ) ; sb . append ( "invalidTag" ) ; last = endIndex ; } else if ( sb != null ) { sb . append ( str . substring ( last , index + 1 ) ) ; last = index + 1 ; } else last = index + 1 ; } if ( sb != null ) { if ( last != str . length ( ) ) sb . append ( str . substring ( last ) ) ; return sb . toString ( ) ; } return str ; } | translate string to script - protected form |
23,029 | public static String translateScriptProtect ( int scriptProtect ) { if ( scriptProtect == ApplicationContext . SCRIPT_PROTECT_NONE ) return "none" ; if ( scriptProtect == ApplicationContext . SCRIPT_PROTECT_ALL ) return "all" ; Array arr = new ArrayImpl ( ) ; if ( ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_CGI ) > 0 ) arr . appendEL ( "cgi" ) ; if ( ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_COOKIE ) > 0 ) arr . appendEL ( "cookie" ) ; if ( ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_FORM ) > 0 ) arr . appendEL ( "form" ) ; if ( ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_URL ) > 0 ) arr . appendEL ( "url" ) ; try { return ListUtil . arrayToList ( arr , "," ) ; } catch ( PageException e ) { return "none" ; } } | translate int definition of script protect to string definition |
23,030 | public static int translateScriptProtect ( String strScriptProtect ) { strScriptProtect = strScriptProtect . toLowerCase ( ) . trim ( ) ; if ( "none" . equals ( strScriptProtect ) ) return ApplicationContext . SCRIPT_PROTECT_NONE ; if ( "no" . equals ( strScriptProtect ) ) return ApplicationContext . SCRIPT_PROTECT_NONE ; if ( "false" . equals ( strScriptProtect ) ) return ApplicationContext . SCRIPT_PROTECT_NONE ; if ( "all" . equals ( strScriptProtect ) ) return ApplicationContext . SCRIPT_PROTECT_ALL ; if ( "true" . equals ( strScriptProtect ) ) return ApplicationContext . SCRIPT_PROTECT_ALL ; if ( "yes" . equals ( strScriptProtect ) ) return ApplicationContext . SCRIPT_PROTECT_ALL ; String [ ] arr = ListUtil . listToStringArray ( strScriptProtect , ',' ) ; String item ; int scriptProtect = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { item = arr [ i ] . trim ( ) ; if ( "cgi" . equals ( item ) && ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_CGI ) == 0 ) scriptProtect += ApplicationContext . SCRIPT_PROTECT_CGI ; else if ( "cookie" . equals ( item ) && ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_COOKIE ) == 0 ) scriptProtect += ApplicationContext . SCRIPT_PROTECT_COOKIE ; else if ( "form" . equals ( item ) && ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_FORM ) == 0 ) scriptProtect += ApplicationContext . SCRIPT_PROTECT_FORM ; else if ( "url" . equals ( item ) && ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_URL ) == 0 ) scriptProtect += ApplicationContext . SCRIPT_PROTECT_URL ; } return scriptProtect ; } | translate string definition of script protect to int definition |
23,031 | private void callListeners ( final CFMLEngine engine ) { final Iterator < EngineChangeListener > it = listeners . iterator ( ) ; while ( it . hasNext ( ) ) it . next ( ) . onUpdate ( ) ; } | call all registered listener for update of the engine |
23,032 | public File getResourceRoot ( ) throws IOException { if ( resourceRoot == null ) { resourceRoot = new File ( _getResourceRoot ( ) , "lucee-server" ) ; if ( ! resourceRoot . exists ( ) ) resourceRoot . mkdirs ( ) ; } return resourceRoot ; } | return directory to lucee resource root |
23,033 | public static void addFunctionDoc ( PageExceptionImpl pe , FunctionLibFunction flf ) { ArrayList < FunctionLibFunctionArg > args = flf . getArg ( ) ; Iterator < FunctionLibFunctionArg > it = args . iterator ( ) ; StringBuilder pattern = new StringBuilder ( flf . getName ( ) ) ; StringBuilder end = new StringBuilder ( ) ; pattern . append ( "(" ) ; FunctionLibFunctionArg arg ; int c = 0 ; while ( it . hasNext ( ) ) { arg = it . next ( ) ; if ( ! arg . isRequired ( ) ) { pattern . append ( " [" ) ; end . append ( "]" ) ; } if ( c ++ > 0 ) pattern . append ( ", " ) ; pattern . append ( arg . getName ( ) ) ; pattern . append ( ":" ) ; pattern . append ( arg . getTypeAsString ( ) ) ; } pattern . append ( end ) ; pattern . append ( "):" ) ; pattern . append ( flf . getReturnTypeAsString ( ) ) ; pe . setAdditional ( KeyConstants . _Pattern , pattern ) ; StringBuilder doc = new StringBuilder ( flf . getDescription ( ) ) ; StringBuilder req = new StringBuilder ( ) ; StringBuilder opt = new StringBuilder ( ) ; StringBuilder tmp ; doc . append ( "\n" ) ; it = args . iterator ( ) ; while ( it . hasNext ( ) ) { arg = it . next ( ) ; tmp = arg . isRequired ( ) ? req : opt ; tmp . append ( "- " ) ; tmp . append ( arg . getName ( ) ) ; tmp . append ( " (" ) ; tmp . append ( arg . getTypeAsString ( ) ) ; tmp . append ( "): " ) ; tmp . append ( arg . getDescription ( ) ) ; tmp . append ( "\n" ) ; } if ( req . length ( ) > 0 ) doc . append ( "\nRequired:\n" ) . append ( req ) ; if ( opt . length ( ) > 0 ) doc . append ( "\nOptional:\n" ) . append ( opt ) ; pe . setAdditional ( KeyImpl . init ( "Documentation" ) , doc ) ; } | add detailed function documentation to the exception |
23,034 | public long stop ( ) { if ( isRunning ) { long time = _time ( ) - start ; total += time ; count ++ ; isRunning = false ; return time ; } return 0 ; } | stops the watch |
23,035 | public void addArg ( FunctionLibFunctionArg arg ) { arg . setFunction ( this ) ; argument . add ( arg ) ; if ( arg . getDefaultValue ( ) != null ) hasDefaultValues = true ; } | Fuegt der Funktion ein Argument hinzu . |
23,036 | public void setFunctionClass ( String value , Identification id , Attributes attrs ) { functionCD = ClassDefinitionImpl . toClassDefinition ( value , id , attrs ) ; } | Setzt die Klassendefinition als Zeichenkette welche diese Funktion implementiert . |
23,037 | public static Text toText ( Document doc , Object o ) throws PageException { if ( o instanceof Text ) return ( Text ) o ; else if ( o instanceof CharacterData ) return doc . createTextNode ( ( ( CharacterData ) o ) . getData ( ) ) ; return doc . createTextNode ( Caster . toString ( o ) ) ; } | casts a value to a XML Text |
23,038 | public static Text [ ] toTextArray ( Document doc , Object o ) throws PageException { if ( o instanceof Node [ ] ) { Node [ ] nodes = ( Node [ ] ) o ; if ( _isAllOfSameType ( nodes , Node . TEXT_NODE ) ) return ( Text [ ] ) nodes ; Text [ ] textes = new Text [ nodes . length ] ; for ( int i = 0 ; i < nodes . length ; i ++ ) { textes [ i ] = toText ( doc , nodes [ i ] ) ; } return textes ; } else if ( o instanceof Collection ) { Collection coll = ( Collection ) o ; Iterator < Object > it = coll . valueIterator ( ) ; List < Text > textes = new ArrayList < Text > ( ) ; while ( it . hasNext ( ) ) { textes . add ( toText ( doc , it . next ( ) ) ) ; } return textes . toArray ( new Text [ textes . size ( ) ] ) ; } Node [ ] nodes = _toNodeArray ( doc , o ) ; if ( nodes != null ) return toTextArray ( doc , nodes ) ; try { return new Text [ ] { toText ( doc , o ) } ; } catch ( ExpressionException e ) { throw new XMLException ( "can't cast Object of type " + Caster . toClassName ( o ) + " to a XML Text Array" ) ; } } | casts a value to a XML Text Array |
23,039 | public static Attr toAttr ( Document doc , Object o ) throws PageException { if ( o instanceof Attr ) return ( Attr ) o ; if ( o instanceof Struct && ( ( Struct ) o ) . size ( ) == 1 ) { Struct sct = ( Struct ) o ; Entry < Key , Object > e = sct . entryIterator ( ) . next ( ) ; Attr attr = doc . createAttribute ( e . getKey ( ) . getString ( ) ) ; attr . setValue ( Caster . toString ( e . getValue ( ) ) ) ; return attr ; } throw new XMLException ( "can't cast Object of type " + Caster . toClassName ( o ) + " to a XML Attribute" ) ; } | casts a value to a XML Attribute Object |
23,040 | public static Attr [ ] toAttrArray ( Document doc , Object o ) throws PageException { if ( o instanceof Node [ ] ) { Node [ ] nodes = ( Node [ ] ) o ; if ( _isAllOfSameType ( nodes , Node . ATTRIBUTE_NODE ) ) return ( Attr [ ] ) nodes ; Attr [ ] attres = new Attr [ nodes . length ] ; for ( int i = 0 ; i < nodes . length ; i ++ ) { attres [ i ] = toAttr ( doc , nodes [ i ] ) ; } return attres ; } else if ( o instanceof Collection ) { Collection coll = ( Collection ) o ; Iterator < Entry < Key , Object > > it = coll . entryIterator ( ) ; Entry < Key , Object > e ; List < Attr > attres = new ArrayList < Attr > ( ) ; Attr attr ; Collection . Key k ; while ( it . hasNext ( ) ) { e = it . next ( ) ; k = e . getKey ( ) ; attr = doc . createAttribute ( Decision . isNumber ( k . getString ( ) ) ? "attribute-" + k . getString ( ) : k . getString ( ) ) ; attr . setValue ( Caster . toString ( e . getValue ( ) ) ) ; attres . add ( attr ) ; } return attres . toArray ( new Attr [ attres . size ( ) ] ) ; } Node [ ] nodes = _toNodeArray ( doc , o ) ; if ( nodes != null ) return toAttrArray ( doc , nodes ) ; try { return new Attr [ ] { toAttr ( doc , o ) } ; } catch ( ExpressionException e ) { throw new XMLException ( "can't cast Object of type " + Caster . toClassName ( o ) + " to a XML Attributes Array" ) ; } } | casts a value to a XML Attr Array |
23,041 | public static Comment toComment ( Document doc , Object o ) throws PageException { if ( o instanceof Comment ) return ( Comment ) o ; else if ( o instanceof CharacterData ) return doc . createComment ( ( ( CharacterData ) o ) . getData ( ) ) ; return doc . createComment ( Caster . toString ( o ) ) ; } | casts a value to a XML Comment Object |
23,042 | public static Comment [ ] toCommentArray ( Document doc , Object o ) throws PageException { if ( o instanceof Node [ ] ) { Node [ ] nodes = ( Node [ ] ) o ; if ( _isAllOfSameType ( nodes , Node . COMMENT_NODE ) ) return ( Comment [ ] ) nodes ; Comment [ ] comments = new Comment [ nodes . length ] ; for ( int i = 0 ; i < nodes . length ; i ++ ) { comments [ i ] = toComment ( doc , nodes [ i ] ) ; } return comments ; } else if ( o instanceof Collection ) { Collection coll = ( Collection ) o ; Iterator < Object > it = coll . valueIterator ( ) ; List < Comment > comments = new ArrayList < Comment > ( ) ; while ( it . hasNext ( ) ) { comments . add ( toComment ( doc , it . next ( ) ) ) ; } return comments . toArray ( new Comment [ comments . size ( ) ] ) ; } Node [ ] nodes = _toNodeArray ( doc , o ) ; if ( nodes != null ) return toCommentArray ( doc , nodes ) ; try { return new Comment [ ] { toComment ( doc , o ) } ; } catch ( ExpressionException e ) { throw new XMLException ( "can't cast Object of type " + Caster . toClassName ( o ) + " to a XML Comment Array" ) ; } } | casts a value to a XML Comment Array |
23,043 | public static Element toElement ( Document doc , Object o ) throws PageException { if ( o instanceof Element ) return ( Element ) o ; else if ( o instanceof Node ) throw new ExpressionException ( "Object " + Caster . toClassName ( o ) + " must be a XML Element" ) ; return doc . createElement ( Caster . toString ( o ) ) ; } | casts a value to a XML Element |
23,044 | public static Node toNode ( Object o ) throws PageException { if ( o instanceof XMLStruct ) return ( ( XMLStruct ) o ) . toNode ( ) ; if ( o instanceof Node ) return ( Node ) o ; throw new CasterException ( o , "node" ) ; } | casts a value to a XML Node |
23,045 | public static Node toNode ( Document doc , Object o , short type ) throws PageException { if ( Node . TEXT_NODE == type ) toText ( doc , o ) ; else if ( Node . ATTRIBUTE_NODE == type ) toAttr ( doc , o ) ; else if ( Node . COMMENT_NODE == type ) toComment ( doc , o ) ; else if ( Node . ELEMENT_NODE == type ) toElement ( doc , o ) ; throw new ExpressionException ( "invalid node type definition" ) ; } | casts a value to a XML Object defined by type parameter |
23,046 | public static Node [ ] toNodeArray ( Document doc , Object o , short type ) throws PageException { if ( Node . TEXT_NODE == type ) toTextArray ( doc , o ) ; else if ( Node . ATTRIBUTE_NODE == type ) toAttrArray ( doc , o ) ; else if ( Node . COMMENT_NODE == type ) toCommentArray ( doc , o ) ; else if ( Node . ELEMENT_NODE == type ) toElementArray ( doc , o ) ; throw new ExpressionException ( "invalid node type definition" ) ; } | casts a value to a XML Object Array defined by type parameter |
23,047 | public static void writeTo ( Node node , Resource file ) throws PageException { OutputStream os = null ; try { os = IOUtil . toBufferedOutputStream ( file . getOutputStream ( ) ) ; writeTo ( node , new StreamResult ( os ) , false , false , null , null , null ) ; } catch ( IOException ioe ) { throw Caster . toPageException ( ioe ) ; } finally { IOUtil . closeEL ( os ) ; } } | write a xml Dom to a file |
23,048 | private static Node [ ] _toNodeArray ( Document doc , Object o ) { if ( o instanceof Node ) return new Node [ ] { ( Node ) o } ; if ( o instanceof Node [ ] ) return ( ( Node [ ] ) o ) ; else if ( o instanceof NamedNodeMap ) { NamedNodeMap map = ( NamedNodeMap ) o ; int len = map . getLength ( ) ; Node [ ] nodes = new Node [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { nodes [ i ] = map . item ( i ) ; } return nodes ; } else if ( o instanceof XMLAttributes ) { return _toNodeArray ( doc , ( ( XMLAttributes ) o ) . toNamedNodeMap ( ) ) ; } else if ( o instanceof NodeList ) { NodeList list = ( NodeList ) o ; int len = list . getLength ( ) ; Node [ ] nodes = new Node [ len ] ; for ( int i = 0 ; i < nodes . length ; i ++ ) { nodes [ i ] = list . item ( i ) ; } return nodes ; } return null ; } | casts a value to a XML named Node Map |
23,049 | private static boolean _isAllOfSameType ( Node [ ] nodes , short type ) { for ( int i = 0 ; i < nodes . length ; i ++ ) { if ( nodes [ i ] . getNodeType ( ) != type ) return false ; } return true ; } | Check if all Node are of the type defnined by para meter |
23,050 | public void setRequired ( String value ) { value = value . toLowerCase ( ) . trim ( ) ; required = ( value . equals ( "yes" ) || value . equals ( "true" ) ) ; } | Setzt ob das Argument Pflicht ist oder nicht . |
23,051 | public static Object invoke ( String name , Object [ ] args ) throws PageException { return invoke ( null , name , args ) ; } | used by genertaed bytecode |
23,052 | public static Blob toBlob ( Connection conn , Object value ) throws PageException , SQLException { if ( value instanceof Blob ) return ( Blob ) value ; if ( SystemUtil . JAVA_VERSION >= SystemUtil . JAVA_VERSION_6 ) { try { Blob blob = conn . createBlob ( ) ; blob . setBytes ( 1 , Caster . toBinary ( value ) ) ; return blob ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; return BlobImpl . toBlob ( value ) ; } } if ( isOracle ( conn ) ) { Blob blob = OracleBlob . createBlob ( conn , Caster . toBinary ( value ) , null ) ; if ( blob != null ) return blob ; } return BlobImpl . toBlob ( value ) ; } | create a blog Object |
23,053 | public static Clob toClob ( Connection conn , Object value ) throws PageException , SQLException { if ( value instanceof Clob ) return ( Clob ) value ; if ( SystemUtil . JAVA_VERSION >= SystemUtil . JAVA_VERSION_6 ) { Clob clob = conn . createClob ( ) ; clob . setString ( 1 , Caster . toString ( value ) ) ; return clob ; } if ( isOracle ( conn ) ) { Clob clob = OracleClob . createClob ( conn , Caster . toString ( value ) , null ) ; if ( clob != null ) return clob ; } return ClobImpl . toClob ( value ) ; } | create a clob Object |
23,054 | public DateTime toDateTime ( double days ) { long utc = Math . round ( days * DAY_MILLIS ) ; utc -= CF_UNIX_OFFSET ; utc -= getLocalTimeZoneOffset ( utc ) ; return new DateTimeImpl ( utc , false ) ; } | returns a date time instance by a number the conversion from the double to date is o the base of the CFML rules . |
23,055 | public static String toHTTPTimeString ( Date date , boolean oldFormat ) { if ( oldFormat ) { synchronized ( HTTP_TIME_STRING_FORMAT_OLD ) { return StringUtil . replace ( HTTP_TIME_STRING_FORMAT_OLD . format ( date ) , "+00:00" , "" , true ) ; } } synchronized ( HTTP_TIME_STRING_FORMAT ) { return StringUtil . replace ( HTTP_TIME_STRING_FORMAT . format ( date ) , "+00:00" , "" , true ) ; } } | converts a date to a http time String |
23,056 | public static URL [ ] doURLs ( Resource [ ] reses ) throws IOException { List < URL > list = new ArrayList < URL > ( ) ; for ( int i = 0 ; i < reses . length ; i ++ ) { if ( reses [ i ] . isDirectory ( ) || "jar" . equalsIgnoreCase ( ResourceUtil . getExtension ( reses [ i ] , null ) ) ) list . add ( doURL ( reses [ i ] ) ) ; } return list . toArray ( new URL [ list . size ( ) ] ) ; } | translate resources to url Objects |
23,057 | private ScheduleTaskImpl [ ] readInAllTasks ( ) throws PageException { Element root = doc . getDocumentElement ( ) ; NodeList children = root . getChildNodes ( ) ; ArrayList < ScheduleTaskImpl > list = new ArrayList < ScheduleTaskImpl > ( ) ; int len = children . getLength ( ) ; for ( int i = 0 ; i < len ; i ++ ) { Node n = children . item ( i ) ; if ( n instanceof Element && n . getNodeName ( ) . equals ( "task" ) ) { list . add ( readInTask ( ( Element ) n ) ) ; } } return list . toArray ( new ScheduleTaskImpl [ list . size ( ) ] ) ; } | read in all schedule tasks |
23,058 | private ScheduleTaskImpl readInTask ( Element el ) throws PageException { long timeout = su . toLong ( el , "timeout" ) ; if ( timeout > 0 && timeout < 1000 ) timeout *= 1000 ; if ( timeout < 0 ) timeout = 600000 ; try { ScheduleTaskImpl st = new ScheduleTaskImpl ( this , su . toString ( el , "name" ) . trim ( ) , su . toResource ( config , el , "file" ) , su . toDate ( config , el , "startDate" ) , su . toTime ( config , el , "startTime" ) , su . toDate ( config , el , "endDate" ) , su . toTime ( config , el , "endTime" ) , su . toString ( el , "url" ) , su . toInt ( el , "port" , - 1 ) , su . toString ( el , "interval" ) , timeout , su . toCredentials ( el , "username" , "password" ) , ProxyDataImpl . getInstance ( su . toString ( el , "proxyHost" ) , su . toInt ( el , "proxyPort" , 80 ) , su . toString ( el , "proxyUser" ) , su . toString ( el , "proxyPassword" ) ) , su . toBoolean ( el , "resolveUrl" ) , su . toBoolean ( el , "publish" ) , su . toBoolean ( el , "hidden" , false ) , su . toBoolean ( el , "readonly" , false ) , su . toBoolean ( el , "paused" , false ) , su . toBoolean ( el , "autoDelete" , false ) ) ; return st ; } catch ( Exception e ) { SystemOut . printDate ( e ) ; throw Caster . toPageException ( e ) ; } } | read in a single task element |
23,059 | private void setAttributes ( Element el , ScheduleTask task ) { if ( el == null ) return ; NamedNodeMap atts = el . getAttributes ( ) ; for ( int i = atts . getLength ( ) - 1 ; i >= 0 ; i -- ) { Attr att = ( Attr ) atts . item ( i ) ; el . removeAttribute ( att . getName ( ) ) ; } su . setString ( el , "name" , task . getTask ( ) ) ; su . setFile ( el , "file" , task . getResource ( ) ) ; su . setDateTime ( el , "startDate" , task . getStartDate ( ) ) ; su . setDateTime ( el , "startTime" , task . getStartTime ( ) ) ; su . setDateTime ( el , "endDate" , task . getEndDate ( ) ) ; su . setDateTime ( el , "endTime" , task . getEndTime ( ) ) ; su . setString ( el , "url" , task . getUrl ( ) . toExternalForm ( ) ) ; su . setInt ( el , "port" , task . getUrl ( ) . getPort ( ) ) ; su . setString ( el , "interval" , task . getIntervalAsString ( ) ) ; su . setInt ( el , "timeout" , ( int ) task . getTimeout ( ) ) ; su . setCredentials ( el , "username" , "password" , task . getCredentials ( ) ) ; ProxyData pd = task . getProxyData ( ) ; su . setString ( el , "proxyHost" , StringUtil . emptyIfNull ( pd == null ? "" : pd . getServer ( ) ) ) ; su . setString ( el , "proxyUser" , StringUtil . emptyIfNull ( pd == null ? "" : pd . getUsername ( ) ) ) ; su . setString ( el , "proxyPassword" , StringUtil . emptyIfNull ( pd == null ? "" : pd . getPassword ( ) ) ) ; su . setInt ( el , "proxyPort" , pd == null ? 0 : pd . getPort ( ) ) ; su . setBoolean ( el , "resolveUrl" , task . isResolveURL ( ) ) ; su . setBoolean ( el , "publish" , task . isPublish ( ) ) ; su . setBoolean ( el , "hidden" , ( ( ScheduleTaskImpl ) task ) . isHidden ( ) ) ; su . setBoolean ( el , "readonly" , ( ( ScheduleTaskImpl ) task ) . isReadonly ( ) ) ; su . setBoolean ( el , "autoDelete" , ( ( ScheduleTaskImpl ) task ) . isAutoDelete ( ) ) ; } | sets all attributes in XML Element from Schedule Task |
23,060 | private Element toElement ( ScheduleTask task ) { Element el = doc . createElement ( "task" ) ; setAttributes ( el , task ) ; return el ; } | translate a schedule task object to a XML Element |
23,061 | public void rollOver ( ) { Resource target ; Resource file ; if ( qw != null ) { long size = ( ( CountingQuietWriter ) qw ) . getCount ( ) ; LogLog . debug ( "rolling over count=" + size ) ; nextRollover = size + maxFileSize ; } LogLog . debug ( "maxBackupIndex=" + maxBackupIndex ) ; boolean renameSucceeded = true ; Resource parent = res . getParentResource ( ) ; if ( maxBackupIndex > 0 ) { file = parent . getRealResource ( res . getName ( ) + "." + maxBackupIndex + ".bak" ) ; if ( file . exists ( ) ) renameSucceeded = file . delete ( ) ; for ( int i = maxBackupIndex - 1 ; i >= 1 && renameSucceeded ; i -- ) { file = parent . getRealResource ( res . getName ( ) + "." + i + ".bak" ) ; if ( file . exists ( ) ) { target = parent . getRealResource ( res . getName ( ) + "." + ( i + 1 ) + ".bak" ) ; LogLog . debug ( "Renaming file " + file + " to " + target ) ; renameSucceeded = file . renameTo ( target ) ; } } if ( renameSucceeded ) { target = parent . getRealResource ( res . getName ( ) + ".1.bak" ) ; this . closeFile ( ) ; file = res ; LogLog . debug ( "Renaming file " + file + " to " + target ) ; renameSucceeded = file . renameTo ( target ) ; if ( ! renameSucceeded ) { try { this . setFile ( true ) ; } catch ( IOException e ) { LogLog . error ( "setFile(" + res + ", true) call failed." , e ) ; } } } } if ( renameSucceeded ) { try { this . setFile ( false ) ; nextRollover = 0 ; } catch ( IOException e ) { LogLog . error ( "setFile(" + res + ", false) call failed." , e ) ; } } } | Implements the usual roll over behavior . |
23,062 | protected void subAppend ( LoggingEvent event ) { super . subAppend ( event ) ; if ( res != null && qw != null ) { long size = ( ( CountingQuietWriter ) qw ) . getCount ( ) ; if ( size >= maxFileSize && size >= nextRollover ) { rollOver ( ) ; } } } | This method differentiates RollingFileAppender from its super class . |
23,063 | public ErrorPage getErrorPage ( PageException pe , short type ) { for ( int i = pages . size ( ) - 1 ; i >= 0 ; i -- ) { ErrorPageImpl ep = ( ErrorPageImpl ) pages . get ( i ) ; if ( ep . getType ( ) == type ) { if ( type == ErrorPage . TYPE_EXCEPTION ) { if ( pe . typeEqual ( ep . getTypeAsString ( ) ) ) return ep ; } else return ep ; } } return null ; } | returns the error page |
23,064 | public void removeErrorPage ( PageException pe ) { ErrorPage ep = getErrorPage ( pe , ErrorPage . TYPE_EXCEPTION ) ; if ( ep != null ) { pages . remove ( ep ) ; hasChanged = true ; } ep = getErrorPage ( pe , ErrorPage . TYPE_REQUEST ) ; if ( ep != null ) { pages . remove ( ep ) ; hasChanged = true ; } ep = getErrorPage ( pe , ErrorPage . TYPE_VALIDATION ) ; if ( ep != null ) { pages . remove ( ep ) ; hasChanged = true ; } } | remove this error page |
23,065 | public static String escapeHTML ( String str , short version ) { String [ ] [ ] data ; int [ ] offset ; StringBuilder rtn = new StringBuilder ( str . length ( ) ) ; char [ ] chars = str . toCharArray ( ) ; if ( version == HTMLV20 ) { data = HTML20_DATA ; offset = HTML20_OFFSET ; } else if ( version == HTMLV32 ) { data = HTML32_DATA ; offset = HTML32_OFFSET ; } else { data = HTML40_DATA ; offset = HTML40_OFFSET ; } outer : for ( int i = 0 ; i < chars . length ; i ++ ) { char c = chars [ i ] ; if ( c == CR ) continue ; for ( int y = 0 ; y < offset . length ; y ++ ) { if ( c >= offset [ y ] && c < data [ y ] . length + offset [ y ] ) { String replacement = data [ y ] [ c - offset [ y ] ] ; if ( replacement != null ) { rtn . append ( '&' ) ; rtn . append ( replacement ) ; rtn . append ( ';' ) ; continue outer ; } } } rtn . append ( c ) ; } return rtn . toString ( ) ; } | escapes html character inside a string |
23,066 | public static String unescapeHTML ( String str ) { StringBuilder rtn = new StringBuilder ( ) ; int posStart = - 1 ; int posFinish = - 1 ; while ( ( posStart = str . indexOf ( '&' , posStart ) ) != - 1 ) { int last = posFinish + 1 ; posFinish = str . indexOf ( ';' , posStart ) ; if ( posFinish == - 1 ) break ; rtn . append ( str . substring ( last , posStart ) ) ; if ( posStart + 1 < posFinish ) { rtn . append ( unescapeHTMLEntity ( str . substring ( posStart + 1 , posFinish ) ) ) ; } else { rtn . append ( "&;" ) ; } posStart = posFinish + 1 ; } rtn . append ( str . substring ( posFinish + 1 ) ) ; return rtn . toString ( ) ; } | unescapes html character inside a string |
23,067 | public static Class [ ] getClasses ( Object [ ] objs ) { Class [ ] cls = new Class [ objs . length ] ; for ( int i = 0 ; i < objs . length ; i ++ ) { if ( objs [ i ] == null ) cls [ i ] = Object . class ; else cls [ i ] = objs [ i ] . getClass ( ) ; } return cls ; } | get all Classes from a Object Array |
23,068 | public static String getDspMethods ( Class ... clazzArgs ) { StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < clazzArgs . length ; i ++ ) { if ( i > 0 ) sb . append ( ", " ) ; sb . append ( Caster . toTypeName ( clazzArgs [ i ] ) ) ; } return sb . toString ( ) ; } | creates a string list with class arguments in a displable form |
23,069 | public static boolean like ( Class src , Class trg ) { if ( src == trg ) return true ; return isInstaneOf ( src , trg ) ; } | checks if src Class is like trg class |
23,070 | public static Object convert ( Object src , Class trgClass , RefInteger rating ) throws PageException { if ( rating != null ) { Object trg = _convert ( src , trgClass ) ; if ( src == trg ) { rating . plus ( 10 ) ; return trg ; } if ( src == null || trg == null ) { rating . plus ( 0 ) ; return trg ; } if ( isInstaneOf ( src . getClass ( ) , trg . getClass ( ) ) ) { rating . plus ( 9 ) ; return trg ; } if ( src . equals ( trg ) ) { rating . plus ( 8 ) ; return trg ; } boolean bothNumbers = src instanceof Number && trg instanceof Number ; if ( bothNumbers && ( ( Number ) src ) . doubleValue ( ) == ( ( Number ) trg ) . doubleValue ( ) ) { rating . plus ( 7 ) ; return trg ; } String sSrc = Caster . toString ( src , null ) ; String sTrg = Caster . toString ( trg , null ) ; if ( sSrc != null && sTrg != null ) { if ( src instanceof Number && trg instanceof Number && sSrc . equals ( sTrg ) ) { rating . plus ( 6 ) ; return trg ; } if ( sSrc . equals ( sTrg ) ) { rating . plus ( 5 ) ; return trg ; } if ( sSrc . equalsIgnoreCase ( sTrg ) ) { rating . plus ( 4 ) ; return trg ; } } try { if ( Operator . equals ( src , trg , false , true ) ) { rating . plus ( 3 ) ; return trg ; } } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; } return trg ; } return _convert ( src , trgClass ) ; } | convert Object from src to trg Type if possible |
23,071 | public static ConstructorInstance getConstructorInstance ( Class clazz , Object [ ] args ) throws NoSuchMethodException { ConstructorInstance ci = getConstructorInstance ( clazz , args , null ) ; if ( ci != null ) return ci ; throw new NoSuchMethodException ( "No matching Constructor for " + clazz . getName ( ) + "(" + getDspMethods ( getClasses ( args ) ) + ") found" ) ; } | gets Constructor Instance matching given parameter |
23,072 | public static Object callConstructor ( Class clazz , Object [ ] args ) throws PageException { args = cleanArgs ( args ) ; try { return getConstructorInstance ( clazz , args ) . invoke ( ) ; } catch ( InvocationTargetException e ) { Throwable target = e . getTargetException ( ) ; if ( target instanceof PageException ) throw ( PageException ) target ; throw Caster . toPageException ( e . getTargetException ( ) ) ; } catch ( Exception e ) { throw Caster . toPageException ( e ) ; } } | call constructor of a class with matching arguments |
23,073 | public static Object callMethod ( Object obj , String methodName , Object [ ] args ) throws PageException { return callMethod ( obj , KeyImpl . getInstance ( methodName ) , args ) ; } | calls a Method of a Objct |
23,074 | public static Object callStaticMethod ( Class clazz , String methodName , Object [ ] args ) throws PageException { try { return getMethodInstance ( null , clazz , methodName , args ) . invoke ( null ) ; } catch ( InvocationTargetException e ) { Throwable target = e . getTargetException ( ) ; if ( target instanceof PageException ) throw ( PageException ) target ; throw Caster . toPageException ( e . getTargetException ( ) ) ; } catch ( Exception e ) { throw Caster . toPageException ( e ) ; } } | calls a Static Method on the given CLass |
23,075 | public static void callSetterEL ( Object obj , String prop , Object value ) throws PageException { try { MethodInstance setter = getSetter ( obj , prop , value , null ) ; if ( setter != null ) setter . invoke ( obj ) ; } catch ( InvocationTargetException e ) { Throwable target = e . getTargetException ( ) ; if ( target instanceof PageException ) throw ( PageException ) target ; throw Caster . toPageException ( e . getTargetException ( ) ) ; } catch ( Exception e ) { throw Caster . toPageException ( e ) ; } } | do nothing when not exist |
23,076 | public static Object getField ( Object obj , String prop ) throws PageException { try { return getFieldsIgnoreCase ( obj . getClass ( ) , prop ) [ 0 ] . get ( obj ) ; } catch ( Throwable e ) { ExceptionUtil . rethrowIfNecessary ( e ) ; throw Caster . toPageException ( e ) ; } } | to get a visible Field of a object |
23,077 | public static boolean setField ( Object obj , String prop , Object value ) throws PageException { Class clazz = value . getClass ( ) ; try { Field [ ] fields = getFieldsIgnoreCase ( obj . getClass ( ) , prop ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { if ( toReferenceClass ( fields [ i ] . getType ( ) ) == clazz ) { fields [ i ] . set ( obj , value ) ; return true ; } } for ( int i = 0 ; i < fields . length ; i ++ ) { if ( like ( fields [ i ] . getType ( ) , clazz ) ) { fields [ i ] . set ( obj , value ) ; return true ; } } for ( int i = 0 ; i < fields . length ; i ++ ) { try { fields [ i ] . set ( obj , convert ( value , toReferenceClass ( fields [ i ] . getType ( ) ) , null ) ) ; return true ; } catch ( PageException e ) { } } } catch ( Exception e ) { throw Caster . toPageException ( e ) ; } return false ; } | assign a value to a visible Field of a object |
23,078 | public static boolean canConvert ( Class from , Class to ) { if ( from == to ) return true ; if ( from == byte . class ) { return to == short . class || to == int . class || to == long . class || to == float . class || to == double . class ; } if ( from == short . class ) { return to == int . class || to == long . class || to == float . class || to == double . class ; } if ( from == char . class ) { return to == int . class || to == long . class || to == float . class || to == double . class ; } if ( from == int . class ) { return to == long . class || to == float . class || to == double . class ; } if ( from == long . class ) { return to == float . class || to == double . class ; } if ( from == float . class ) { return to == double . class ; } return false ; } | check if given class from can be converted to class to without explicit casting |
23,079 | public CatchBlock getCatchBlock ( Config config ) { String strSQL = sql == null ? "" : sql . toString ( ) ; if ( StringUtil . isEmpty ( strSQL ) ) strSQL = Caster . toString ( getAdditional ( ) . get ( "SQL" , "" ) , "" ) ; String datasourceName = datasource == null ? "" : datasource . getName ( ) ; if ( StringUtil . isEmpty ( datasourceName ) ) datasourceName = Caster . toString ( getAdditional ( ) . get ( "DataSource" , "" ) , "" ) ; CatchBlock sct = super . getCatchBlock ( config ) ; sct . setEL ( "NativeErrorCode" , new Double ( errorcode ) ) ; sct . setEL ( "DataSource" , datasourceName ) ; sct . setEL ( "SQLState" , sqlstate ) ; sct . setEL ( "Sql" , strSQL ) ; sct . setEL ( "queryError" , strSQL ) ; sct . setEL ( "where" , "" ) ; return sct ; } | Constructor of the class |
23,080 | public void start ( Resource xmlFile ) throws PageException { InputStream is = null ; try { XMLReader xmlReader = XMLUtil . createXMLReader ( ) ; xmlReader . setContentHandler ( this ) ; xmlReader . setErrorHandler ( this ) ; xmlReader . parse ( new InputSource ( is = IOUtil . toBufferedInputStream ( xmlFile . getInputStream ( ) ) ) ) ; } catch ( Exception e ) { throw Caster . toPageException ( e ) ; } finally { IOUtil . closeEL ( is ) ; } } | start execution of the parser |
23,081 | private void call ( UDF udf , Object [ ] arguments ) { try { udf . call ( pc , arguments , false ) ; } catch ( PageException pe ) { error ( pe ) ; } } | call a user defined function |
23,082 | private void error ( PageException pe ) { if ( error == null ) throw new PageRuntimeException ( pe ) ; try { pc = ThreadLocalPageContext . get ( pc ) ; error . call ( pc , new Object [ ] { pe . getCatchBlock ( pc . getConfig ( ) ) } , false ) ; } catch ( PageException e ) { } } | call back error function if a error occour |
23,083 | private Struct toStruct ( Attributes att ) { int len = att . getLength ( ) ; Struct sct = new StructImpl ( ) ; for ( int i = 0 ; i < len ; i ++ ) { sct . setEL ( att . getQName ( i ) , att . getValue ( i ) ) ; } return sct ; } | cast a Attributes object to a Struct |
23,084 | public static Pair < String , String > [ ] cloneHeaders ( HttpServletRequest req ) { List < Pair < String , String > > headers = new ArrayList < Pair < String , String > > ( ) ; Enumeration < String > e = req . getHeaderNames ( ) , ee ; String name ; while ( e . hasMoreElements ( ) ) { name = e . nextElement ( ) ; ee = req . getHeaders ( name ) ; while ( ee . hasMoreElements ( ) ) { headers . add ( new Pair < String , String > ( name , ee . nextElement ( ) . toString ( ) ) ) ; } } return ( Pair < String , String > [ ] ) headers . toArray ( new Pair [ headers . size ( ) ] ) ; } | read all headers from request and return it |
23,085 | private static void loadExtensionBundles ( ConfigServerImpl cs , ConfigImpl config , Document doc , Log log ) { try { Element parent = getChildByName ( doc . getDocumentElement ( ) , "extensions" ) ; Element [ ] children = getChildren ( parent , "rhextension" ) ; String strBundles ; List < RHExtension > extensions = new ArrayList < RHExtension > ( ) ; RHExtension rhe ; for ( Element child : children ) { BundleInfo [ ] bfsq ; try { rhe = new RHExtension ( config , child ) ; if ( rhe . getStartBundles ( ) ) rhe . deployBundles ( config ) ; extensions . add ( rhe ) ; } catch ( Exception e ) { log . error ( "load-extension" , e ) ; continue ; } } config . setExtensions ( extensions . toArray ( new RHExtension [ extensions . size ( ) ] ) ) ; } catch ( Exception e ) { log ( config , log , e ) ; } } | loads the bundles defined in the extensions |
23,086 | private static boolean toBoolean ( String value , boolean defaultValue ) { if ( value == null || value . trim ( ) . length ( ) == 0 ) return defaultValue ; try { return Caster . toBooleanValue ( value . trim ( ) ) ; } catch ( PageException e ) { return defaultValue ; } } | cast a string value to a boolean |
23,087 | public static String getAttr ( Element el , String name ) { String v = el . getAttribute ( name ) ; return replaceConfigPlaceHolder ( v ) ; } | reads an attribute from a xml Element and parses placeholders |
23,088 | public void setAction ( String strAction ) throws ApplicationException { strAction = strAction . toLowerCase ( ) ; if ( strAction . equals ( "move" ) || strAction . equals ( "rename" ) ) action = ACTION_MOVE ; else if ( strAction . equals ( "copy" ) ) action = ACTION_COPY ; else if ( strAction . equals ( "delete" ) ) action = ACTION_DELETE ; else if ( strAction . equals ( "read" ) ) action = ACTION_READ ; else if ( strAction . equals ( "readbinary" ) ) action = ACTION_READ_BINARY ; else if ( strAction . equals ( "write" ) ) action = ACTION_WRITE ; else if ( strAction . equals ( "append" ) ) action = ACTION_APPEND ; else if ( strAction . equals ( "upload" ) ) action = ACTION_UPLOAD ; else if ( strAction . equals ( "uploadall" ) ) action = ACTION_UPLOAD_ALL ; else if ( strAction . equals ( "info" ) ) action = ACTION_INFO ; else if ( strAction . equals ( "touch" ) ) action = ACTION_TOUCH ; else throw new ApplicationException ( "invalid value [" + strAction + "] for attribute action" , "values for attribute action are:info,move,rename,copy,delete,read,readbinary,write,append,upload,uploadall,touch" ) ; } | set the value action Type of file manipulation that the tag performs . |
23,089 | public void setCharset ( String charset ) { if ( StringUtil . isEmpty ( charset ) ) return ; this . charset = CharsetUtil . toCharSet ( charset . trim ( ) ) ; } | set the value charset Character set name for the file contents . |
23,090 | public static void actionMove ( PageContext pageContext , lucee . runtime . security . SecurityManager securityManager , Resource source , String strDestination , int nameconflict , String serverPassword , Object acl , int mode , String attributes ) throws PageException { if ( nameconflict == NAMECONFLICT_UNDEFINED ) nameconflict = NAMECONFLICT_OVERWRITE ; if ( source == null ) throw new ApplicationException ( "attribute source is not defined for tag file" ) ; if ( StringUtil . isEmpty ( strDestination ) ) throw new ApplicationException ( "attribute destination is not defined for tag file" ) ; Resource destination = toDestination ( pageContext , strDestination , source ) ; securityManager . checkFileLocation ( pageContext . getConfig ( ) , source , serverPassword ) ; securityManager . checkFileLocation ( pageContext . getConfig ( ) , destination , serverPassword ) ; if ( source . equals ( destination ) ) return ; if ( ! source . exists ( ) ) throw new ApplicationException ( "source file [" + source . toString ( ) + "] doesn't exist" ) ; else if ( ! source . isFile ( ) ) throw new ApplicationException ( "source file [" + source . toString ( ) + "] is not a file" ) ; else if ( ! source . isReadable ( ) || ! source . isWriteable ( ) ) throw new ApplicationException ( "no access to source file [" + source . toString ( ) + "]" ) ; if ( destination . isDirectory ( ) ) destination = destination . getRealResource ( source . getName ( ) ) ; if ( destination . exists ( ) ) { if ( nameconflict == NAMECONFLICT_SKIP ) return ; else if ( nameconflict == NAMECONFLICT_OVERWRITE ) destination . delete ( ) ; else if ( nameconflict == NAMECONFLICT_MAKEUNIQUE ) destination = makeUnique ( destination ) ; else throw new ApplicationException ( "destiniation file [" + destination . toString ( ) + "] already exist" ) ; } setACL ( pageContext , destination , acl ) ; try { source . moveTo ( destination ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; throw new ApplicationException ( t . getMessage ( ) ) ; } setMode ( destination , mode ) ; setAttributes ( destination , attributes ) ; } | move source file to destination path or file |
23,091 | private void actionAppend ( ) throws PageException { if ( output == null ) throw new ApplicationException ( "attribute output is not defined for tag file" ) ; checkFile ( pageContext , securityManager , file , serverPassword , createPath , true , false , true ) ; setACL ( pageContext , file , acl ) ; try { if ( ! file . exists ( ) ) file . createNewFile ( ) ; String content = Caster . toString ( output ) ; if ( fixnewline ) content = doFixNewLine ( content ) ; if ( addnewline ) content += SystemUtil . getOSSpecificLineSeparator ( ) ; IOUtil . write ( file , content , CharsetUtil . toCharset ( charset ) , true ) ; } catch ( UnsupportedEncodingException e ) { throw new ApplicationException ( "Unsupported Charset Definition [" + charset + "]" , e . getMessage ( ) ) ; } catch ( IOException e ) { throw new ApplicationException ( "can't write file" , e . getMessage ( ) ) ; } setMode ( file , mode ) ; setAttributes ( file , attributes ) ; } | append data to source file |
23,092 | private static void checkContentType ( String contentType , String accept , String ext , boolean strict ) throws PageException { if ( ! StringUtil . isEmpty ( ext , true ) ) { ext = ext . trim ( ) . toLowerCase ( ) ; if ( ext . startsWith ( "*." ) ) ext = ext . substring ( 2 ) ; if ( ext . startsWith ( "." ) ) ext = ext . substring ( 1 ) ; String blacklistedTypes = SystemUtil . getSystemPropOrEnvVar ( SystemUtil . SETTING_UPLOAD_EXT_BLACKLIST , SystemUtil . DEFAULT_UPLOAD_EXT_BLACKLIST ) . toLowerCase ( ) ; Array blacklist = ListUtil . listToArrayRemoveEmpty ( blacklistedTypes , ',' ) ; for ( int i = blacklist . size ( ) ; i > 0 ; i -- ) { if ( ext . equals ( Caster . toString ( blacklist . getE ( i ) ) . trim ( ) ) ) { throw new ApplicationException ( "Upload of files with extension [" + ext + "] is not permitted. " + "You can configure the " + SystemUtil . SETTING_UPLOAD_EXT_BLACKLIST + " System property or the " + SystemUtil . convertSystemPropToEnvVar ( SystemUtil . SETTING_UPLOAD_EXT_BLACKLIST ) + " Environment variable to allow that file type." ) ; } } } else ext = null ; if ( StringUtil . isEmpty ( accept , true ) ) return ; MimeType mt = MimeType . getInstance ( contentType ) , sub ; Array whishedTypes = ListUtil . listToArrayRemoveEmpty ( accept , ',' ) ; int len = whishedTypes . size ( ) ; for ( int i = 1 ; i <= len ; i ++ ) { String whishedType = Caster . toString ( whishedTypes . getE ( i ) ) . trim ( ) . toLowerCase ( ) ; if ( whishedType . equals ( "*" ) ) return ; if ( ListUtil . len ( whishedType , "/" , true ) == 2 ) { sub = MimeType . getInstance ( whishedType ) ; if ( mt . match ( sub ) ) return ; } if ( ext != null && ! strict ) { if ( whishedType . startsWith ( "*." ) ) whishedType = whishedType . substring ( 2 ) ; if ( whishedType . startsWith ( "." ) ) whishedType = whishedType . substring ( 1 ) ; if ( ext . equals ( whishedType ) ) return ; } } throw new ApplicationException ( "The MIME type of the uploaded file [" + contentType + "] was not accepted by the server." , "only this [" + accept + "] mime type are accepted" ) ; } | check if the content type is permitted |
23,093 | private static FormItem getFormItem ( PageContext pageContext , String filefield ) throws PageException { if ( StringUtil . isEmpty ( filefield ) ) { FormItem [ ] items = getFormItems ( pageContext ) ; if ( ArrayUtil . isEmpty ( items ) ) throw new ApplicationException ( "no file send with this form" ) ; return items [ 0 ] ; } PageException pe = pageContext . formScope ( ) . getInitException ( ) ; if ( pe != null ) throw pe ; lucee . runtime . type . scope . Form upload = pageContext . formScope ( ) ; FormItem fileItem = upload . getUploadResource ( filefield ) ; if ( fileItem == null ) { FormItem [ ] items = upload . getFileItems ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < items . length ; i ++ ) { if ( i != 0 ) sb . append ( ", " ) ; sb . append ( items [ i ] . getFieldName ( ) ) ; } String add = "." ; if ( sb . length ( ) > 0 ) add = ", valid field names are [" + sb + "]." ; if ( pageContext . formScope ( ) . get ( filefield , null ) == null ) throw new ApplicationException ( "form field [" + filefield + "] is not a file field" + add ) ; throw new ApplicationException ( "form field [" + filefield + "] doesn't exist or has no content" + add ) ; } return fileItem ; } | rreturn fileItem matching to filefiled definition or throw a exception |
23,094 | private static String getFileName ( Resource file ) { String name = file . getName ( ) ; int pos = name . lastIndexOf ( "." ) ; if ( pos == - 1 ) return name ; return name . substring ( 0 , pos ) ; } | get file name of a file object without extension |
23,095 | private static void setAttributes ( Resource file , String attributes ) throws PageException { if ( ! SystemUtil . isWindows ( ) || StringUtil . isEmpty ( attributes ) ) return ; try { ResourceUtil . setAttribute ( file , attributes ) ; } catch ( IOException e ) { throw new ApplicationException ( "can't change attributes of file " + file , e . getMessage ( ) ) ; } } | set attributes on file |
23,096 | private static void setMode ( Resource file , int mode ) throws ApplicationException { if ( mode == - 1 || SystemUtil . isWindows ( ) ) return ; try { file . setMode ( mode ) ; } catch ( IOException e ) { throw new ApplicationException ( "can't change mode of file " + file , e . getMessage ( ) ) ; } } | change mode of given file |
23,097 | private static Boolean methodExists ( Class clazz , String methodName , Type [ ] args , Type returnType ) { try { Class < ? > [ ] _args = new Class [ args . length ] ; for ( int i = 0 ; i < _args . length ; i ++ ) { _args [ i ] = Types . toClass ( args [ i ] ) ; } Class < ? > rtn = Types . toClass ( returnType ) ; try { java . lang . reflect . Method m = clazz . getMethod ( methodName , _args ) ; return m . getReturnType ( ) == rtn ; } catch ( Exception e ) { return false ; } } catch ( Exception e ) { SystemOut . printDate ( e ) ; return null ; } } | checks if a method exists |
23,098 | private static NamedArgument [ ] toNamedArguments ( Argument [ ] args ) { NamedArgument [ ] nargs = new NamedArgument [ args . length ] ; for ( int i = 0 ; i < args . length ; i ++ ) { nargs [ i ] = ( NamedArgument ) args [ i ] ; } return nargs ; } | translate a array of arguments to a araay of NamedArguments attention no check if the elements are really named arguments |
23,099 | private static boolean isNamed ( String funcName , Argument [ ] args ) throws TransformerException { if ( ArrayUtil . isEmpty ( args ) ) return false ; boolean named = false ; for ( int i = 0 ; i < args . length ; i ++ ) { if ( args [ i ] instanceof NamedArgument ) named = true ; else if ( named ) throw new TransformerException ( "invalid argument for function " + funcName + ", you can not mix named and unnamed arguments" , args [ i ] . getStart ( ) ) ; } return named ; } | check if the arguments are named arguments or regular arguments throws a exception when mixed |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.