idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
23,100 | public static MergeResult mergeRevision ( long revision , File directory , String branch , String baseUrl ) throws IOException { CommandLine cmdLine = new CommandLine ( SVN_CMD ) ; cmdLine . addArgument ( CMD_MERGE ) ; addDefaultArguments ( cmdLine , null , null ) ; cmdLine . addArgument ( "-x" ) ; cmdLine . addArgument ( "-uw --ignore-eol-style" ) ; cmdLine . addArgument ( "--accept" ) ; cmdLine . addArgument ( "postpone" ) ; cmdLine . addArgument ( "-c" ) ; cmdLine . addArgument ( Long . toString ( revision ) ) ; cmdLine . addArgument ( baseUrl + branch ) ; try ( InputStream result = ExecutionHelper . getCommandResult ( cmdLine , directory , 0 , 120000 ) ) { String output = extractResult ( result ) ; boolean foundActualMerge = false ; boolean foundConflict = false ; for ( String line : output . split ( "\n" ) ) { if ( line . startsWith ( "--- " ) ) { continue ; } if ( line . length ( ) >= 4 && line . substring ( 0 , 4 ) . contains ( "C" ) ) { foundConflict = true ; log . info ( "Found conflict!" ) ; break ; } else if ( ! line . startsWith ( " U " ) && ! line . startsWith ( " G " ) ) { foundActualMerge = true ; log . info ( "Found actual merge: " + line ) ; } } log . info ( "Svn-Merge reported:\n" + output ) ; if ( foundConflict ) { return MergeResult . Conflicts ; } if ( ! foundActualMerge ) { log . info ( "Only mergeinfo updates found after during merge." ) ; return MergeResult . OnlyMergeInfo ; } } return MergeResult . Normal ; } | Merge the given revision and return true if only mergeinfo changes were done on trunk . |
23,101 | public static String getMergedRevisions ( File directory , String ... branches ) throws IOException { CommandLine cmdLine ; cmdLine = new CommandLine ( SVN_CMD ) ; cmdLine . addArgument ( "propget" ) ; addDefaultArguments ( cmdLine , null , null ) ; cmdLine . addArgument ( "svn:mergeinfo" ) ; StringBuilder MERGED_REVISIONS_BUILD = new StringBuilder ( ) ; try ( InputStream ignoreStr = ExecutionHelper . getCommandResult ( cmdLine , directory , 0 , 120000 ) ) { List < String > lines = IOUtils . readLines ( ignoreStr , "UTF-8" ) ; for ( String line : lines ) { for ( String source : branches ) { if ( line . startsWith ( source + ":" ) ) { log . info ( "Found merged revisions for branch: " + source ) ; MERGED_REVISIONS_BUILD . append ( "," ) . append ( line . substring ( source . length ( ) + 1 ) ) ; break ; } } } } String MERGED_REVISIONS = StringUtils . removeStart ( MERGED_REVISIONS_BUILD . toString ( ) , "," ) ; if ( MERGED_REVISIONS . equals ( "" ) ) { throw new IllegalStateException ( "Could not read merged revision with command " + cmdLine + " in directory " + directory ) ; } List < Long > revList = new ArrayList < > ( ) ; String [ ] revs = MERGED_REVISIONS . split ( "," ) ; for ( String rev : revs ) { if ( rev . contains ( "-" ) ) { String [ ] revRange = rev . split ( "-" ) ; if ( revRange . length != 2 ) { throw new IllegalStateException ( "Expected to have start and end of range, but had: " + rev ) ; } for ( long r = Long . parseLong ( revRange [ 0 ] ) ; r <= Long . parseLong ( revRange [ 1 ] ) ; r ++ ) { revList . add ( r ) ; } } else { rev = StringUtils . removeEnd ( rev , "*" ) ; revList . add ( Long . parseLong ( rev ) ) ; } } return revList . toString ( ) ; } | Retrieve a list of all merged revisions . |
23,102 | public static void revertAll ( File directory ) throws IOException { log . info ( "Reverting SVN Working copy at " + directory ) ; CommandLine cmdLine = new CommandLine ( SVN_CMD ) ; cmdLine . addArgument ( CMD_REVERT ) ; addDefaultArguments ( cmdLine , null , null ) ; cmdLine . addArgument ( OPT_DEPTH ) ; cmdLine . addArgument ( INFINITY ) ; cmdLine . addArgument ( directory . getAbsolutePath ( ) ) ; try ( InputStream result = ExecutionHelper . getCommandResult ( cmdLine , directory , 0 , 120000 ) ) { log . info ( "Svn-RevertAll reported:\n" + extractResult ( result ) ) ; } } | Revert all changes pending in the given SVN Working Copy . |
23,103 | public static void cleanup ( File directory ) throws IOException { log . info ( "Cleaning SVN Working copy at " + directory ) ; CommandLine cmdLine = new CommandLine ( SVN_CMD ) ; cmdLine . addArgument ( "cleanup" ) ; addDefaultArguments ( cmdLine , null , null ) ; try ( InputStream result = ExecutionHelper . getCommandResult ( cmdLine , directory , 0 , 360000 ) ) { log . info ( "Svn-Cleanup reported:\n" + extractResult ( result ) ) ; } } | Run svn cleanup on the given working copy . |
23,104 | public static InputStream checkout ( String url , File directory , String user , String pwd ) throws IOException { if ( ! directory . exists ( ) && ! directory . mkdirs ( ) ) { throw new IOException ( "Could not create new working copy directory at " + directory ) ; } CommandLine cmdLine = new CommandLine ( SVN_CMD ) ; cmdLine . addArgument ( "co" ) ; addDefaultArguments ( cmdLine , user , pwd ) ; cmdLine . addArgument ( url ) ; cmdLine . addArgument ( directory . toString ( ) ) ; return ExecutionHelper . getCommandResult ( cmdLine , directory , - 1 , 2 * 60 * 60 * 1000 ) ; } | Performs a SVN Checkout of the given URL to the given directory |
23,105 | public static void copyBranch ( String base , String branch , long revision , String baseUrl ) throws IOException { log . info ( "Copying branch " + base + AT_REVISION + revision + " to branch " + branch ) ; CommandLine cmdLine = new CommandLine ( SVN_CMD ) ; cmdLine . addArgument ( "cp" ) ; addDefaultArguments ( cmdLine , null , null ) ; if ( revision > 0 ) { cmdLine . addArgument ( "-r" + revision ) ; } cmdLine . addArgument ( "-m" ) ; cmdLine . addArgument ( "Branch automatically created from " + base + ( revision > 0 ? AT_REVISION + revision : "" ) ) ; cmdLine . addArgument ( baseUrl + base ) ; cmdLine . addArgument ( baseUrl + branch ) ; try ( InputStream result = ExecutionHelper . getCommandResult ( cmdLine , new File ( "." ) , 0 , 120000 ) ) { log . info ( "Svn-Copy reported:\n" + extractResult ( result ) ) ; } } | Make a branch by calling the svn cp operation . |
23,106 | public ConfigurationStore getStore ( ) throws ConfigException { if ( store != null ) { return store ; } String uriStr = getConfigUri ( ) ; if ( uriStr == null ) { getPfile ( ) ; String configPname = getConfigPname ( ) ; if ( configPname == null ) { throw new ConfigException ( "Either a uri or property name must be specified" ) ; } uriStr = pfile . getProperty ( configPname ) ; if ( uriStr == null ) { if ( configPname . endsWith ( ".confuri" ) ) { final int lastDotpos = configPname . length ( ) - 8 ; final int pos = configPname . lastIndexOf ( '.' , lastDotpos - 1 ) ; if ( pos > 0 ) { uriStr = configPname . substring ( pos + 1 , lastDotpos ) ; } } } if ( uriStr == null ) { throw new ConfigException ( "No property with name \"" + configPname + "\"" ) ; } } try { URI uri = new URI ( uriStr ) ; String scheme = uri . getScheme ( ) ; if ( scheme == null ) { String path = uri . getPath ( ) ; File f = new File ( path ) ; if ( ! f . isAbsolute ( ) && configBase != null ) { path = configBase + path ; } uri = new URI ( path ) ; scheme = uri . getScheme ( ) ; } if ( ( scheme == null ) || ( scheme . equals ( "file" ) ) ) { String path = uri . getPath ( ) ; if ( getPathSuffix ( ) != null ) { if ( ! path . endsWith ( File . separator ) ) { path += File . separator ; } path += getPathSuffix ( ) + File . separator ; } store = new ConfigurationFileStore ( path ) ; return store ; } throw new ConfigException ( "Unsupported ConfigurationStore: " + uri ) ; } catch ( URISyntaxException use ) { throw new ConfigException ( use ) ; } } | Get a ConfigurationStore based on the uri or property value . |
23,107 | protected String loadOnlyConfig ( final Class < T > cl ) { try { ConfigurationStore cs = getStore ( ) ; List < String > configNames = cs . getConfigs ( ) ; if ( configNames . isEmpty ( ) ) { error ( "No configuration on path " + cs . getLocation ( ) ) ; return "No configuration on path " + cs . getLocation ( ) ; } if ( configNames . size ( ) != 1 ) { error ( "1 and only 1 configuration allowed" ) ; return "1 and only 1 configuration allowed" ; } String configName = configNames . iterator ( ) . next ( ) ; cfg = getConfigInfo ( cs , configName , cl ) ; if ( cfg == null ) { error ( "Unable to read configuration" ) ; return "Unable to read configuration" ; } setConfigName ( configName ) ; return null ; } catch ( Throwable t ) { error ( "Failed to load configuration: " + t . getLocalizedMessage ( ) ) ; error ( t ) ; return "failed" ; } } | Load the configuration if we only expect one and we don t care or know what it s called . |
23,108 | public static StorageConfiguration deserialize ( final File pFile ) throws TTIOException { try { FileReader fileReader = new FileReader ( new File ( pFile , Paths . ConfigBinary . getFile ( ) . getName ( ) ) ) ; JsonReader jsonReader = new JsonReader ( fileReader ) ; jsonReader . beginObject ( ) ; jsonReader . nextName ( ) ; File file = new File ( jsonReader . nextString ( ) ) ; jsonReader . endObject ( ) ; jsonReader . close ( ) ; fileReader . close ( ) ; return new StorageConfiguration ( file ) ; } catch ( IOException ioexc ) { throw new TTIOException ( ioexc ) ; } } | Generate a StorageConfiguration out of a file . |
23,109 | @ ConfInfo ( dontSave = true ) public String getProperty ( final Collection < String > col , final String name ) { String key = name + "=" ; for ( String p : col ) { if ( p . startsWith ( key ) ) { return p . substring ( key . length ( ) ) ; } } return null ; } | Get a property stored as a String name = val |
23,110 | public void removeProperty ( final Collection < String > col , final String name ) { try { String v = getProperty ( col , name ) ; if ( v == null ) { return ; } col . remove ( name + "=" + v ) ; } catch ( Throwable t ) { throw new RuntimeException ( t ) ; } } | Remove a property stored as a String name = val |
23,111 | @ SuppressWarnings ( "unchecked" ) public < L extends List > L setListProperty ( final L list , final String name , final String val ) { removeProperty ( list , name ) ; return addListProperty ( list , name , val ) ; } | Set a property |
23,112 | public void toXml ( final Writer wtr ) throws ConfigException { try { XmlEmit xml = new XmlEmit ( ) ; xml . addNs ( new NameSpace ( ns , "BW" ) , true ) ; xml . startEmit ( wtr ) ; dump ( xml , false ) ; xml . flush ( ) ; } catch ( ConfigException cfe ) { throw cfe ; } catch ( Throwable t ) { throw new ConfigException ( t ) ; } } | Output to a writer |
23,113 | public ConfigBase fromXml ( final InputStream is , final Class cl ) throws ConfigException { try { return fromXml ( parseXml ( is ) , cl ) ; } catch ( final ConfigException ce ) { throw ce ; } catch ( final Throwable t ) { throw new ConfigException ( t ) ; } } | XML root element must have type attribute if cl is null |
23,114 | public ConfigBase fromXml ( final Element rootEl , final Class cl ) throws ConfigException { try { final ConfigBase cb = ( ConfigBase ) getObject ( rootEl , cl ) ; if ( cb == null ) { return null ; } for ( final Element el : XmlUtil . getElementsArray ( rootEl ) ) { populate ( el , cb , null , null ) ; } return cb ; } catch ( final ConfigException ce ) { throw ce ; } catch ( final Throwable t ) { throw new ConfigException ( t ) ; } } | XML root element must have type attribute |
23,115 | public void setPath ( final String ideal , final String actual ) { synchronized ( transformers ) { pathMap . put ( ideal , actual ) ; } } | Set ideal to actual mapping . |
23,116 | public static void initLogging ( ) throws IOException { sendCommonsLogToJDKLog ( ) ; try ( InputStream resource = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( "logging.properties" ) ) { if ( resource != null ) { try { LogManager . getLogManager ( ) . readConfiguration ( resource ) ; } finally { resource . close ( ) ; } } Logger log = Logger . getLogger ( "" ) ; for ( Handler handler : log . getHandlers ( ) ) { handler . setFormatter ( new DefaultFormatter ( ) ) ; } if ( resource == null ) { throw new IOException ( "Did not find a file 'logging.properties' in the classpath" ) ; } } } | Initialize Logging from a file logging . properties which needs to be found in the classpath . |
23,117 | public void add ( final ITreeData paramNodeX , final ITreeData paramNodeY ) throws TTIOException { mMapping . put ( paramNodeX , paramNodeY ) ; mReverseMapping . put ( paramNodeY , paramNodeX ) ; updateSubtreeMap ( paramNodeX , mRtxNew ) ; updateSubtreeMap ( paramNodeY , mRtxOld ) ; } | Adds the matching x - > y . |
23,118 | public long containedChildren ( final ITreeData paramNodeX , final ITreeData paramNodeY ) throws TTIOException { assert paramNodeX != null ; assert paramNodeY != null ; long retVal = 0 ; mRtxOld . moveTo ( paramNodeX . getDataKey ( ) ) ; for ( final AbsAxis axis = new DescendantAxis ( mRtxOld , true ) ; axis . hasNext ( ) ; axis . next ( ) ) { retVal += mIsInSubtree . get ( paramNodeY , partner ( mRtxOld . getNode ( ) ) ) ? 1 : 0 ; } return retVal ; } | Counts the number of child nodes in the subtrees of x and y that are also in the matching . |
23,119 | public static List < String > fixPath ( final String path ) throws ServletException { if ( path == null ) { return null ; } String decoded ; try { decoded = URLDecoder . decode ( path , "UTF8" ) ; } catch ( Throwable t ) { throw new ServletException ( "bad path: " + path ) ; } if ( decoded == null ) { return ( null ) ; } if ( decoded . indexOf ( '\\' ) >= 0 ) { decoded = decoded . replace ( '\\' , '/' ) ; } if ( ! decoded . startsWith ( "/" ) ) { decoded = "/" + decoded ; } while ( decoded . contains ( "//" ) ) { decoded = decoded . replaceAll ( "//" , "/" ) ; } final StringTokenizer st = new StringTokenizer ( decoded , "/" ) ; ArrayList < String > al = new ArrayList < String > ( ) ; while ( st . hasMoreTokens ( ) ) { String s = st . nextToken ( ) ; if ( s . equals ( "." ) ) { } else if ( s . equals ( ".." ) ) { if ( al . size ( ) == 0 ) { return null ; } al . remove ( al . size ( ) - 1 ) ; } else { al . add ( s ) ; } } return al ; } | Return a path broken into its elements after . and .. are removed . If the parameter path attempts to go above the root we return null . |
23,120 | protected Object readJson ( final InputStream is , final Class cl , final HttpServletResponse resp ) throws ServletException { if ( is == null ) { return null ; } try { return getMapper ( ) . readValue ( is , cl ) ; } catch ( Throwable t ) { resp . setStatus ( HttpServletResponse . SC_INTERNAL_SERVER_ERROR ) ; if ( debug ( ) ) { error ( t ) ; } throw new ServletException ( t ) ; } } | Parse the request body and return the object . |
23,121 | public static String timeToReadable ( long millis , String suffix ) { StringBuilder builder = new StringBuilder ( ) ; boolean haveDays = false ; if ( millis > ONE_DAY ) { millis = handleTime ( builder , millis , ONE_DAY , "day" , "s" ) ; haveDays = true ; } boolean haveHours = false ; if ( millis >= ONE_HOUR ) { millis = handleTime ( builder , millis , ONE_HOUR , "h" , "" ) ; haveHours = true ; } if ( ( ! haveDays || ! haveHours ) && millis >= ONE_MINUTE ) { millis = handleTime ( builder , millis , ONE_MINUTE , "min" , "" ) ; } if ( ! haveDays && ! haveHours && millis >= ONE_SECOND ) { handleTime ( builder , millis , ONE_SECOND , "s" , "" ) ; } if ( builder . length ( ) > 0 ) { builder . setLength ( builder . length ( ) - 2 ) ; builder . append ( suffix ) ; } return builder . toString ( ) ; } | Format the given number of milliseconds as readable string optionally appending a suffix . |
23,122 | public static synchronized XMLEventReader createFileReader ( final File paramFile ) throws IOException , XMLStreamException { final XMLInputFactory factory = XMLInputFactory . newInstance ( ) ; factory . setProperty ( XMLInputFactory . SUPPORT_DTD , false ) ; final InputStream in = new FileInputStream ( paramFile ) ; return factory . createXMLEventReader ( in ) ; } | Create a new StAX reader on a file . |
23,123 | public static synchronized XMLEventReader createStringReader ( final String paramString ) throws IOException , XMLStreamException { final XMLInputFactory factory = XMLInputFactory . newInstance ( ) ; factory . setProperty ( XMLInputFactory . SUPPORT_DTD , false ) ; final InputStream in = new ByteArrayInputStream ( paramString . getBytes ( ) ) ; return factory . createXMLEventReader ( in ) ; } | Create a new StAX reader on a string . |
23,124 | public String simpleGet ( String url ) throws IOException { final AtomicReference < String > str = new AtomicReference < > ( ) ; simpleGetInternal ( url , inputStream -> { try { str . set ( IOUtils . toString ( inputStream , "UTF-8" ) ) ; } catch ( IOException e ) { throw new IllegalStateException ( e ) ; } } , null ) ; return str . get ( ) ; } | Perform a simple get - operation and return the resulting String . |
23,125 | public byte [ ] simpleGetBytes ( String url ) throws IOException { final AtomicReference < byte [ ] > bytes = new AtomicReference < > ( ) ; simpleGetInternal ( url , inputStream -> { try { bytes . set ( IOUtils . toByteArray ( inputStream ) ) ; } catch ( IOException e ) { throw new IllegalStateException ( e ) ; } } , null ) ; return bytes . get ( ) ; } | Perform a simple get - operation and return the resulting byte - array . |
23,126 | public void simpleGet ( String url , Consumer < InputStream > consumer ) throws IOException { simpleGetInternal ( url , consumer , null ) ; } | Perform a simple get - operation and passes the resulting InputStream to the given Consumer |
23,127 | public static String retrieveData ( String url , String user , String password , int timeoutMs ) throws IOException { try ( HttpClientWrapper wrapper = new HttpClientWrapper ( user , password , timeoutMs ) ) { return wrapper . simpleGet ( url ) ; } } | Small helper method to simply query the URL without password and return the resulting data . |
23,128 | public static HttpEntity checkAndFetch ( HttpResponse response , String url ) throws IOException { int statusCode = response . getStatusLine ( ) . getStatusCode ( ) ; if ( statusCode > 206 ) { String msg = "Had HTTP StatusCode " + statusCode + " for request: " + url + ", response: " + response . getStatusLine ( ) . getReasonPhrase ( ) + "\n" + StringUtils . abbreviate ( IOUtils . toString ( response . getEntity ( ) . getContent ( ) , "UTF-8" ) , 1024 ) ; log . warning ( msg ) ; throw new IOException ( msg ) ; } return response . getEntity ( ) ; } | Helper method to check the status code of the response and throw an IOException if it is an error or moved state . |
23,129 | public void createResource ( final InputStream inputStream , final String resourceName ) throws JaxRxException { synchronized ( resourceName ) { if ( inputStream == null ) { throw new JaxRxException ( 400 , "Bad user request" ) ; } else { try { shred ( inputStream , resourceName ) ; } catch ( final TTException exce ) { throw new JaxRxException ( exce ) ; } } } } | This method is responsible to create a new database . |
23,130 | public void add ( final InputStream input , final String resource ) throws JaxRxException { synchronized ( resource ) { try { shred ( input , resource ) ; } catch ( final TTException exce ) { throw new JaxRxException ( exce ) ; } } } | This method is responsible to add a new XML document to a collection . |
23,131 | public void deleteResource ( final String resourceName ) throws WebApplicationException { synchronized ( resourceName ) { try { mDatabase . truncateResource ( new SessionConfiguration ( resourceName , null ) ) ; } catch ( TTException e ) { throw new WebApplicationException ( e ) ; } } } | This method is responsible to delete an existing database . |
23,132 | public long getLastRevision ( final String resourceName ) throws JaxRxException , TTException { long lastRevision ; if ( mDatabase . existsResource ( resourceName ) ) { ISession session = null ; try { session = mDatabase . getSession ( new SessionConfiguration ( resourceName , StandardSettings . KEY ) ) ; lastRevision = session . getMostRecentVersion ( ) ; } catch ( final Exception globExcep ) { throw new JaxRxException ( globExcep ) ; } finally { session . close ( ) ; } } else { throw new JaxRxException ( 404 , "Resource not found" ) ; } return lastRevision ; } | This method reads the existing database and offers the last revision id of the database |
23,133 | private void serializIt ( final String resource , final Long revision , final OutputStream output , final boolean nodeid ) throws JaxRxException , TTException { ISession session = null ; try { session = mDatabase . getSession ( new SessionConfiguration ( resource , StandardSettings . KEY ) ) ; final XMLSerializerBuilder builder ; if ( revision == null ) builder = new XMLSerializerBuilder ( session , output ) ; else builder = new XMLSerializerBuilder ( session , output , revision ) ; builder . setREST ( nodeid ) ; builder . setID ( nodeid ) ; builder . setDeclaration ( false ) ; final XMLSerializer serializer = builder . build ( ) ; serializer . call ( ) ; } catch ( final Exception exce ) { throw new JaxRxException ( exce ) ; } finally { WorkerHelper . closeRTX ( null , session ) ; } } | The XML serializer to a given tnk file . |
23,134 | public void revertToRevision ( final String resourceName , final long backToRevision ) throws JaxRxException , TTException { ISession session = null ; INodeWriteTrx wtx = null ; boolean abort = false ; try { session = mDatabase . getSession ( new SessionConfiguration ( resourceName , StandardSettings . KEY ) ) ; wtx = new NodeWriteTrx ( session , session . beginBucketWtx ( ) , HashKind . Rolling ) ; wtx . revertTo ( backToRevision ) ; wtx . commit ( ) ; } catch ( final TTException exce ) { abort = true ; throw new JaxRxException ( exce ) ; } finally { WorkerHelper . closeWTX ( abort , wtx , session ) ; } } | This method reverts the latest revision data to the requested . |
23,135 | private String discover ( final String url ) throws TimezonesException { String realUrl ; try { new URL ( url ) ; realUrl = url ; } catch ( final Throwable t ) { realUrl = "https://" + url + "/.well-known/timezone" ; } for ( int redirects = 0 ; redirects < 10 ; redirects ++ ) { try ( CloseableHttpResponse hresp = doCall ( realUrl , "capabilities" , null , null ) ) { if ( ( status == HttpServletResponse . SC_MOVED_PERMANENTLY ) || ( status == HttpServletResponse . SC_MOVED_TEMPORARILY ) || ( status == HttpServletResponse . SC_TEMPORARY_REDIRECT ) ) { final String newLoc = HttpUtil . getFirstHeaderValue ( hresp , "location" ) ; if ( newLoc != null ) { if ( debug ( ) ) { debug ( "Got redirected to " + newLoc + " from " + url ) ; } final int qpos = newLoc . indexOf ( "?" ) ; if ( qpos < 0 ) { realUrl = newLoc ; } else { realUrl = newLoc . substring ( 0 , qpos ) ; } continue ; } } if ( status != HttpServletResponse . SC_OK ) { error ( "================================================" ) ; error ( "================================================" ) ; error ( "================================================" ) ; error ( "Got response " + status + ", from " + realUrl ) ; error ( "================================================" ) ; error ( "================================================" ) ; error ( "================================================" ) ; throw new TimezonesException ( TimezonesException . noPrimary , "Got response " + status + ", from " + realUrl ) ; } try { capabilities = om . readValue ( hresp . getEntity ( ) . getContent ( ) , CapabilitiesType . class ) ; } catch ( final Throwable t ) { error ( t ) ; } return realUrl ; } catch ( final TimezonesException tze ) { throw tze ; } catch ( final Throwable t ) { if ( debug ( ) ) { error ( t ) ; } throw new TimezonesException ( t ) ; } } if ( debug ( ) ) { error ( "Too many redirects: Got response " + status + ", from " + realUrl ) ; } throw new TimezonesException ( "Too many redirects on " + realUrl ) ; } | See if we have a url for the service . If not discover the real one . |
23,136 | protected void emitEndElement ( final INodeReadTrx paramRTX ) { try { indent ( ) ; mOut . write ( ECharsForSerializing . OPEN_SLASH . getBytes ( ) ) ; mOut . write ( paramRTX . nameForKey ( ( ( ITreeNameData ) paramRTX . getNode ( ) ) . getNameKey ( ) ) . getBytes ( ) ) ; mOut . write ( ECharsForSerializing . CLOSE . getBytes ( ) ) ; if ( mIndent ) { mOut . write ( ECharsForSerializing . NEWLINE . getBytes ( ) ) ; } } catch ( final IOException exc ) { exc . printStackTrace ( ) ; } } | Emit end element . |
23,137 | private void indent ( ) throws IOException { if ( mIndent ) { for ( int i = 0 ; i < mStack . size ( ) * mIndentSpaces ; i ++ ) { mOut . write ( " " . getBytes ( ) ) ; } } } | Indentation of output . |
23,138 | private void write ( final long mValue ) throws IOException { final int length = ( int ) Math . log10 ( ( double ) mValue ) ; int digit = 0 ; long remainder = mValue ; for ( int i = length ; i >= 0 ; i -- ) { digit = ( byte ) ( remainder / LONG_POWERS [ i ] ) ; mOut . write ( ( byte ) ( digit + ASCII_OFFSET ) ) ; remainder -= digit * LONG_POWERS [ i ] ; } } | Write non - negative non - zero long as UTF - 8 bytes . |
23,139 | public static String isoDate ( final Date val ) { synchronized ( isoDateFormat ) { try { isoDateFormat . setTimeZone ( Timezones . getDefaultTz ( ) ) ; } catch ( TimezonesException tze ) { throw new RuntimeException ( tze ) ; } return isoDateFormat . format ( val ) ; } } | Turn Date into yyyyMMdd |
23,140 | public static String rfcDate ( final Date val ) { synchronized ( rfcDateFormat ) { try { rfcDateFormat . setTimeZone ( Timezones . getDefaultTz ( ) ) ; } catch ( TimezonesException tze ) { throw new RuntimeException ( tze ) ; } return rfcDateFormat . format ( val ) ; } } | Turn Date into yyyy - MM - dd |
23,141 | public static String isoDateTime ( final Date val ) { synchronized ( isoDateTimeFormat ) { try { isoDateTimeFormat . setTimeZone ( Timezones . getDefaultTz ( ) ) ; } catch ( TimezonesException tze ) { throw new RuntimeException ( tze ) ; } return isoDateTimeFormat . format ( val ) ; } } | Turn Date into yyyyMMddTHHmmss |
23,142 | public static String isoDateTime ( final Date val , final TimeZone tz ) { synchronized ( isoDateTimeTZFormat ) { isoDateTimeTZFormat . setTimeZone ( tz ) ; return isoDateTimeTZFormat . format ( val ) ; } } | Turn Date into yyyyMMddTHHmmss for a given timezone |
23,143 | public static Date fromISODate ( final String val ) throws BadDateException { try { synchronized ( isoDateFormat ) { try { isoDateFormat . setTimeZone ( Timezones . getDefaultTz ( ) ) ; } catch ( TimezonesException tze ) { throw new RuntimeException ( tze ) ; } return isoDateFormat . parse ( val ) ; } } catch ( Throwable t ) { throw new BadDateException ( ) ; } } | Get Date from yyyyMMdd |
23,144 | public static Date fromRfcDate ( final String val ) throws BadDateException { try { synchronized ( rfcDateFormat ) { try { rfcDateFormat . setTimeZone ( Timezones . getDefaultTz ( ) ) ; } catch ( TimezonesException tze ) { throw new RuntimeException ( tze ) ; } return rfcDateFormat . parse ( val ) ; } } catch ( Throwable t ) { throw new BadDateException ( ) ; } } | Get Date from yyyy - MM - dd |
23,145 | public static Date fromISODateTime ( final String val ) throws BadDateException { try { synchronized ( isoDateTimeFormat ) { try { isoDateTimeFormat . setTimeZone ( Timezones . getDefaultTz ( ) ) ; } catch ( TimezonesException tze ) { throw new RuntimeException ( tze ) ; } return isoDateTimeFormat . parse ( val ) ; } } catch ( Throwable t ) { throw new BadDateException ( ) ; } } | Get Date from yyyyMMddThhmmss |
23,146 | public static Date fromISODateTime ( final String val , final TimeZone tz ) throws BadDateException { try { synchronized ( isoDateTimeTZFormat ) { isoDateTimeTZFormat . setTimeZone ( tz ) ; return isoDateTimeTZFormat . parse ( val ) ; } } catch ( Throwable t ) { throw new BadDateException ( ) ; } } | Get Date from yyyyMMddThhmmss with timezone |
23,147 | @ SuppressWarnings ( "unused" ) public static Date fromISODateTimeUTC ( final String val , final TimeZone tz ) throws BadDateException { try { synchronized ( isoDateTimeUTCTZFormat ) { isoDateTimeUTCTZFormat . setTimeZone ( tz ) ; return isoDateTimeUTCTZFormat . parse ( val ) ; } } catch ( Throwable t ) { throw new BadDateException ( ) ; } } | Get Date from yyyyMMddThhmmssZ with timezone |
23,148 | public static Date fromISODateTimeUTC ( final String val ) throws BadDateException { try { synchronized ( isoDateTimeUTCFormat ) { return isoDateTimeUTCFormat . parse ( val ) ; } } catch ( Throwable t ) { throw new BadDateException ( ) ; } } | Get Date from yyyyMMddThhmmssZ |
23,149 | public static String fromISODateTimeUTCtoRfc822 ( final String val ) throws BadDateException { try { synchronized ( isoDateTimeUTCFormat ) { return rfc822Date ( isoDateTimeUTCFormat . parse ( val ) ) ; } } catch ( Throwable t ) { throw new BadDateException ( ) ; } } | Get RFC822 form from yyyyMMddThhmmssZ |
23,150 | public static boolean isISODate ( final String val ) throws BadDateException { try { if ( val . length ( ) != 8 ) { return false ; } fromISODate ( val ) ; return true ; } catch ( Throwable t ) { return false ; } } | Check Date is yyyyMMdd |
23,151 | public static boolean isISODateTimeUTC ( final String val ) throws BadDateException { try { if ( val . length ( ) != 16 ) { return false ; } fromISODateTimeUTC ( val ) ; return true ; } catch ( Throwable t ) { return false ; } } | Check Date is yyyyMMddThhmmddZ |
23,152 | public static boolean isISODateTime ( final String val ) throws BadDateException { try { if ( val . length ( ) != 15 ) { return false ; } fromISODateTime ( val ) ; return true ; } catch ( Throwable t ) { return false ; } } | Check Date is yyyyMMddThhmmdd |
23,153 | public static Date fromDate ( final String dt ) throws BadDateException { try { if ( dt == null ) { return null ; } if ( dt . indexOf ( "T" ) > 0 ) { return fromDateTime ( dt ) ; } if ( ! dt . contains ( "-" ) ) { return fromISODate ( dt ) ; } return fromRfcDate ( dt ) ; } catch ( Throwable t ) { throw new BadDateException ( ) ; } } | Return rfc or iso String date or datetime as java Date |
23,154 | public static Date fromDateTime ( final String dt ) throws BadDateException { try { if ( dt == null ) { return null ; } if ( ! dt . contains ( "-" ) ) { return fromISODateTimeUTC ( dt ) ; } return fromRfcDateTimeUTC ( dt ) ; } catch ( Throwable t ) { throw new BadDateException ( ) ; } } | Return rfc or iso String datetime as java Date |
23,155 | public AbstractModule createModule ( ) { return new AbstractModule ( ) { protected void configure ( ) { bind ( IDataFactory . class ) . to ( mDataFacClass ) ; bind ( IMetaEntryFactory . class ) . to ( mMetaFacClass ) ; bind ( IRevisioning . class ) . to ( mRevisioningClass ) ; bind ( IByteHandlerPipeline . class ) . toInstance ( mByteHandler ) ; install ( new FactoryModuleBuilder ( ) . implement ( IBackend . class , mBackend ) . build ( IBackendFactory . class ) ) ; install ( new FactoryModuleBuilder ( ) . build ( IResourceConfigurationFactory . class ) ) ; bind ( Key . class ) . toInstance ( mKey ) ; install ( new FactoryModuleBuilder ( ) . build ( ISessionConfigurationFactory . class ) ) ; } } ; } | Creating an Guice Module based on the parameters set . |
23,156 | public void setProperty ( final String name , final String val ) { if ( props == null ) { props = new Properties ( ) ; } props . setProperty ( name , val ) ; } | Allows applications to provide parameters to methods using this object class |
23,157 | public void startEmit ( final Writer wtr , final String dtd ) throws IOException { this . wtr = wtr ; this . dtd = dtd ; } | Emit any headers dtd and namespace declarations |
23,158 | public void openTag ( final QName tag , final String attrName , final String attrVal ) throws IOException { blanks ( ) ; openTagSameLine ( tag , attrName , attrVal ) ; newline ( ) ; indent += 2 ; } | open with attribute |
23,159 | public void openTagSameLine ( final QName tag , final String attrName , final String attrVal ) throws IOException { lb ( ) ; emitQName ( tag ) ; attribute ( attrName , attrVal ) ; endOpeningTag ( ) ; } | Emit an opening tag ready for nested values . No new line |
23,160 | private void value ( final String val , final String quoteChar ) throws IOException { if ( val == null ) { return ; } String q = quoteChar ; if ( q == null ) { q = "" ; } if ( ( val . indexOf ( '&' ) >= 0 ) || ( val . indexOf ( '<' ) >= 0 ) ) { out ( "<![CDATA[" ) ; out ( q ) ; out ( val ) ; out ( q ) ; out ( "]]>" ) ; } else { out ( q ) ; out ( val ) ; out ( q ) ; } } | Write out a value |
23,161 | public OptionElement parseOptions ( final InputStream is ) throws OptionsException { Reader rdr = null ; try { rdr = new InputStreamReader ( is ) ; DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( false ) ; DocumentBuilder builder = factory . newDocumentBuilder ( ) ; Document doc = builder . parse ( new InputSource ( rdr ) ) ; Element root = doc . getDocumentElement ( ) ; if ( ! root . getNodeName ( ) . equals ( outerTag . getLocalPart ( ) ) ) { throw new OptionsException ( "org.bedework.bad.options" ) ; } OptionElement oel = new OptionElement ( ) ; oel . name = "root" ; doChildren ( oel , root , new Stack < Object > ( ) ) ; return oel ; } catch ( OptionsException ce ) { throw ce ; } catch ( Throwable t ) { throw new OptionsException ( t ) ; } finally { if ( rdr != null ) { try { rdr . close ( ) ; } catch ( Throwable t ) { } } } } | Parse the input stream and return the internal representation . |
23,162 | public void toXml ( final OptionElement root , final OutputStream str ) throws OptionsException { Writer wtr = null ; try { XmlEmit xml = new XmlEmit ( true ) ; wtr = new OutputStreamWriter ( str ) ; xml . startEmit ( wtr ) ; xml . openTag ( outerTag ) ; for ( OptionElement oe : root . getChildren ( ) ) { childToXml ( oe , xml ) ; } xml . closeTag ( outerTag ) ; } catch ( OptionsException ce ) { throw ce ; } catch ( Throwable t ) { throw new OptionsException ( t ) ; } finally { if ( wtr != null ) { try { wtr . close ( ) ; } catch ( Throwable t ) { } } } } | Emit the options as xml . |
23,163 | public Object getProperty ( final String name ) throws OptionsException { Object val = getOptProperty ( name ) ; if ( val == null ) { throw new OptionsException ( "Missing property " + name ) ; } return val ; } | Get required property throw exception if absent |
23,164 | public String getStringProperty ( final String name ) throws OptionsException { Object val = getProperty ( name ) ; if ( ! ( val instanceof String ) ) { throw new OptionsException ( "org.bedework.calenv.bad.option.value" ) ; } return ( String ) val ; } | Return the String value of the named property . |
23,165 | public Collection match ( final String name ) throws OptionsException { if ( useSystemwideValues ) { return match ( optionsRoot , makePathElements ( name ) , - 1 ) ; } return match ( localOptionsRoot , makePathElements ( name ) , - 1 ) ; } | Match for values . |
23,166 | public static String getProperty ( final MessageResources msg , final String pname , final String def ) throws Throwable { String p = msg . getMessage ( pname ) ; if ( p == null ) { return def ; } return p ; } | Return a property value or the default |
23,167 | public static String getReqProperty ( final MessageResources msg , final String pname ) throws Throwable { String p = getProperty ( msg , pname , null ) ; if ( p == null ) { logger . error ( "No definition for property " + pname ) ; throw new Exception ( ": No definition for property " + pname ) ; } return p ; } | Return a required property value |
23,168 | public static boolean getBoolProperty ( final MessageResources msg , final String pname , final boolean def ) throws Throwable { String p = msg . getMessage ( pname ) ; if ( p == null ) { return def ; } return Boolean . valueOf ( p ) ; } | Return a boolean property value or the default |
23,169 | public static int getIntProperty ( final MessageResources msg , final String pname , final int def ) throws Throwable { String p = msg . getMessage ( pname ) ; if ( p == null ) { return def ; } return Integer . valueOf ( p ) ; } | Return an int property value or the default |
23,170 | public static MessageEmit getErrorObj ( final HttpServletRequest request , final String errorObjAttrName ) { if ( errorObjAttrName == null ) { return null ; } HttpSession sess = request . getSession ( false ) ; if ( sess == null ) { logger . error ( "No session!!!!!!!" ) ; return null ; } Object o = sess . getAttribute ( errorObjAttrName ) ; if ( ( o != null ) && ( o instanceof MessageEmit ) ) { return ( MessageEmit ) o ; } return null ; } | Get the existing error object from the session or null . |
23,171 | public static MessageEmit getMessageObj ( final HttpServletRequest request , final String messageObjAttrName ) { if ( messageObjAttrName == null ) { return null ; } HttpSession sess = request . getSession ( false ) ; if ( sess == null ) { logger . error ( "No session!!!!!!!" ) ; return null ; } Object o = sess . getAttribute ( messageObjAttrName ) ; if ( ( o != null ) && ( o instanceof MessageEmit ) ) { return ( MessageEmit ) o ; } return null ; } | Get the existing message object from the session or null . |
23,172 | public static double quickRatio ( final String paramFirst , final String paramSecond ) { if ( paramFirst == null || paramSecond == null ) { return 1 ; } double matches = 0 ; final int x [ ] [ ] = new int [ 256 ] [ ] ; for ( char c : paramSecond . toCharArray ( ) ) { if ( x [ c >> 8 ] == null ) { x [ c >> 8 ] = new int [ 256 ] ; } x [ c >> 8 ] [ c & 0xFF ] ++ ; } for ( char c : paramFirst . toCharArray ( ) ) { final int n = ( x [ c >> 8 ] == null ) ? 0 : x [ c >> 8 ] [ c & 0xFF ] -- ; if ( n > 0 ) { matches ++ ; } } return 2.0 * matches / ( paramFirst . length ( ) + paramSecond . length ( ) ) ; } | Calculates the similarity of two strings . This is done by comparing the frequency each character occures in both strings . |
23,173 | public ObjectName createCustomComponentMBeanName ( final String type , final String name ) { ObjectName result = null ; String tmp = jmxDomainName + ":" + "type=" + sanitizeString ( type ) + ",name=" + sanitizeString ( name ) ; try { result = new ObjectName ( tmp ) ; } catch ( MalformedObjectNameException e ) { error ( "Couldn't create ObjectName from: " + type + " , " + name ) ; } return result ; } | Formulate and return the MBean ObjectName of a custom control MBean |
23,174 | public static ObjectName getSystemObjectName ( final String domainName , final String containerName , final Class theClass ) throws MalformedObjectNameException { String tmp = domainName + ":" + "type=" + theClass . getName ( ) + ",name=" + getRelativeName ( containerName , theClass ) ; return new ObjectName ( tmp ) ; } | Retrieve a System ObjectName |
23,175 | public void unregisterMBean ( final ObjectName name ) throws JMException { if ( ( beanServer != null ) && beanServer . isRegistered ( name ) && registeredMBeanNames . remove ( name ) ) { beanServer . unregisterMBean ( name ) ; } } | Unregister an MBean |
23,176 | public void set ( final T paramOrigin , final T paramDestination , final boolean paramBool ) { assert paramOrigin != null ; assert paramDestination != null ; if ( ! mMap . containsKey ( paramOrigin ) ) { mMap . put ( paramOrigin , new IdentityHashMap < T , Boolean > ( ) ) ; } mMap . get ( paramOrigin ) . put ( paramDestination , paramBool ) ; } | Sets the connection between a and b . |
23,177 | public boolean get ( final T paramOrigin , final T paramDestination ) { assert paramOrigin != null ; assert paramDestination != null ; if ( ! mMap . containsKey ( paramOrigin ) ) { return false ; } final Boolean bool = mMap . get ( paramOrigin ) . get ( paramDestination ) ; return bool != null && bool ; } | Returns whether there is a connection between a and b . Unknown objects do never have a connection . |
23,178 | public void toStringSegment ( final ToString ts ) { ts . append ( "sysCode" , String . valueOf ( getSysCode ( ) ) ) ; ts . append ( "dtstamp" , getDtstamp ( ) ) ; ts . append ( "sequence" , getSequence ( ) ) ; } | Add our stuff to the ToString object |
23,179 | public synchronized byte [ ] toByteArray ( ) { byte [ ] outBuff = new byte [ count ] ; int pos = 0 ; for ( BufferPool . Buffer b : buffers ) { System . arraycopy ( b . buf , 0 , outBuff , pos , b . pos ) ; pos += b . pos ; } return outBuff ; } | Creates a newly allocated byte array . Its size is the current size of this output stream and the valid contents of the buffer have been copied into it . |
23,180 | public void release ( ) throws IOException { for ( BufferPool . Buffer b : buffers ) { PooledBuffers . release ( b ) ; } buffers . clear ( ) ; count = 0 ; } | This really release buffers back to the pool . MUST be called to gain the benefit of pooling . |
23,181 | public static boolean createFolderStructure ( final File pFile , IConfigurationPath [ ] pPaths ) throws TTIOException { boolean returnVal = true ; pFile . mkdirs ( ) ; for ( IConfigurationPath paths : pPaths ) { final File toCreate = new File ( pFile , paths . getFile ( ) . getName ( ) ) ; if ( paths . isFolder ( ) ) { returnVal = toCreate . mkdir ( ) ; } else { try { returnVal = toCreate . createNewFile ( ) ; } catch ( final IOException exc ) { throw new TTIOException ( exc ) ; } } if ( ! returnVal ) { break ; } } return returnVal ; } | Creating a folder structure based on a set of paths given as parameter and returning a boolean determining the success . |
23,182 | public static int compareStructure ( final File pFile , IConfigurationPath [ ] pPaths ) { int existing = 0 ; for ( final IConfigurationPath path : pPaths ) { final File currentFile = new File ( pFile , path . getFile ( ) . getName ( ) ) ; if ( currentFile . exists ( ) ) { existing ++ ; } } return existing - pPaths . length ; } | Checking a structure in a folder to be equal with the data in this enum . |
23,183 | public static synchronized void invokeFullDiff ( final Builder paramBuilder ) throws TTException { checkParams ( paramBuilder ) ; DiffKind . FULL . invoke ( paramBuilder ) ; } | Do a full diff . |
23,184 | public static synchronized void invokeStructuralDiff ( final Builder paramBuilder ) throws TTException { checkParams ( paramBuilder ) ; DiffKind . STRUCTURAL . invoke ( paramBuilder ) ; } | Do a structural diff . |
23,185 | private static void checkParams ( final Builder paramBuilder ) { checkState ( paramBuilder . mSession != null && paramBuilder . mKey >= 0 && paramBuilder . mNewRev >= 0 && paramBuilder . mOldRev >= 0 && paramBuilder . mObservers != null && paramBuilder . mKind != null , "No valid arguments specified!" ) ; checkState ( paramBuilder . mNewRev != paramBuilder . mOldRev && paramBuilder . mNewRev >= paramBuilder . mOldRev , "Revision numbers must not be the same and the new revision must have a greater number than the old revision!" ) ; } | Check parameters for validity and assign global static variables . |
23,186 | public boolean equalsAllBut ( DirRecord that , String [ ] attrIDs ) throws NamingException { if ( attrIDs == null ) throw new NamingException ( "DirectoryRecord: null attrID list" ) ; if ( ! dnEquals ( that ) ) { return false ; } int n = attrIDs . length ; if ( n == 0 ) return true ; Attributes thisAttrs = getAttributes ( ) ; Attributes thatAttrs = that . getAttributes ( ) ; if ( thisAttrs == null ) { if ( thatAttrs == null ) return true ; return false ; } if ( thatAttrs == null ) { return false ; } int sz = thisAttrs . size ( ) ; int thatLeft = sz ; if ( ( sz == 0 ) && ( thatAttrs . size ( ) == 0 ) ) { return true ; } NamingEnumeration ne = thisAttrs . getAll ( ) ; if ( ne == null ) { return false ; } while ( ne . hasMore ( ) ) { Attribute attr = ( Attribute ) ne . next ( ) ; String id = attr . getID ( ) ; boolean present = false ; for ( int i = 0 ; i < attrIDs . length ; i ++ ) { if ( id . equalsIgnoreCase ( attrIDs [ i ] ) ) { present = true ; break ; } } if ( present ) { if ( thatAttrs . get ( id ) != null ) thatLeft -- ; } else { Attribute thatAttr = thatAttrs . get ( id ) ; if ( thatAttr == null ) { return false ; } if ( ! thatAttr . contains ( attr ) ) { return false ; } thatLeft -- ; } } return ( thatLeft == 0 ) ; } | This compares all but the named attributes allbut true = > All must be equal except those on the list |
23,187 | public boolean dnEquals ( DirRecord that ) throws NamingException { if ( that == null ) { throw new NamingException ( "Null record for dnEquals" ) ; } String thisDn = getDn ( ) ; if ( thisDn == null ) { throw new NamingException ( "No dn for this record" ) ; } String thatDn = that . getDn ( ) ; if ( thatDn == null ) { throw new NamingException ( "That record has no dn" ) ; } return ( thisDn . equals ( thatDn ) ) ; } | Check dns for equality |
23,188 | public void addAttr ( String attr , Object val ) throws NamingException { Attribute a = findAttr ( attr ) ; if ( a == null ) { setAttr ( attr , val ) ; } else { a . add ( val ) ; } } | Add the attribute value to the table . If an attribute already exists add it to the end of its values . |
23,189 | public boolean contains ( Attribute attr ) throws NamingException { if ( attr == null ) { return false ; } Attribute recAttr = getAttributes ( ) . get ( attr . getID ( ) ) ; if ( recAttr == null ) { return false ; } NamingEnumeration ne = attr . getAll ( ) ; while ( ne . hasMore ( ) ) { if ( ! recAttr . contains ( ne . next ( ) ) ) { return false ; } } return true ; } | Return true if the record contains all of the values of the given attribute . |
23,190 | public NamingEnumeration attrElements ( String attr ) throws NamingException { Attribute a = findAttr ( attr ) ; if ( a == null ) { return null ; } return a . getAll ( ) ; } | Retrieve an enumeration of the named attribute s values . The behaviour of this enumeration is unspecified if the the attribute s values are added changed or removed while the enumeration is in progress . If the attribute values are ordered the enumeration s items will be ordered . |
23,191 | private void emitEndTag ( ) throws TTIOException { final long nodeKey = mRtx . getNode ( ) . getDataKey ( ) ; mEvent = mFac . createEndElement ( mRtx . getQNameOfCurrentNode ( ) , new NamespaceIterator ( mRtx ) ) ; mRtx . moveTo ( nodeKey ) ; } | Emit end tag . |
23,192 | private void emitNode ( ) throws TTIOException { switch ( mRtx . getNode ( ) . getKind ( ) ) { case ROOT : mEvent = mFac . createStartDocument ( ) ; break ; case ELEMENT : final long key = mRtx . getNode ( ) . getDataKey ( ) ; final QName qName = mRtx . getQNameOfCurrentNode ( ) ; mEvent = mFac . createStartElement ( qName , new AttributeIterator ( mRtx ) , new NamespaceIterator ( mRtx ) ) ; mRtx . moveTo ( key ) ; break ; case TEXT : mEvent = mFac . createCharacters ( mRtx . getValueOfCurrentNode ( ) ) ; break ; default : throw new IllegalStateException ( "Kind not known!" ) ; } } | Emit a node . |
23,193 | private void emit ( ) throws TTIOException { if ( mCloseElements ) { if ( ! mStack . empty ( ) && mStack . peek ( ) != ( ( ITreeStructData ) mRtx . getNode ( ) ) . getLeftSiblingKey ( ) ) { mRtx . moveTo ( mStack . pop ( ) ) ; emitEndTag ( ) ; mRtx . moveTo ( mKey ) ; } else if ( ! mStack . empty ( ) ) { mRtx . moveTo ( mStack . pop ( ) ) ; emitEndTag ( ) ; mRtx . moveTo ( mKey ) ; mCloseElements = false ; mCloseElementsEmitted = true ; } } else { mCloseElementsEmitted = false ; emitNode ( ) ; final long nodeKey = mRtx . getNode ( ) . getDataKey ( ) ; mLastKey = nodeKey ; if ( mRtx . getNode ( ) . getKind ( ) == ELEMENT ) { mStack . push ( nodeKey ) ; } if ( ! ( ( ITreeStructData ) mRtx . getNode ( ) ) . hasFirstChild ( ) && ! ( ( ITreeStructData ) mRtx . getNode ( ) ) . hasRightSibling ( ) ) { mGoUp = true ; moveToNextNode ( ) ; } else if ( mRtx . getNode ( ) . getKind ( ) == ELEMENT && ! ( ( ElementNode ) mRtx . getNode ( ) ) . hasFirstChild ( ) ) { mGoBack = true ; moveToNextNode ( ) ; } } } | Move to node and emit it . |
23,194 | private boolean isBooleanFalse ( ) { if ( getNode ( ) . getDataKey ( ) >= 0 ) { return false ; } else { if ( getNode ( ) . getTypeKey ( ) == NamePageHash . generateHashForString ( "xs:boolean" ) ) { return ! ( Boolean . parseBoolean ( new String ( ( ( ITreeValData ) getNode ( ) ) . getRawValue ( ) ) ) ) ; } else { return false ; } } } | Tests whether current Item is an atomic value with boolean value false . |
23,195 | private String expandString ( ) { final FastStringBuffer fsb = new FastStringBuffer ( FastStringBuffer . SMALL ) ; try { final INodeReadTrx rtx = createRtxAndMove ( ) ; final FilterAxis axis = new FilterAxis ( new DescendantAxis ( rtx ) , rtx , new TextFilter ( rtx ) ) ; while ( axis . hasNext ( ) ) { if ( rtx . getNode ( ) . getKind ( ) == TEXT ) { fsb . append ( rtx . getValueOfCurrentNode ( ) ) ; } axis . next ( ) ; } rtx . close ( ) ; } catch ( final TTException exc ) { LOGGER . error ( exc . toString ( ) ) ; } return fsb . condense ( ) . toString ( ) ; } | Filter text nodes . |
23,196 | public int getTypeAnnotation ( ) { int type = 0 ; if ( nodeKind == ATTRIBUTE ) { type = StandardNames . XS_UNTYPED_ATOMIC ; } else { type = StandardNames . XS_UNTYPED ; } return type ; } | Get the type annotation . |
23,197 | public boolean walk ( OutputHandler outputHandler ) throws IOException { try ( ZipFile zipFile = new ZipFile ( zip ) ) { Enumeration < ? extends ZipEntry > entries = zipFile . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry entry = entries . nextElement ( ) ; File file = new File ( zip , entry . getName ( ) ) ; if ( outputHandler . found ( file , zipFile . getInputStream ( entry ) ) ) { return true ; } if ( ZipUtils . isZip ( entry . getName ( ) ) ) { if ( walkRecursive ( file , zipFile . getInputStream ( entry ) , outputHandler ) ) { return true ; } } } return false ; } } | Run the ZipFileWalker using the given OutputHandler |
23,198 | public void updateConfigInfo ( final HttpServletRequest request , final XSLTConfig xcfg ) throws ServletException { PresentationState ps = getPresentationState ( request ) ; if ( ps == null ) { return ; } if ( xcfg . nextCfg == null ) { xcfg . nextCfg = new XSLTFilterConfigInfo ( ) ; } else { xcfg . cfg . updateFrom ( xcfg . nextCfg ) ; } xcfg . cfg . setAppRoot ( ps . getAppRoot ( ) ) ; xcfg . nextCfg . setAppRoot ( ps . getAppRoot ( ) ) ; if ( ps . getNoXSLTSticky ( ) ) { xcfg . cfg . setDontFilter ( true ) ; xcfg . nextCfg . setDontFilter ( true ) ; } else { xcfg . cfg . setDontFilter ( ps . getNoXSLT ( ) ) ; ps . setNoXSLT ( false ) ; } if ( xcfg . cfg . getDontFilter ( ) ) { return ; } Locale l = request . getLocale ( ) ; String lang = l . getLanguage ( ) ; if ( ( lang == null ) || ( lang . length ( ) == 0 ) ) { lang = xcfg . cfg . getDefaultLang ( ) ; } String country = l . getCountry ( ) ; if ( ( country == null ) || ( country . length ( ) == 0 ) ) { country = xcfg . cfg . getDefaultCountry ( ) ; } xcfg . cfg . setLocaleInfo ( XSLTFilterConfigInfo . makeLocale ( lang , country ) ) ; xcfg . nextCfg . setLocaleInfo ( XSLTFilterConfigInfo . makeLocale ( lang , country ) ) ; String temp = ps . getBrowserType ( ) ; if ( temp != null ) { xcfg . cfg . setBrowserType ( temp ) ; } if ( ! ps . getBrowserTypeSticky ( ) ) { ps . setBrowserType ( null ) ; } else { xcfg . nextCfg . setBrowserType ( temp ) ; } temp = ps . getSkinName ( ) ; if ( temp != null ) { xcfg . cfg . setSkinName ( temp ) ; } if ( ! ps . getSkinNameSticky ( ) ) { ps . setSkinName ( null ) ; } else { xcfg . nextCfg . setSkinName ( temp ) ; } xcfg . cfg . setContentType ( ps . getContentType ( ) ) ; if ( ! ps . getContentTypeSticky ( ) ) { ps . setContentType ( null ) ; } else { xcfg . nextCfg . setContentType ( ps . getContentType ( ) ) ; } xcfg . cfg . setForceReload ( ps . getForceXSLTRefresh ( ) ) ; ps . setForceXSLTRefresh ( false ) ; } | This method can be overridden to allow a subclass to set up ready for a transformation . |
23,199 | protected PresentationState getPresentationState ( HttpServletRequest request ) { String attrName = getPresentationAttrName ( ) ; if ( ( attrName == null ) || ( attrName . equals ( "NONE" ) ) ) { return null ; } Object o = request . getAttribute ( attrName ) ; if ( o == null ) { HttpSession sess = request . getSession ( false ) ; if ( sess == null ) { return null ; } o = sess . getAttribute ( attrName ) ; } if ( o == null ) { return null ; } PresentationState ps = ( PresentationState ) o ; if ( debug ( ) ) { ps . debugDump ( "ConfiguredXSLTFilter" ) ; } return ps ; } | Obtain the presentation state from the session . Override if you want different behaviour . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.