idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
23,400 | public static char lastChar ( String str ) { if ( str == null || str . length ( ) == 0 ) return 0 ; return str . charAt ( str . length ( ) - 1 ) ; } | return the last character of a string if string ist empty return 0 ; |
23,401 | public static boolean isAllAlpha ( String str ) { if ( str == null ) return false ; for ( int i = str . length ( ) - 1 ; i >= 0 ; i -- ) { if ( ! Character . isLetter ( str . charAt ( i ) ) ) return false ; } return true ; } | returns true if all characters in the string are letters |
23,402 | public static boolean isAllUpperCase ( String str ) { if ( str == null ) return false ; boolean hasLetters = false ; char c ; for ( int i = str . length ( ) - 1 ; i >= 0 ; i -- ) { c = str . charAt ( i ) ; if ( Character . isLetter ( c ) ) { if ( ! Character . isUpperCase ( c ) ) return false ; hasLetters = true ; } } return hasLetters ; } | returns true if the input string has letters and they are all UPPERCASE |
23,403 | public static String substring ( String str , int off , int len ) { return str . substring ( off , off + len ) ; } | this method works different from the regular substring method the regular substring method takes startIndex and endIndex as second and third argument this method takes offset and length |
23,404 | public void setNameconflict ( String nameconflict ) throws PageException { nameconflict = nameconflict . toLowerCase ( ) . trim ( ) ; if ( "error" . equals ( nameconflict ) ) this . nameconflict = NAMECONFLICT_ERROR ; else if ( "skip" . equals ( nameconflict ) ) this . nameconflict = NAMECONFLICT_SKIP ; else if ( "overwrite" . equals ( nameconflict ) ) this . nameconflict = NAMECONFLICT_OVERWRITE ; else if ( "makeunique" . equals ( nameconflict ) ) this . nameconflict = NAMECONFLICT_MAKEUNIQUE ; else throw doThrow ( "invalid value for attribute nameconflict [" + nameconflict + "]" , "valid values are [error,skip,overwrite,makeunique]" ) ; } | set the value nameconflict Action to take if filename is the same as that of a file in the directory . |
23,405 | public Object touch ( int row ) throws PageException { Object o = query . getAt ( columnName , row , NullSupportHelper . NULL ( ) ) ; if ( o != NullSupportHelper . NULL ( ) ) return o ; return query . setAt ( columnName , row , new StructImpl ( ) ) ; } | touch a value means if key dosent exist it will created |
23,406 | public IPRangeNode findFast ( String addr ) { InetAddress iaddr ; try { iaddr = InetAddress . getByName ( addr ) ; } catch ( UnknownHostException ex ) { return null ; } return findFast ( iaddr ) ; } | performs a binary search over sorted list |
23,407 | public static ConstructorParameterPair getConstructorParameterPairIgnoreCase ( Class clazz , Object [ ] parameters ) throws NoSuchMethodException { if ( parameters == null ) parameters = new Object [ 0 ] ; Class [ ] parameterClasses = new Class [ parameters . length ] ; for ( int i = 0 ; i < parameters . length ; i ++ ) { parameterClasses [ i ] = parameters [ i ] . getClass ( ) ; } Constructor [ ] constructor = clazz . getConstructors ( ) ; for ( int mode = 0 ; mode < 2 ; mode ++ ) { outer : for ( int i = 0 ; i < constructor . length ; i ++ ) { Constructor c = constructor [ i ] ; Class [ ] paramTrg = c . getParameterTypes ( ) ; if ( parameterClasses . length == paramTrg . length ) { for ( int y = 0 ; y < parameterClasses . length ; y ++ ) { if ( mode == 0 && parameterClasses [ y ] != primitiveToWrapperType ( paramTrg [ y ] ) ) { continue outer ; } else if ( mode == 1 ) { Object o = compareClasses ( parameters [ y ] , paramTrg [ y ] ) ; if ( o == null ) continue outer ; parameters [ y ] = o ; parameterClasses [ y ] = o . getClass ( ) ; } } return new ConstructorParameterPair ( c , parameters ) ; } } } String parameter = "" ; for ( int i = 0 ; i < parameterClasses . length ; i ++ ) { if ( i != 0 ) parameter += ", " ; parameter += parameterClasses [ i ] . getName ( ) ; } throw new NoSuchMethodException ( "class constructor " + clazz . getName ( ) + "(" + parameter + ") doesn't exist" ) ; } | search the matching constructor to defined parameter list also translate parameters for matching |
23,408 | public static Object callMethod ( Object object , String methodName , Object [ ] parameters ) throws NoSuchMethodException , IllegalArgumentException , IllegalAccessException , InvocationTargetException { MethodParameterPair pair = getMethodParameterPairIgnoreCase ( object . getClass ( ) , methodName , parameters ) ; return pair . getMethod ( ) . invoke ( object , pair . getParameters ( ) ) ; } | call of a method from given object |
23,409 | public static MethodParameterPair getMethodParameterPairIgnoreCase ( Class objectClass , String methodName , Object [ ] parameters ) throws NoSuchMethodException { if ( parameters == null ) parameters = new Object [ 0 ] ; Class [ ] parameterClasses = new Class [ parameters . length ] ; for ( int i = 0 ; i < parameters . length ; i ++ ) { parameterClasses [ i ] = parameters [ i ] . getClass ( ) ; } Method [ ] methods = null ; if ( lastClass != null && lastClass . equals ( objectClass ) ) { methods = lastMethods ; } else { methods = objectClass . getDeclaredMethods ( ) ; } lastClass = objectClass ; lastMethods = methods ; for ( int mode = 0 ; mode < 2 ; mode ++ ) { outer : for ( int i = 0 ; i < methods . length ; i ++ ) { Method method = methods [ i ] ; if ( method . getName ( ) . equalsIgnoreCase ( methodName ) ) { Class [ ] paramTrg = method . getParameterTypes ( ) ; if ( parameterClasses . length == paramTrg . length ) { for ( int y = 0 ; y < parameterClasses . length ; y ++ ) { if ( mode == 0 && parameterClasses [ y ] != primitiveToWrapperType ( paramTrg [ y ] ) ) { continue outer ; } else if ( mode == 1 ) { Object o = compareClasses ( parameters [ y ] , paramTrg [ y ] ) ; if ( o == null ) { continue outer ; } parameters [ y ] = o ; parameterClasses [ y ] = o . getClass ( ) ; } } return new MethodParameterPair ( method , parameters ) ; } } } } String parameter = "" ; for ( int i = 0 ; i < parameterClasses . length ; i ++ ) { if ( i != 0 ) parameter += ", " ; parameter += parameterClasses [ i ] . getName ( ) ; } throw new NoSuchMethodException ( "method " + methodName + "(" + parameter + ") doesn't exist in class " + objectClass . getName ( ) ) ; } | search the matching method to defined Method Name also translate parameters for matching |
23,410 | private static Object compareClasses ( Object parameter , Class trgClass ) { Class srcClass = parameter . getClass ( ) ; trgClass = primitiveToWrapperType ( trgClass ) ; try { if ( parameter instanceof ObjectWrap ) parameter = ( ( ObjectWrap ) parameter ) . getEmbededObject ( ) ; if ( srcClass == trgClass ) return parameter ; else if ( instaceOf ( srcClass , trgClass ) ) { return parameter ; } else if ( trgClass . getName ( ) . equals ( "java.lang.String" ) ) { return Caster . toString ( parameter ) ; } else if ( trgClass . getName ( ) . equals ( "java.lang.Boolean" ) ) { return Caster . toBoolean ( parameter ) ; } else if ( trgClass . getName ( ) . equals ( "java.lang.Byte" ) ) { return new Byte ( Caster . toString ( parameter ) ) ; } else if ( trgClass . getName ( ) . equals ( "java.lang.Character" ) ) { String str = Caster . toString ( parameter ) ; if ( str . length ( ) == 1 ) return new Character ( str . toCharArray ( ) [ 0 ] ) ; return null ; } else if ( trgClass . getName ( ) . equals ( "java.lang.Short" ) ) { return Short . valueOf ( ( short ) Caster . toIntValue ( parameter ) ) ; } else if ( trgClass . getName ( ) . equals ( "java.lang.Integer" ) ) { return Integer . valueOf ( Caster . toIntValue ( parameter ) ) ; } else if ( trgClass . getName ( ) . equals ( "java.lang.Long" ) ) { return Long . valueOf ( ( long ) Caster . toDoubleValue ( parameter ) ) ; } else if ( trgClass . getName ( ) . equals ( "java.lang.Float" ) ) { return Float . valueOf ( ( float ) Caster . toDoubleValue ( parameter ) ) ; } else if ( trgClass . getName ( ) . equals ( "java.lang.Double" ) ) { return Caster . toDouble ( parameter ) ; } } catch ( PageException e ) { return null ; } return null ; } | compare parameter with whished parameter class and convert parameter to whished type |
23,411 | private static Class primitiveToWrapperType ( Class clazz ) { if ( clazz == null ) return null ; else if ( clazz . isPrimitive ( ) ) { if ( clazz . getName ( ) . equals ( "boolean" ) ) return Boolean . class ; else if ( clazz . getName ( ) . equals ( "byte" ) ) return Byte . class ; else if ( clazz . getName ( ) . equals ( "char" ) ) return Character . class ; else if ( clazz . getName ( ) . equals ( "short" ) ) return Short . class ; else if ( clazz . getName ( ) . equals ( "int" ) ) return Integer . class ; else if ( clazz . getName ( ) . equals ( "long" ) ) return Long . class ; else if ( clazz . getName ( ) . equals ( "float" ) ) return Float . class ; else if ( clazz . getName ( ) . equals ( "double" ) ) return Double . class ; } return clazz ; } | cast a primitive type class definition to his object reference type |
23,412 | public static Object getProperty ( Object o , String prop ) throws NoSuchFieldException , IllegalArgumentException , IllegalAccessException { Field f = getFieldIgnoreCase ( o . getClass ( ) , prop ) ; return f . get ( o ) ; } | to get a visible Property of a object |
23,413 | public static void setProperty ( Object o , String prop , Object value ) throws IllegalArgumentException , IllegalAccessException , NoSuchFieldException { getFieldIgnoreCase ( o . getClass ( ) , prop ) . set ( o , value ) ; } | assign a value to a visible property of a object |
23,414 | public static Object callStaticMethod ( Class staticClass , String methodName , Object [ ] values ) throws PageException { if ( values == null ) values = new Object [ 0 ] ; MethodParameterPair mp ; try { mp = getMethodParameterPairIgnoreCase ( staticClass , methodName , values ) ; } catch ( NoSuchMethodException e ) { throw Caster . toPageException ( e ) ; } try { return mp . getMethod ( ) . invoke ( null , mp . getParameters ( ) ) ; } 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 of a static method of a Class |
23,415 | public void resetPageContext ( ) { SystemOut . printDate ( config . getOutWriter ( ) , "Reset " + pcs . size ( ) + " Unused PageContexts" ) ; pcs . clear ( ) ; Iterator < PageContextImpl > it = runningPcs . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { it . next ( ) . reset ( ) ; } } | reset the PageContexes |
23,416 | public void checkTimeout ( ) { if ( ! engine . allowRequestTimeout ( ) ) return ; Map < Integer , PageContextImpl > map = engine . exeRequestAsync ( ) ? runningChildPcs : runningPcs ; { Iterator < Entry < Integer , PageContextImpl > > it = map . entrySet ( ) . iterator ( ) ; PageContextImpl pc ; Entry < Integer , PageContextImpl > e ; while ( it . hasNext ( ) ) { e = it . next ( ) ; pc = e . getValue ( ) ; long timeout = pc . getRequestTimeout ( ) ; if ( pc . getStartTime ( ) + timeout < System . currentTimeMillis ( ) && Long . MAX_VALUE != timeout ) { Log log = ( ( ConfigImpl ) pc . getConfig ( ) ) . getLog ( "requesttimeout" ) ; if ( log != null ) { log . log ( Log . LEVEL_ERROR , "controller" , "stop " + ( pc . getParentPageContext ( ) == null ? "request" : "thread" ) + " (" + pc . getId ( ) + ") because run into a timeout " + getPath ( pc ) + "." + MonitorState . getBlockedThreads ( pc ) + RequestTimeoutException . locks ( pc ) + "\n" + MonitorState . toString ( pc . getThread ( ) . getStackTrace ( ) ) ) ; } terminate ( pc , true ) ; runningPcs . remove ( Integer . valueOf ( pc . getId ( ) ) ) ; it . remove ( ) ; } else if ( pc . getStartTime ( ) + 10000 < System . currentTimeMillis ( ) && pc . getThread ( ) . getPriority ( ) != Thread . MIN_PRIORITY ) { Log log = ( ( ConfigImpl ) pc . getConfig ( ) ) . getLog ( "requesttimeout" ) ; if ( log != null ) { log . log ( Log . LEVEL_WARN , "controller" , "downgrade priority of the a " + ( pc . getParentPageContext ( ) == null ? "request" : "thread" ) + " at " + getPath ( pc ) + ". " + MonitorState . getBlockedThreads ( pc ) + RequestTimeoutException . locks ( pc ) + "\n" + MonitorState . toString ( pc . getThread ( ) . getStackTrace ( ) ) ) ; } try { pc . getThread ( ) . setPriority ( Thread . MIN_PRIORITY ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; } } } } } | check timeout of all running threads downgrade also priority from all thread run longer than 10 seconds |
23,417 | public void printResults ( ) { System . out . println ( "[ --- Lucee Debug Response --- ]" ) ; System . out . println ( ) ; System . out . println ( "----------------------------" ) ; System . out . println ( "| Output |" ) ; System . out . println ( "----------------------------" ) ; System . out . println ( write ) ; System . out . println ( ) ; System . out . println ( "----------------------------" ) ; System . out . println ( "| Debug Output |" ) ; System . out . println ( "----------------------------" ) ; System . out . println ( writeDebug ) ; System . out . println ( ) ; System . out . println ( "----------------------------" ) ; System . out . println ( "| Variables |" ) ; System . out . println ( "----------------------------" ) ; Enumeration e = variables . keys ( ) ; while ( e . hasMoreElements ( ) ) { final Object key = e . nextElement ( ) ; System . out . println ( "[Variable:" + key + "]" ) ; System . out . println ( escapeString ( variables . get ( key ) . toString ( ) ) ) ; } System . out . println ( ) ; e = queries . keys ( ) ; while ( e . hasMoreElements ( ) ) { final Query query = ( Query ) queries . get ( e . nextElement ( ) ) ; printQuery ( query ) ; System . out . println ( ) ; } } | print out the response |
23,418 | public void printQuery ( final Query query ) { if ( query != null ) { final String [ ] cols = query . getColumns ( ) ; final int rows = query . getRowCount ( ) ; System . out . println ( "[Query:" + query . getName ( ) + "]" ) ; for ( int i = 0 ; i < cols . length ; i ++ ) { if ( i > 0 ) System . out . print ( ", " ) ; System . out . print ( cols [ i ] ) ; } System . out . println ( ) ; for ( int row = 1 ; row <= rows ; row ++ ) { for ( int col = 1 ; col <= cols . length ; col ++ ) { if ( col > 1 ) System . out . print ( ", " ) ; System . out . print ( escapeString ( query . getData ( row , col ) ) ) ; } System . out . println ( ) ; } } } | print out a query |
23,419 | private static String [ ] toRealPath ( Config config , String dotPath ) throws ExpressionException { dotPath = dotPath . trim ( ) ; while ( dotPath . indexOf ( '.' ) == 0 ) { dotPath = dotPath . substring ( 1 ) ; } int len = - 1 ; while ( ( len = dotPath . length ( ) ) > 0 && dotPath . lastIndexOf ( '.' ) == len - 1 ) { dotPath = dotPath . substring ( 0 , len - 2 ) ; } return CustomTagUtil . getFileNames ( config , dotPath . replace ( '.' , '/' ) ) ; } | translate a dot - notation path to a realpath |
23,420 | public static DateTime toDateTime ( Locale locale , String str , TimeZone tz , boolean useCommomDateParserAsWell ) throws PageException { DateTime dt = toDateTime ( locale , str , tz , null , useCommomDateParserAsWell ) ; if ( dt == null ) { String prefix = locale . getLanguage ( ) + "-" + locale . getCountry ( ) + "-" ; throw new ExpressionException ( "can't cast [" + str + "] to date value" , "to add custom formats for " + LocaleFactory . toString ( locale ) + ", create/extend on of the following files [" + prefix + "datetime.df (for date time formats), " + prefix + "date.df (for date formats) or " + prefix + "time.df (for time formats)] in the following directory [<context>/lucee/locales]." + "" ) ; } return dt ; } | parse a string to a Datetime Object |
23,421 | public static DateTime toDateTime ( Locale locale , String str , TimeZone tz , DateTime defaultValue , boolean useCommomDateParserAsWell ) { str = str . trim ( ) ; tz = ThreadLocalPageContext . getTimeZone ( tz ) ; DateFormat [ ] df ; Calendar c = JREDateTimeUtil . getThreadCalendar ( locale , tz ) ; ParsePosition pp = new ParsePosition ( 0 ) ; df = FormatUtil . getDateTimeFormats ( locale , tz , false ) ; Date d ; for ( int i = 0 ; i < df . length ; i ++ ) { SimpleDateFormat sdf = ( SimpleDateFormat ) df [ i ] ; pp . setErrorIndex ( - 1 ) ; pp . setIndex ( 0 ) ; sdf . setTimeZone ( tz ) ; d = sdf . parse ( str , pp ) ; if ( pp . getIndex ( ) == 0 || d == null || pp . getIndex ( ) < str . length ( ) ) continue ; optimzeDate ( c , tz , d ) ; return new DateTimeImpl ( c . getTime ( ) ) ; } df = FormatUtil . getDateFormats ( locale , tz , false ) ; for ( int i = 0 ; i < df . length ; i ++ ) { SimpleDateFormat sdf = ( SimpleDateFormat ) df [ i ] ; pp . setErrorIndex ( - 1 ) ; pp . setIndex ( 0 ) ; sdf . setTimeZone ( tz ) ; d = sdf . parse ( str , pp ) ; if ( pp . getIndex ( ) == 0 || d == null || pp . getIndex ( ) < str . length ( ) ) continue ; optimzeDate ( c , tz , d ) ; return new DateTimeImpl ( c . getTime ( ) ) ; } df = FormatUtil . getTimeFormats ( locale , tz , false ) ; for ( int i = 0 ; i < df . length ; i ++ ) { SimpleDateFormat sdf = ( SimpleDateFormat ) df [ i ] ; pp . setErrorIndex ( - 1 ) ; pp . setIndex ( 0 ) ; sdf . setTimeZone ( tz ) ; d = sdf . parse ( str , pp ) ; if ( pp . getIndex ( ) == 0 || d == null || pp . getIndex ( ) < str . length ( ) ) continue ; c . setTimeZone ( tz ) ; c . setTime ( d ) ; c . set ( Calendar . YEAR , 1899 ) ; c . set ( Calendar . MONTH , 11 ) ; c . set ( Calendar . DAY_OF_MONTH , 30 ) ; c . setTimeZone ( tz ) ; return new DateTimeImpl ( c . getTime ( ) ) ; } if ( useCommomDateParserAsWell ) return DateCaster . toDateSimple ( str , CONVERTING_TYPE_NONE , true , tz , defaultValue ) ; return defaultValue ; } | parse a string to a Datetime Object returns null if can t convert |
23,422 | public static Time toTime ( TimeZone timeZone , Object o ) throws PageException { if ( o instanceof Time ) return ( Time ) o ; else if ( o instanceof Date ) return new TimeImpl ( ( Date ) o ) ; else if ( o instanceof Castable ) return new TimeImpl ( ( ( Castable ) o ) . castToDateTime ( ) ) ; else if ( o instanceof String ) { Time dt = toTime ( timeZone , o . toString ( ) , null ) ; if ( dt == null ) throw new ExpressionException ( "can't cast [" + o + "] to time value" ) ; return dt ; } else if ( o instanceof ObjectWrap ) return toTime ( timeZone , ( ( ObjectWrap ) o ) . getEmbededObject ( ) ) ; else if ( o instanceof Calendar ) { return new TimeImpl ( ( ( Calendar ) o ) . getTimeInMillis ( ) , false ) ; } throw new ExpressionException ( "can't cast [" + Caster . toClassName ( o ) + "] to time value" ) ; } | converts a Object to a Time Object returns null if invalid string |
23,423 | public static Time toTime ( TimeZone timeZone , String str , Time defaultValue ) { if ( str == null || str . length ( ) < 3 ) { return defaultValue ; } DateString ds = new DateString ( str ) ; if ( ds . isCurrent ( '{' ) && ds . isLast ( '}' ) ) { if ( ds . fwIfNext ( 't' ) ) { if ( ! ( ds . fwIfNext ( ' ' ) && ds . fwIfNext ( '\'' ) ) ) return defaultValue ; ds . next ( ) ; int hour = ds . readDigits ( ) ; if ( hour == - 1 ) return defaultValue ; if ( ! ds . fwIfCurrent ( ':' ) ) return defaultValue ; int minute = ds . readDigits ( ) ; if ( minute == - 1 ) return defaultValue ; if ( ! ds . fwIfCurrent ( ':' ) ) return defaultValue ; int second = ds . readDigits ( ) ; if ( second == - 1 ) return defaultValue ; if ( ! ( ds . fwIfCurrent ( '\'' ) && ds . fwIfCurrent ( '}' ) ) ) return defaultValue ; if ( ds . isAfterLast ( ) ) { long time = util . toTime ( timeZone , 1899 , 12 , 30 , hour , minute , second , 0 , DEFAULT_VALUE ) ; if ( time == DEFAULT_VALUE ) return defaultValue ; return new TimeImpl ( time , false ) ; } return defaultValue ; } return defaultValue ; } ds . reset ( ) ; DateTime rtn = parseTime ( timeZone , new int [ ] { 1899 , 12 , 30 } , ds , defaultValue , - 1 ) ; if ( rtn == defaultValue ) return defaultValue ; return new TimeImpl ( rtn ) ; } | converts a String to a Time Object returns null if invalid string |
23,424 | private static DateTime parseDateTime ( String str , DateString ds , short convertingType , boolean alsoMonthString , TimeZone timeZone , DateTime defaultValue ) { int month = 0 ; int first = ds . readDigits ( ) ; if ( first == - 1 ) { if ( ! alsoMonthString ) return defaultValue ; first = ds . readMonthString ( ) ; if ( first == - 1 ) return defaultValue ; month = 1 ; } if ( ds . isAfterLast ( ) ) return month == 1 ? defaultValue : numberToDate ( timeZone , Caster . toDoubleValue ( str , Double . NaN ) , convertingType , defaultValue ) ; char del = ds . current ( ) ; if ( del != '.' && del != '/' && del != '-' && del != ' ' && del != '\t' ) { if ( ds . fwIfCurrent ( ':' ) ) { return parseTime ( timeZone , new int [ ] { 1899 , 12 , 30 } , ds , defaultValue , first ) ; } return defaultValue ; } ds . next ( ) ; ds . removeWhitespace ( ) ; int second = ds . readDigits ( ) ; if ( second == - 1 ) { if ( ! alsoMonthString || month != 0 ) return defaultValue ; second = ds . readMonthString ( ) ; if ( second == - 1 ) return defaultValue ; month = 2 ; } if ( ds . isAfterLast ( ) ) { return toDate ( month , timeZone , first , second , defaultValue ) ; } char del2 = ds . current ( ) ; if ( del != del2 ) { ds . fwIfCurrent ( ' ' ) ; ds . fwIfCurrent ( 'T' ) ; ds . fwIfCurrent ( ' ' ) ; return parseTime ( timeZone , _toDate ( timeZone , month , first , second ) , ds , defaultValue , - 1 ) ; } ds . next ( ) ; ds . removeWhitespace ( ) ; int third = ds . readDigits ( ) ; if ( third == - 1 ) { return defaultValue ; } if ( ds . isAfterLast ( ) ) { if ( classicStyle ( ) && del == '.' ) return toDate ( month , timeZone , second , first , third , defaultValue ) ; return toDate ( month , timeZone , first , second , third , defaultValue ) ; } ds . fwIfCurrent ( ' ' ) ; ds . fwIfCurrent ( 'T' ) ; ds . fwIfCurrent ( ' ' ) ; if ( classicStyle ( ) && del == '.' ) return parseTime ( timeZone , _toDate ( month , second , first , third ) , ds , defaultValue , - 1 ) ; return parseTime ( timeZone , _toDate ( month , first , second , third ) , ds , defaultValue , - 1 ) ; } | converts a String to a DateTime Object returns null if invalid string |
23,425 | private static DateTime readOffset ( boolean isPlus , TimeZone timeZone , DateTime dt , int years , int months , int days , int hours , int minutes , int seconds , int milliSeconds , DateString ds , boolean checkAfterLast , DateTime defaultValue ) { if ( timeZone == null ) return defaultValue ; int hourLength = ds . getPos ( ) ; int hour = ds . readDigits ( ) ; hourLength = ds . getPos ( ) - hourLength ; if ( hour == - 1 ) return defaultValue ; int minute = 0 ; if ( ! ds . isAfterLast ( ) ) { if ( ! ( ds . fwIfCurrent ( ':' ) || ds . fwIfCurrent ( '.' ) ) ) return defaultValue ; minute = ds . readDigits ( ) ; if ( minute == - 1 ) return defaultValue ; } else if ( hourLength > 2 ) { int h = hour / 100 ; minute = hour - ( h * 100 ) ; hour = h ; } if ( minute > 59 ) return defaultValue ; if ( hour > 14 || ( hour == 14 && minute > 0 ) ) return defaultValue ; long offset = hour * 60L * 60L * 1000L ; offset += minute * 60 * 1000 ; if ( ! checkAfterLast || ds . isAfterLast ( ) ) { long time = util . toTime ( TimeZoneConstants . UTC , years , months , days , hours , minutes , seconds , milliSeconds , 0 ) ; if ( isPlus ) time -= offset ; else time += offset ; return new DateTimeImpl ( time , false ) ; } return defaultValue ; } | reads a offset definition at the end of a date string |
23,426 | synchronized void printBuffer ( ) throws IOException { int len = sb . length ( ) ; if ( len > 0 ) { char [ ] chars = new char [ len ] ; sb . getChars ( 0 , len , chars , 0 ) ; sb . setLength ( 0 ) ; super . write ( chars , 0 , chars . length ) ; } } | prints the characters from the buffer and resets it |
23,427 | boolean addToBuffer ( char c ) throws IOException { int len = sb . length ( ) ; if ( len == 0 && c != CHAR_LT ) return false ; sb . append ( c ) ; if ( ++ len >= minTagLen ) { boolean isClosingTag = ( len >= 2 && sb . charAt ( 1 ) == CHAR_SL ) ; String substr ; if ( isClosingTag ) substr = sb . substring ( 2 ) ; else substr = sb . substring ( 1 ) ; for ( int i = 0 ; i < EXCLUDE_TAGS . length ; i ++ ) { if ( substr . equalsIgnoreCase ( EXCLUDE_TAGS [ i ] ) ) { if ( isClosingTag ) { depthDec ( i ) ; printBuffer ( ) ; lastChar = 0 ; } else { depthInc ( i ) ; } } } } return true ; } | checks if a character is part of an open html tag or close html tag and if so adds it to the buffer otherwise returns false . |
23,428 | public void print ( char c ) throws IOException { boolean isWS = Character . isWhitespace ( c ) ; if ( isWS ) { if ( isFirstChar ) return ; if ( c == CHAR_RETURN ) return ; if ( sb . length ( ) > 0 ) { printBuffer ( ) ; lastChar = ( c == CHAR_NL ) ? CHAR_NL : c ; super . print ( lastChar ) ; return ; } } isFirstChar = false ; if ( c == CHAR_GT && sb . length ( ) > 0 ) printBuffer ( ) ; if ( isWS || ! addToBuffer ( c ) ) { if ( depthSum == 0 ) { if ( isWS ) { if ( lastChar == CHAR_NL ) return ; if ( c != CHAR_NL ) { if ( Character . isWhitespace ( lastChar ) ) return ; } } } lastChar = c ; super . print ( c ) ; } } | sends a character to output stream if it is not a consecutive white - space unless we re inside a PRE or TEXTAREA tag . |
23,429 | public HtmlEmailImpl setTextMsg ( String aText ) throws EmailException { if ( StringUtil . isEmpty ( aText ) ) { throw new EmailException ( "Invalid message supplied" ) ; } this . text = aText ; return this ; } | Set the text content . |
23,430 | public HtmlEmailImpl setHtmlMsg ( String aHtml ) throws EmailException { if ( StringUtil . isEmpty ( aHtml ) ) { throw new EmailException ( "Invalid message supplied" ) ; } this . html = aHtml ; return this ; } | Set the HTML content . |
23,431 | public void embed ( URL url , String cid , String name ) throws EmailException { try { InputStream is = url . openStream ( ) ; is . close ( ) ; } catch ( IOException e ) { throw new EmailException ( "Invalid URL" ) ; } MimeBodyPart mbp = new MimeBodyPart ( ) ; try { mbp . setDataHandler ( new DataHandler ( new URLDataSource ( url ) ) ) ; mbp . setFileName ( name ) ; mbp . setDisposition ( "inline" ) ; mbp . addHeader ( "Content-ID" , "<" + cid + ">" ) ; this . inlineImages . add ( mbp ) ; } catch ( MessagingException me ) { throw new EmailException ( me ) ; } } | Embeds an URL in the HTML . |
23,432 | public void buildMimeMessage ( ) throws EmailException { try { if ( this . isBoolHasAttachments ( ) ) { this . buildAttachments ( ) ; } else { this . buildNoAttachments ( ) ; } } catch ( MessagingException me ) { throw new EmailException ( me ) ; } super . buildMimeMessage ( ) ; } | Does the work of actually building the email . |
23,433 | public synchronized void put ( IPRangeNode < Map > ipr , boolean doCheck ) { IPRangeNode parent = ipr . isV4 ( ) ? ipv4 : ipv6 ; parent . addChild ( ipr , doCheck ) ; version ++ ; isSorted = false ; } | all added data should go through this method |
23,434 | public IPRangeNode get ( InetAddress addr ) { if ( version == 0 ) return null ; IPRangeNode node = isV4 ( addr ) ? ipv4 : ipv6 ; if ( ! this . isSorted ) this . optimize ( ) ; return node . findFast ( addr ) ; } | returns a single best matching node for the given address |
23,435 | public String getWsdlFile ( ) { if ( meta == null ) return null ; return ( String ) meta . get ( WSDL_FILE , null ) ; } | returns null if there is no wsdlFile defined |
23,436 | public byte [ ] toByteArray ( ) { byte [ ] p = new byte [ 48 ] ; p [ 0 ] = ( byte ) ( leapIndicator << 6 | version << 3 | mode ) ; p [ 1 ] = ( byte ) stratum ; p [ 2 ] = pollInterval ; p [ 3 ] = precision ; int l = ( int ) ( rootDelay * 65536.0 ) ; p [ 4 ] = ( byte ) ( ( l >> 24 ) & 0xFF ) ; p [ 5 ] = ( byte ) ( ( l >> 16 ) & 0xFF ) ; p [ 6 ] = ( byte ) ( ( l >> 8 ) & 0xFF ) ; p [ 7 ] = ( byte ) ( l & 0xFF ) ; long ul = ( long ) ( rootDispersion * 65536.0 ) ; p [ 8 ] = ( byte ) ( ( ul >> 24 ) & 0xFF ) ; p [ 9 ] = ( byte ) ( ( ul >> 16 ) & 0xFF ) ; p [ 10 ] = ( byte ) ( ( ul >> 8 ) & 0xFF ) ; p [ 11 ] = ( byte ) ( ul & 0xFF ) ; p [ 12 ] = referenceIdentifier [ 0 ] ; p [ 13 ] = referenceIdentifier [ 1 ] ; p [ 14 ] = referenceIdentifier [ 2 ] ; p [ 15 ] = referenceIdentifier [ 3 ] ; encodeTimestamp ( p , 16 , referenceTimestamp ) ; encodeTimestamp ( p , 24 , originateTimestamp ) ; encodeTimestamp ( p , 32 , receiveTimestamp ) ; encodeTimestamp ( p , 40 , transmitTimestamp ) ; return p ; } | This method constructs the data bytes of a raw NTP packet . |
23,437 | public static void encodeTimestamp ( byte [ ] array , int pointer , double timestamp ) { for ( int i = 0 ; i < 8 ; i ++ ) { double base = Math . pow ( 2 , ( 3 - i ) * 8 ) ; array [ pointer + i ] = ( byte ) ( timestamp / base ) ; timestamp = timestamp - ( unsignedByteToShort ( array [ pointer + i ] ) * base ) ; } array [ 7 ] = ( byte ) ( Math . random ( ) * 255.0 ) ; } | Encodes a timestamp in the specified position in the message |
23,438 | public static String referenceIdentifierToString ( byte [ ] ref , short stratum , byte version ) { if ( stratum == 0 || stratum == 1 ) { return new String ( ref ) ; } else if ( version == 3 ) { return unsignedByteToShort ( ref [ 0 ] ) + "." + unsignedByteToShort ( ref [ 1 ] ) + "." + unsignedByteToShort ( ref [ 2 ] ) + "." + unsignedByteToShort ( ref [ 3 ] ) ; } else if ( version == 4 ) { return "" + ( ( unsignedByteToShort ( ref [ 0 ] ) / 256.0 ) + ( unsignedByteToShort ( ref [ 1 ] ) / 65536.0 ) + ( unsignedByteToShort ( ref [ 2 ] ) / 16777216.0 ) + ( unsignedByteToShort ( ref [ 3 ] ) / 4294967296.0 ) ) ; } return "" ; } | Returns a string representation of a reference identifier according to the rules set out in RFC 2030 . |
23,439 | public static int compare ( Object left , Object right ) throws PageException { if ( left instanceof String ) return compare ( ( String ) left , right ) ; else if ( left instanceof Number ) return compare ( ( ( Number ) left ) . doubleValue ( ) , right ) ; else if ( left instanceof Boolean ) return compare ( ( ( Boolean ) left ) . booleanValue ( ) , right ) ; else if ( left instanceof Date ) return compare ( ( Date ) left , right ) ; else if ( left instanceof Castable ) return compare ( ( ( Castable ) left ) , right ) ; else if ( left instanceof Locale ) return compare ( ( ( Locale ) left ) , right ) ; else if ( left == null ) return compare ( "" , right ) ; else if ( left instanceof Character ) return compare ( ( ( Character ) left ) . toString ( ) , right ) ; else if ( left instanceof Calendar ) return compare ( ( ( Calendar ) left ) . getTime ( ) , right ) ; else if ( left instanceof TimeZone ) return compare ( ( ( TimeZone ) left ) , right ) ; else { return error ( false , true ) ; } } | compares two Objects |
23,440 | public static int compare ( String left , String right ) { if ( Decision . isNumber ( left ) ) { if ( Decision . isNumber ( right ) ) { if ( left . length ( ) > 9 || right . length ( ) > 9 ) { try { return new BigDecimal ( left ) . compareTo ( new BigDecimal ( right ) ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; } } return compare ( Caster . toDoubleValue ( left , Double . NaN ) , Caster . toDoubleValue ( right , Double . NaN ) ) ; } return compare ( Caster . toDoubleValue ( left , Double . NaN ) , right ) ; } if ( Decision . isBoolean ( left ) ) return compare ( Caster . toBooleanValue ( left , false ) ? 1D : 0D , right ) ; return left . compareToIgnoreCase ( right ) ; } | compares a String with a String |
23,441 | public static int compare ( String left , double right ) { if ( Decision . isNumber ( left ) ) { if ( left . length ( ) > 9 ) { try { return new BigDecimal ( left ) . compareTo ( new BigDecimal ( Caster . toString ( right ) ) ) ; } catch ( Exception e ) { } } return compare ( Caster . toDoubleValue ( left , Double . NaN ) , right ) ; } if ( Decision . isBoolean ( left ) ) return compare ( Caster . toBooleanValue ( left , false ) , right ) ; if ( left . length ( ) == 0 ) return - 1 ; char leftFirst = left . charAt ( 0 ) ; if ( leftFirst >= '0' && leftFirst <= '9' ) return left . compareToIgnoreCase ( Caster . toString ( right ) ) ; return leftFirst - '0' ; } | compares a String with a double |
23,442 | public static int compare ( Date left , String right ) throws PageException { if ( Decision . isNumber ( right ) ) return compare ( left . getTime ( ) / 1000 , Caster . toDoubleValue ( right ) ) ; DateTime dt = DateCaster . toDateAdvanced ( right , DateCaster . CONVERTING_TYPE_OFFSET , null , null ) ; if ( dt != null ) { return compare ( left . getTime ( ) / 1000 , dt . getTime ( ) / 1000 ) ; } return Caster . toString ( left ) . compareToIgnoreCase ( right ) ; } | compares a Date with a String |
23,443 | public static int compare ( Date left , double right ) { return compare ( left . getTime ( ) / 1000 , DateTimeUtil . getInstance ( ) . toDateTime ( right ) . getTime ( ) / 1000 ) ; } | compares a Date with a double |
23,444 | public static int compare ( Date left , Date right ) { return compare ( left . getTime ( ) / 1000 , right . getTime ( ) / 1000 ) ; } | compares a Date with a Date |
23,445 | public static double exponent ( Object left , Object right ) throws PageException { return StrictMath . pow ( Caster . toDoubleValue ( left ) , Caster . toDoubleValue ( right ) ) ; } | calculate the exponent of the left value |
23,446 | public static CharSequence concat ( CharSequence left , CharSequence right ) { if ( left instanceof Appendable ) { try { ( ( Appendable ) left ) . append ( right ) ; return left ; } catch ( IOException e ) { } } return new StringBuilder ( left ) . append ( right ) ; } | concat 2 CharSequences |
23,447 | public static void visitLine ( BytecodeContext bc , Position pos ) { if ( pos != null ) { visitLine ( bc , pos . line ) ; } } | visit line number |
23,448 | public static void writeOutSilent ( Expression value , BytecodeContext bc , int mode ) throws TransformerException { Position start = value . getStart ( ) ; Position end = value . getEnd ( ) ; value . setStart ( null ) ; value . setEnd ( null ) ; value . writeOut ( bc , mode ) ; value . setStart ( start ) ; value . setEnd ( end ) ; } | write out expression without LNT |
23,449 | public static void addTagMetaData ( ConfigWebImpl cw , lucee . commons . io . log . Log log ) { if ( true ) return ; PageContextImpl pc = null ; try { pc = ThreadUtil . createPageContext ( cw , DevNullOutputStream . DEV_NULL_OUTPUT_STREAM , "localhost" , "/" , "" , new Cookie [ 0 ] , new Pair [ 0 ] , null , new Pair [ 0 ] , new StructImpl ( ) , false , - 1 ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; return ; } PageContext orgPC = ThreadLocalPageContext . get ( ) ; try { ThreadLocalPageContext . register ( pc ) ; _addTagMetaData ( pc , cw , CFMLEngine . DIALECT_CFML ) ; _addTagMetaData ( pc , cw , CFMLEngine . DIALECT_LUCEE ) ; } catch ( Exception e ) { XMLConfigWebFactory . log ( cw , log , e ) ; } finally { pc . getConfig ( ) . getFactory ( ) . releaseLuceePageContext ( pc , true ) ; ThreadLocalPageContext . register ( orgPC ) ; } } | load metadata from cfc based custom tags and add the info to the tag |
23,450 | public static Object invokeBIF ( PageContext pc , Object [ ] args , String className , String bundleName , String bundleVersion ) throws PageException { try { Class < ? > clazz = ClassUtil . loadClassByBundle ( className , bundleName , bundleVersion , pc . getConfig ( ) . getIdentification ( ) ) ; BIF bif ; if ( Reflector . isInstaneOf ( clazz , BIF . class ) ) bif = ( BIF ) clazz . newInstance ( ) ; else bif = new BIFProxy ( clazz ) ; return bif . invoke ( pc , args ) ; } catch ( Exception e ) { throw Caster . toPageException ( e ) ; } } | used by the bytecode builded |
23,451 | public void setCredential ( String username , String password ) { if ( username != null ) { env . put ( "java.naming.security.principal" , username ) ; env . put ( "java.naming.security.credentials" , password ) ; } else { env . remove ( "java.naming.security.principal" ) ; env . remove ( "java.naming.security.credentials" ) ; } } | sets username password for the connection |
23,452 | public void setSecureLevel ( short secureLevel ) throws ClassException { if ( secureLevel == SECURE_CFSSL_BASIC ) { env . put ( "java.naming.security.protocol" , "ssl" ) ; env . put ( "java.naming.ldap.factory.socket" , "javax.net.ssl.SSLSocketFactory" ) ; ClassUtil . loadClass ( "com.sun.net.ssl.internal.ssl.Provider" ) ; Security . addProvider ( new com . sun . net . ssl . internal . ssl . Provider ( ) ) ; } else if ( secureLevel == SECURE_CFSSL_CLIENT_AUTH ) { env . put ( "java.naming.security.protocol" , "ssl" ) ; env . put ( "java.naming.security.authentication" , "EXTERNAL" ) ; } else { env . put ( "java.naming.security.authentication" , "simple" ) ; env . remove ( "java.naming.security.protocol" ) ; env . remove ( "java.naming.ldap.factory.socket" ) ; } } | sets the secure Level |
23,453 | public void setReferral ( int referral ) { if ( referral > 0 ) { env . put ( "java.naming.referral" , "follow" ) ; env . put ( "java.naming.ldap.referral.limit" , Caster . toString ( referral ) ) ; } else { env . put ( "java.naming.referral" , "ignore" ) ; env . remove ( "java.naming.ldap.referral.limit" ) ; } } | sets thr referral |
23,454 | public void add ( String dn , String attributes , String delimiter , String seperator ) throws NamingException , PageException { DirContext ctx = new InitialDirContext ( env ) ; ctx . createSubcontext ( dn , toAttributes ( attributes , delimiter , seperator ) ) ; ctx . close ( ) ; } | adds LDAP entries to LDAP server |
23,455 | public void delete ( String dn ) throws NamingException { DirContext ctx = new InitialDirContext ( env ) ; ctx . destroySubcontext ( dn ) ; ctx . close ( ) ; } | deletes LDAP entries on an LDAP server |
23,456 | public void modifydn ( String dn , String attributes ) throws NamingException { DirContext ctx = new InitialDirContext ( env ) ; ctx . rename ( dn , attributes ) ; ctx . close ( ) ; } | modifies distinguished name attribute for LDAP entries on LDAP server |
23,457 | public PageException execute ( String id ) { SpoolerTask task = getTaskById ( openDirectory , id ) ; if ( task == null ) task = getTaskById ( closedDirectory , id ) ; if ( task != null ) { return execute ( task ) ; } return null ; } | execute task by id and return eror throwd by task |
23,458 | protected static InternetAddress [ ] add ( InternetAddress [ ] oldArr , InternetAddress newValue ) { if ( oldArr == null ) return new InternetAddress [ ] { newValue } ; InternetAddress [ ] tmp = new InternetAddress [ oldArr . length + 1 ] ; for ( int i = 0 ; i < oldArr . length ; i ++ ) { tmp [ i ] = oldArr [ i ] ; } tmp [ oldArr . length ] = newValue ; return tmp ; } | creates a new expanded array and return it ; |
23,459 | private static void clean ( Config config , Attachment [ ] attachmentz ) { if ( attachmentz != null ) for ( int i = 0 ; i < attachmentz . length ; i ++ ) { if ( attachmentz [ i ] . isRemoveAfterSend ( ) ) { Resource res = config . getResource ( attachmentz [ i ] . getAbsolutePath ( ) ) ; ResourceUtil . removeEL ( res , true ) ; } } } | remove all atttachements that are marked to remove |
23,460 | public Boolean isWriteLocked ( K token ) { RWLock < K > lock = locks . get ( token ) ; if ( lock == null ) return null ; return lock . isWriteLocked ( ) ; } | Queries if the write lock is held by any thread on given lock token returns null when lock with this token does not exists |
23,461 | public static DateFormat [ ] getCFMLFormats ( TimeZone tz , boolean lenient ) { String id = "cfml-" + Locale . ENGLISH . toString ( ) + "-" + tz . getID ( ) + "-" + lenient ; DateFormat [ ] df = formats . get ( id ) ; if ( df == null ) { df = new SimpleDateFormat [ ] { new SimpleDateFormat ( "EEE MMM dd HH:mm:ss z yyyy" , Locale . ENGLISH ) , new SimpleDateFormat ( "MMMM dd, yyyy HH:mm:ss a zzz" , Locale . ENGLISH ) , new SimpleDateFormat ( "MMM dd, yyyy HH:mm:ss a" , Locale . ENGLISH ) , new SimpleDateFormat ( "MMM dd, yyyy HH:mm:ss" , Locale . ENGLISH ) , new SimpleDateFormat ( "MMMM d yyyy HH:mm:ssZ" , Locale . ENGLISH ) , new SimpleDateFormat ( "MMMM d yyyy HH:mm:ss" , Locale . ENGLISH ) , new SimpleDateFormat ( "MMMM d yyyy HH:mm" , Locale . ENGLISH ) , new SimpleDateFormat ( "EEE, MMM dd, yyyy HH:mm:ssZ" , Locale . ENGLISH ) , new SimpleDateFormat ( "EEE, MMM dd, yyyy HH:mm:ss" , Locale . ENGLISH ) , new SimpleDateFormat ( "EEEE, MMMM dd, yyyy H:mm:ss a zzz" , Locale . ENGLISH ) , new SimpleDateFormat ( "dd-MMM-yy HH:mm a" , Locale . ENGLISH ) , new SimpleDateFormat ( "dd-MMMM-yy HH:mm a" , Locale . ENGLISH ) , new SimpleDateFormat ( "EE, dd-MMM-yyyy HH:mm:ss zz" , Locale . ENGLISH ) , new SimpleDateFormat ( "EE, dd MMM yyyy HH:mm:ss zz" , Locale . ENGLISH ) , new SimpleDateFormat ( "EEE d, MMM yyyy HH:mm:ss zz" , Locale . ENGLISH ) , new SimpleDateFormat ( "dd-MMM-yyyy" , Locale . ENGLISH ) , new SimpleDateFormat ( "MMMM, dd yyyy HH:mm:ssZ" , Locale . ENGLISH ) , new SimpleDateFormat ( "MMMM, dd yyyy HH:mm:ss" , Locale . ENGLISH ) , new SimpleDateFormat ( "yyyy/MM/dd HH:mm:ss zz" , Locale . ENGLISH ) , new SimpleDateFormat ( "dd MMM yyyy HH:mm:ss zz" , Locale . ENGLISH ) , new SimpleDateFormat ( "EEE MMM dd yyyy HH:mm:ss 'GMT'ZZ (z)" , Locale . ENGLISH ) , new SimpleDateFormat ( "dd MMM, yyyy HH:mm:ss" , Locale . ENGLISH ) } ; for ( int i = 0 ; i < df . length ; i ++ ) { df [ i ] . setLenient ( lenient ) ; df [ i ] . setTimeZone ( tz ) ; } formats . put ( id , df ) ; } return clone ( df ) ; } | CFML Supported LS Formats |
23,462 | public void setMode ( String mode ) throws PageException { try { this . mode = ModeUtil . toOctalMode ( mode ) ; } catch ( IOException e ) { throw Caster . toPageException ( e ) ; } } | set the value mode Used with action = Create to define the permissions for a directory on UNIX and Linux platforms . Ignored on Windows . Options correspond to the octal values of the UNIX chmod command . From left to right permissions are assigned for owner group and other . |
23,463 | public void setNameconflict ( String nameconflict ) throws ApplicationException { this . nameconflict = FileUtil . toNameConflict ( nameconflict , NAMECONFLICT_UNDEFINED | NAMECONFLICT_ERROR | NAMECONFLICT_OVERWRITE , NAMECONFLICT_DEFAULT ) ; } | set the value nameconflict Action to take if destination directory is the same as that of a file in the directory . |
23,464 | public static void actionRename ( PageContext pc , Resource directory , String strNewdirectory , String serverPassword , boolean createPath , Object acl , String storage ) throws PageException { SecurityManager securityManager = pc . getConfig ( ) . getSecurityManager ( ) ; securityManager . checkFileLocation ( pc . getConfig ( ) , directory , serverPassword ) ; if ( ! directory . exists ( ) ) throw new ApplicationException ( "the directory [" + directory . toString ( ) + "] doesn't exist" ) ; if ( ! directory . isDirectory ( ) ) throw new ApplicationException ( "the file [" + directory . toString ( ) + "] exists, but it isn't a directory" ) ; if ( ! directory . canRead ( ) ) throw new ApplicationException ( "no access to read directory [" + directory . toString ( ) + "]" ) ; if ( strNewdirectory == null ) throw new ApplicationException ( "the attribute [newDirectory] is not defined" ) ; Resource newdirectory = toDestination ( pc , strNewdirectory , directory ) ; securityManager . checkFileLocation ( pc . getConfig ( ) , newdirectory , serverPassword ) ; if ( newdirectory . exists ( ) ) throw new ApplicationException ( "new directory [" + newdirectory . toString ( ) + "] already exists" ) ; if ( createPath ) { newdirectory . getParentResource ( ) . mkdirs ( ) ; } try { directory . moveTo ( newdirectory ) ; } catch ( Throwable t ) { ExceptionUtil . rethrowIfNecessary ( t ) ; throw Caster . toPageException ( t ) ; } setS3Attrs ( pc , directory , acl , storage ) ; } | rename a directory to a new Name |
23,465 | public void append ( String str ) { if ( str == null ) return ; int restLength = buffer . length - pos ; if ( str . length ( ) < restLength ) { str . getChars ( 0 , str . length ( ) , buffer , pos ) ; pos += str . length ( ) ; } else { str . getChars ( 0 , restLength , buffer , pos ) ; curr . next = new Entity ( buffer ) ; curr = curr . next ; length += buffer . length ; buffer = new char [ ( buffer . length > str . length ( ) - restLength ) ? buffer . length : str . length ( ) - restLength ] ; str . getChars ( restLength , str . length ( ) , buffer , 0 ) ; pos = str . length ( ) - restLength ; } } | Method to append a string to char buffer |
23,466 | public char [ ] toCharArray ( ) { Entity e = root ; char [ ] chrs = new char [ size ( ) ] ; int off = 0 ; while ( e . next != null ) { e = e . next ; System . arraycopy ( e . data , 0 , chrs , off , e . data . length ) ; off += e . data . length ; } System . arraycopy ( buffer , 0 , chrs , off , pos ) ; return chrs ; } | return content of the Char Buffer as char array |
23,467 | public void clear ( ) { if ( size ( ) == 0 ) return ; buffer = new char [ buffer . length ] ; root . next = null ; pos = 0 ; length = 0 ; curr = root ; } | clear the content of the buffer |
23,468 | private AFTPClient actionExistsDir ( ) throws PageException , IOException { required ( "directory" , directory ) ; AFTPClient client = getClient ( ) ; boolean res = existsDir ( client , directory ) ; Struct cfftp = writeCfftp ( client ) ; cfftp . setEL ( RETURN_VALUE , Caster . toBoolean ( res ) ) ; cfftp . setEL ( SUCCEEDED , Boolean . TRUE ) ; stoponerror = false ; return client ; } | check if a directory exists or not |
23,469 | private AFTPClient actionExistsFile ( ) throws PageException , IOException { required ( "remotefile" , remotefile ) ; AFTPClient client = getClient ( ) ; FTPFile file = existsFile ( client , remotefile , true ) ; Struct cfftp = writeCfftp ( client ) ; cfftp . setEL ( RETURN_VALUE , Caster . toBoolean ( file != null && file . isFile ( ) ) ) ; cfftp . setEL ( SUCCEEDED , Boolean . TRUE ) ; stoponerror = false ; return client ; } | check if a file exists or not |
23,470 | private AFTPClient actionExists ( ) throws PageException , IOException { required ( "item" , item ) ; AFTPClient client = getClient ( ) ; FTPFile file = existsFile ( client , item , false ) ; Struct cfftp = writeCfftp ( client ) ; cfftp . setEL ( RETURN_VALUE , Caster . toBoolean ( file != null ) ) ; cfftp . setEL ( SUCCEEDED , Boolean . TRUE ) ; return client ; } | check if a file or directory exists |
23,471 | private AFTPClient actionRemove ( ) throws IOException , PageException { required ( "item" , item ) ; AFTPClient client = getClient ( ) ; client . deleteFile ( item ) ; writeCfftp ( client ) ; return client ; } | removes a file on the server |
23,472 | private AFTPClient actionRename ( ) throws PageException , IOException { required ( "existing" , existing ) ; required ( "new" , _new ) ; AFTPClient client = getClient ( ) ; client . rename ( existing , _new ) ; writeCfftp ( client ) ; return client ; } | rename a file on the server |
23,473 | private AFTPClient actionPutFile ( ) throws IOException , PageException { required ( "remotefile" , remotefile ) ; required ( "localfile" , localfile ) ; AFTPClient client = getClient ( ) ; Resource local = ResourceUtil . toResourceExisting ( pageContext , localfile ) ; InputStream is = null ; try { is = IOUtil . toBufferedInputStream ( local . getInputStream ( ) ) ; client . setFileType ( getType ( local ) ) ; client . storeFile ( remotefile , is ) ; } finally { IOUtil . closeEL ( is ) ; } writeCfftp ( client ) ; return client ; } | copy a local file to server |
23,474 | private AFTPClient actionGetFile ( ) throws PageException , IOException { required ( "remotefile" , remotefile ) ; required ( "localfile" , localfile ) ; AFTPClient client = getClient ( ) ; Resource local = ResourceUtil . toResourceExistingParent ( pageContext , localfile ) ; pageContext . getConfig ( ) . getSecurityManager ( ) . checkFileLocation ( local ) ; if ( failifexists && local . exists ( ) ) throw new ApplicationException ( "File [" + local + "] already exist, if you want to overwrite, set attribute failIfExists to false" ) ; OutputStream fos = null ; client . setFileType ( getType ( local ) ) ; boolean success = false ; try { fos = IOUtil . toBufferedOutputStream ( local . getOutputStream ( ) ) ; success = client . retrieveFile ( remotefile , fos ) ; } finally { IOUtil . closeEL ( fos ) ; if ( ! success ) local . delete ( ) ; } writeCfftp ( client ) ; return client ; } | gets a file from server and copy it local |
23,475 | private AFTPClient actionGetCurrentURL ( ) throws PageException , IOException { AFTPClient client = getClient ( ) ; String pwd = client . printWorkingDirectory ( ) ; Struct cfftp = writeCfftp ( client ) ; cfftp . setEL ( "returnValue" , client . getPrefix ( ) + "://" + client . getRemoteAddress ( ) . getHostName ( ) + pwd ) ; return client ; } | get url of the working directory |
23,476 | private AFTPClient actionGetCurrentDir ( ) throws PageException , IOException { AFTPClient client = getClient ( ) ; String pwd = client . printWorkingDirectory ( ) ; Struct cfftp = writeCfftp ( client ) ; cfftp . setEL ( "returnValue" , pwd ) ; return client ; } | get path from the working directory |
23,477 | private AFTPClient actionChangeDir ( ) throws IOException , PageException { required ( "directory" , directory ) ; AFTPClient client = getClient ( ) ; client . changeWorkingDirectory ( directory ) ; writeCfftp ( client ) ; return client ; } | change working directory |
23,478 | private AFTPClient actionRemoveDir ( ) throws IOException , PageException { required ( "directory" , directory ) ; AFTPClient client = getClient ( ) ; if ( recursive ) { removeRecursive ( client , directory , FTPFile . DIRECTORY_TYPE ) ; } else client . removeDirectory ( directory ) ; writeCfftp ( client ) ; return client ; } | removes a remote directory on server |
23,479 | private AFTPClient actionCreateDir ( ) throws IOException , PageException { required ( "directory" , directory ) ; AFTPClient client = getClient ( ) ; client . makeDirectory ( directory ) ; writeCfftp ( client ) ; return client ; } | create a remote directory |
23,480 | private AFTPClient actionListDir ( ) throws PageException , IOException { required ( "name" , name ) ; required ( "directory" , directory ) ; AFTPClient client = getClient ( ) ; FTPFile [ ] files = client . listFiles ( directory ) ; if ( files == null ) files = new FTPFile [ 0 ] ; pageContext . setVariable ( name , toQuery ( files , "ftp" , directory , client . getRemoteAddress ( ) . getHostName ( ) ) ) ; writeCfftp ( client ) ; return client ; } | List data of a ftp connection |
23,481 | private AFTPClient actionOpen ( ) throws IOException , PageException { required ( "server" , server ) ; required ( "username" , username ) ; AFTPClient client = getClient ( ) ; writeCfftp ( client ) ; return client ; } | Opens a FTP Connection |
23,482 | private AFTPClient actionClose ( ) throws PageException { FTPConnection conn = _createConnection ( ) ; AFTPClient client = pool . remove ( conn ) ; Struct cfftp = writeCfftp ( client ) ; cfftp . setEL ( "succeeded" , Caster . toBoolean ( client != null ) ) ; return client ; } | close a existing ftp connection |
23,483 | private Struct writeCfftp ( AFTPClient client ) throws PageException { Struct cfftp = new StructImpl ( ) ; if ( result == null ) pageContext . variablesScope ( ) . setEL ( CFFTP , cfftp ) ; else pageContext . setVariable ( result , cfftp ) ; if ( client == null ) { cfftp . setEL ( SUCCEEDED , Boolean . FALSE ) ; cfftp . setEL ( ERROR_CODE , new Double ( - 1 ) ) ; cfftp . setEL ( ERROR_TEXT , "" ) ; cfftp . setEL ( RETURN_VALUE , "" ) ; return cfftp ; } int repCode = client . getReplyCode ( ) ; String repStr = client . getReplyString ( ) ; cfftp . setEL ( ERROR_CODE , new Double ( repCode ) ) ; cfftp . setEL ( ERROR_TEXT , repStr ) ; cfftp . setEL ( SUCCEEDED , Caster . toBoolean ( client . isPositiveCompletion ( ) ) ) ; cfftp . setEL ( RETURN_VALUE , repStr ) ; return cfftp ; } | writes cfftp variable |
23,484 | private boolean checkCompletion ( AFTPClient client ) throws ApplicationException { boolean isPositiveCompletion = client . isPositiveCompletion ( ) ; if ( isPositiveCompletion ) return false ; if ( count ++ < retrycount ) return true ; if ( stoponerror ) { throw new lucee . runtime . exp . FTPException ( action , client ) ; } return false ; } | check completion status of the client |
23,485 | private int getType ( Resource file ) { if ( transferMode == FTPConstant . TRANSFER_MODE_BINARY ) return AFTPClient . FILE_TYPE_BINARY ; else if ( transferMode == FTPConstant . TRANSFER_MODE_ASCCI ) return AFTPClient . FILE_TYPE_TEXT ; else { String ext = ResourceUtil . getExtension ( file , null ) ; if ( ext == null || ListUtil . listContainsNoCase ( ASCIIExtensionList , ext , ";" , true , false ) == - 1 ) return AFTPClient . FILE_TYPE_BINARY ; return AFTPClient . FILE_TYPE_TEXT ; } } | get FTP . ... _FILE_TYPE |
23,486 | public Pair addElseIf ( ExprBoolean condition , Statement body , Position start , Position end ) { Pair pair ; ifs . add ( pair = new Pair ( condition , body , start , end ) ) ; body . setParent ( this ) ; return pair ; } | adds a else statement |
23,487 | public Pair setElse ( Statement body , Position start , Position end ) { _else = new Pair ( null , body , start , end ) ; body . setParent ( this ) ; return _else ; } | sets the else Block of the condition |
23,488 | public static void copy ( Struct source , Struct target , boolean overwrite ) { Iterator < Entry < Key , Object > > it = source . entryIterator ( ) ; Entry < Key , Object > e ; while ( it . hasNext ( ) ) { e = it . next ( ) ; if ( overwrite || ! target . containsKey ( e . getKey ( ) ) ) target . setEL ( e . getKey ( ) , e . getValue ( ) ) ; } } | copy data from source struct to target struct |
23,489 | public static java . util . Collection < ? > values ( Struct sct ) { ArrayList < Object > arr = new ArrayList < Object > ( ) ; Iterator < Object > it = sct . valueIterator ( ) ; while ( it . hasNext ( ) ) { arr . add ( it . next ( ) ) ; } return arr ; } | create a value return value out of a struct |
23,490 | public static long sizeOf ( Struct sct ) { Iterator < Entry < Key , Object > > it = sct . entryIterator ( ) ; Entry < Key , Object > e ; long size = 0 ; while ( it . hasNext ( ) ) { e = it . next ( ) ; size += SizeOf . size ( e . getKey ( ) ) ; size += SizeOf . size ( e . getValue ( ) ) ; } return size ; } | return the size of given struct size of values + keys |
23,491 | public static void removeValue ( Map map , Object value ) { Iterator it = map . entrySet ( ) . iterator ( ) ; Map . Entry entry ; while ( it . hasNext ( ) ) { entry = ( Entry ) it . next ( ) ; if ( entry . getValue ( ) == value ) it . remove ( ) ; } } | remove every entry hat has this value |
23,492 | private void writeOutTypeNormal ( BytecodeContext bc ) throws TransformerException { ParseBodyVisitor pbv = new ParseBodyVisitor ( ) ; pbv . visitBegin ( bc ) ; getBody ( ) . writeOut ( bc ) ; pbv . visitEnd ( bc ) ; } | write out normal query |
23,493 | public void setQuery ( String query ) throws PageException { this . query = Caster . toQuery ( pageContext . getVariable ( query ) ) ; } | set the value query Name of the cfquery from which to draw data . |
23,494 | public Reflections merge ( final Reflections reflections ) { if ( reflections . store != null ) { for ( String indexName : reflections . store . keySet ( ) ) { Multimap < String , String > index = reflections . store . get ( indexName ) ; for ( String key : index . keySet ( ) ) { for ( String string : index . get ( key ) ) { store . getOrCreate ( indexName ) . put ( key , string ) ; } } } } return this ; } | merges a Reflections instance metadata into this instance |
23,495 | public Set < Method > getMethodsReturn ( Class returnType ) { return getMethodsFromDescriptors ( store . get ( index ( MethodParameterScanner . class ) , names ( returnType ) ) , loaders ( ) ) ; } | get methods with return type match given type |
23,496 | public Set < Method > getMethodsWithAnyParamAnnotated ( Class < ? extends Annotation > annotation ) { return getMethodsFromDescriptors ( store . get ( index ( MethodParameterScanner . class ) , annotation . getName ( ) ) , loaders ( ) ) ; } | get methods with any parameter annotated with given annotation |
23,497 | public Set < Method > getMethodsWithAnyParamAnnotated ( Annotation annotation ) { return filter ( getMethodsWithAnyParamAnnotated ( annotation . annotationType ( ) ) , withAnyParameterAnnotation ( annotation ) ) ; } | get methods with any parameter annotated with given annotation including annotation member values matching |
23,498 | public Set < Constructor > getConstructorsWithAnyParamAnnotated ( Class < ? extends Annotation > annotation ) { return getConstructorsFromDescriptors ( store . get ( index ( MethodParameterScanner . class ) , annotation . getName ( ) ) , loaders ( ) ) ; } | get constructors with any parameter annotated with given annotation |
23,499 | public Set < Constructor > getConstructorsWithAnyParamAnnotated ( Annotation annotation ) { return filter ( getConstructorsWithAnyParamAnnotated ( annotation . annotationType ( ) ) , withAnyParameterAnnotation ( annotation ) ) ; } | get constructors with any parameter annotated with given annotation including annotation member values matching |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.