idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
9,700
public static File getMountSource ( Closeable handle ) { if ( handle instanceof MountHandle ) { return MountHandle . class . cast ( handle ) . getMountSource ( ) ; } return null ; }
Return the mount source File for a given mount handle .
9,701
private static VisitorAttributes checkAttributes ( VirtualFileFilter filter , VisitorAttributes attributes ) { if ( filter == null ) { throw MESSAGES . nullArgument ( "filter" ) ; } if ( attributes != null ) { return attributes ; } if ( filter instanceof VirtualFileFilterWithAttributes ) { return ( ( VirtualFileFilterWithAttributes ) filter ) . getAttributes ( ) ; } return null ; }
Check the attributes
9,702
protected String getPathName ( VirtualFile file ) { try { return file . toURI ( ) . toString ( ) ; } catch ( Exception e ) { return file . getPathName ( ) ; } }
Get the path name for the VirtualFile .
9,703
private static MountConfig getMountConfig ( MountOption [ ] mountOptions ) { final MountConfig config = new MountConfig ( ) ; for ( MountOption option : mountOptions ) { option . applyTo ( config ) ; } return config ; }
Creates a MountConfig and applies the provided mount options
9,704
public static boolean addHandle ( VirtualFile owner , Closeable handle ) { RegistryEntry entry = getEntry ( owner ) ; return entry . handles . add ( handle ) ; }
Add handle to owner to be auto closed .
9,705
public static boolean removeHandle ( VirtualFile owner , Closeable handle ) { RegistryEntry entry = getEntry ( owner ) ; return entry . handles . remove ( handle ) ; }
Remove handle from owner .
9,706
static RegistryEntry getEntry ( VirtualFile virtualFile ) { if ( virtualFile == null ) { throw MESSAGES . nullArgument ( "VirutalFile" ) ; } return rootEntry . find ( virtualFile ) ; }
Get the entry from the tree creating the entry if not present .
9,707
public static TempFileProvider create ( final String providerType , final ScheduledExecutorService executor , final boolean cleanExisting ) throws IOException { if ( cleanExisting ) { try { final File possiblyExistingProviderRoot = new File ( TMP_ROOT , providerType ) ; if ( possiblyExistingProviderRoot . exists ( ) ) { final File toBeDeletedProviderRoot = new File ( TMP_ROOT , createTempName ( providerType + "-to-be-deleted-" , "" ) ) ; final boolean renamed = possiblyExistingProviderRoot . renameTo ( toBeDeletedProviderRoot ) ; if ( ! renamed ) { throw new IOException ( "Failed to rename " + possiblyExistingProviderRoot . getAbsolutePath ( ) + " to " + toBeDeletedProviderRoot . getAbsolutePath ( ) ) ; } else { executor . submit ( new DeleteTask ( toBeDeletedProviderRoot , executor ) ) ; } } } catch ( Throwable t ) { VFSLogger . ROOT_LOGGER . failedToCleanExistingContentForTempFileProvider ( providerType ) ; VFSLogger . ROOT_LOGGER . debug ( "Failed to clean existing content for temp file provider of type " + providerType , t ) ; } } final File providerRoot = new File ( TMP_ROOT , providerType ) ; return new TempFileProvider ( createTempDir ( providerType , "" , providerRoot ) , executor ) ; }
Create a temporary file provider for a given type .
9,708
public TempDir createTempDir ( String originalName ) throws IOException { if ( ! open . get ( ) ) { throw VFSMessages . MESSAGES . tempFileProviderClosed ( ) ; } final String name = createTempName ( originalName + "-" , "" ) ; final File f = new File ( providerRoot , name ) ; for ( int i = 0 ; i < RETRIES ; i ++ ) { if ( f . mkdirs ( ) ) { return new TempDir ( this , f ) ; } } throw VFSMessages . MESSAGES . couldNotCreateDirectory ( originalName , RETRIES ) ; }
Create a temp directory into which temporary files may be placed .
9,709
private void openCurrent ( VirtualFile current ) throws IOException { if ( current . isDirectory ( ) ) { currentEntryStream = VFSUtils . emptyStream ( ) ; } else { currentEntryStream = current . openStream ( ) ; } }
Open the current virtual file as the current JarEntry stream .
9,710
public List < Article > get ( String url ) { if ( url . equals ( KEY_FAVORITES ) ) return getFavorites ( ) ; return articleMap . get ( url ) ; }
Looks up the specified URL String from the saved HashMap .
9,711
public void deleteAllFavorites ( ) { long time = System . currentTimeMillis ( ) ; log ( "Deleting all favorites..." ) ; favoriteDatabase . deleteAll ( ) ; log ( "Deleting all favorites took " + ( System . currentTimeMillis ( ) - time ) + "ms" ) ; }
Clears the favorites database .
9,712
private void insert ( String url , List < Article > newArticles ) { if ( ! articleMap . containsKey ( url ) ) articleMap . put ( url , new ArrayList < Article > ( ) ) ; List < Article > articleList = articleMap . get ( url ) ; articleList . addAll ( newArticles ) ; log ( "New size for " + url + " is " + articleList . size ( ) ) ; }
Inserts the passed list into the article map database . This will be cleared once the instance dies .
9,713
private void getRead ( ) { new AsyncTask < Void , Void , Void > ( ) { protected Void doInBackground ( Void ... params ) { int size = mPrefs . getInt ( "READ_ARRAY_SIZE" , 0 ) ; boolean value ; if ( size < 1 ) return null ; for ( int i = 0 , key ; i < size ; i ++ ) { key = mPrefs . getInt ( "READ_ARRAY_KEY_" + i , 0 ) ; value = mPrefs . getBoolean ( "READ_ARRAY_VALUE_" + i , false ) ; readList . put ( key , value ) ; } return null ; } } . executeOnExecutor ( AsyncTask . SERIAL_EXECUTOR ) ; }
Asynchronously loads read data .
9,714
private void writeRead ( ) { new AsyncTask < Void , Void , Void > ( ) { protected Void doInBackground ( Void ... params ) { SharedPreferences . Editor editor = mPrefs . edit ( ) ; int size = readList . size ( ) ; boolean value ; editor . putInt ( "READ_ARRAY_SIZE" , size ) ; for ( int i = 0 , key ; i < size ; i ++ ) { key = readList . keyAt ( i ) ; value = readList . get ( key ) ; editor . putInt ( "READ_ARRAY_KEY_" + i , key ) ; editor . putBoolean ( "READ_ARRAY_VALUE_" + i , value ) ; } editor . commit ( ) ; return null ; } } . executeOnExecutor ( AsyncTask . SERIAL_EXECUTOR ) ; }
Asynchronously saves read data .
9,715
private String pullImageLink ( String encoded ) { try { XmlPullParserFactory factory = XmlPullParserFactory . newInstance ( ) ; XmlPullParser xpp = factory . newPullParser ( ) ; xpp . setInput ( new StringReader ( encoded ) ) ; int eventType = xpp . getEventType ( ) ; while ( eventType != XmlPullParser . END_DOCUMENT ) { if ( eventType == XmlPullParser . START_TAG && "img" . equals ( xpp . getName ( ) ) ) { int count = xpp . getAttributeCount ( ) ; for ( int x = 0 ; x < count ; x ++ ) { if ( xpp . getAttributeName ( x ) . equalsIgnoreCase ( "src" ) ) return pattern . matcher ( xpp . getAttributeValue ( x ) ) . replaceAll ( "" ) ; } } eventType = xpp . next ( ) ; } } catch ( Exception e ) { log ( TAG , "Error pulling image link from description!\n" + e . getMessage ( ) , Log . WARN ) ; } return "" ; }
Pulls an image URL from an encoded String .
9,716
public boolean validate ( URL url ) throws SAXException { String xmlText = null ; try { xmlText = IOUtils . toString ( url . openStream ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } return validate ( xmlText ) ; }
Validate XML text retrieved from URL
9,717
public boolean validate ( String xmlText ) throws SAXException { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; try { DocumentBuilder b = factory . newDocumentBuilder ( ) ; Document document = b . parse ( new ByteArrayInputStream ( xmlText . getBytes ( ) ) ) ; Element root = document . getDocumentElement ( ) ; root . removeAttribute ( "xsi:schemaLocation" ) ; TransformerFactory transFactory = TransformerFactory . newInstance ( ) ; Transformer transformer = transFactory . newTransformer ( ) ; StringWriter buffer = new StringWriter ( ) ; transformer . transform ( new DOMSource ( root ) , new StreamResult ( buffer ) ) ; xmlText = buffer . toString ( ) ; } catch ( ParserConfigurationException e ) { throw new RuntimeException ( e ) ; } catch ( TransformerConfigurationException e ) { throw new RuntimeException ( e ) ; } catch ( TransformerException e ) { throw new RuntimeException ( e ) ; } catch ( SAXException e ) { throw new RuntimeException ( e ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } try { synchronized ( this ) { validator . validate ( new StreamSource ( new ByteArrayInputStream ( xmlText . getBytes ( StandardCharsets . UTF_8 ) ) ) ) ; } } catch ( IOException e ) { throw new RuntimeException ( e ) ; } catch ( SAXException e ) { if ( this . validator . getErrorHandler ( ) != null ) { return false ; } else { throw e ; } } return true ; }
Validate an XML text String against the STIX schema
9,718
public static String getNamespaceURI ( Object obj ) { Package pkg = obj . getClass ( ) . getPackage ( ) ; XmlSchema xmlSchemaAnnotation = pkg . getAnnotation ( XmlSchema . class ) ; return xmlSchemaAnnotation . namespace ( ) ; }
Return the namespace URI from the package for the class of the object .
9,719
public static String getName ( Object obj ) { try { return obj . getClass ( ) . getAnnotation ( XmlRootElement . class ) . name ( ) ; } catch ( NullPointerException e ) { return obj . getClass ( ) . getAnnotation ( XmlType . class ) . name ( ) ; } }
Return the name from the JAXB model object .
9,720
public static QName getQualifiedName ( Object obj ) { return new QName ( STIXSchema . getNamespaceURI ( obj ) , STIXSchema . getName ( obj ) ) ; }
Return the QualifiedNam from the JAXB model object .
9,721
public RequestCreator nextPage ( ) { Request request = data . build ( ) ; String url = request . url ; int page = request . page ; if ( request . search != null ) url += "?s=" + request . search ; Map < String , Integer > pageTracker = singleton . getPageTracker ( ) ; if ( pageTracker . containsKey ( url ) ) page = pageTracker . get ( url ) ; this . data . page ( page + 1 ) ; return this ; }
Loads the next page of the current RSS feed . If no page was previously loaded this will request the first page .
9,722
public static Document toDocument ( JAXBElement < ? > jaxbElement , boolean prettyPrint ) { Document document = null ; try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory . newInstance ( ) ; documentBuilderFactory . setNamespaceAware ( true ) ; documentBuilderFactory . setIgnoringElementContentWhitespace ( true ) ; documentBuilderFactory . isIgnoringComments ( ) ; documentBuilderFactory . setCoalescing ( true ) ; document = documentBuilderFactory . newDocumentBuilder ( ) . newDocument ( ) ; String packName = jaxbElement . getDeclaredType ( ) . getPackage ( ) . getName ( ) ; JAXBContext jaxbContext ; if ( packName . startsWith ( "org.mitre" ) ) { jaxbContext = stixJaxbContext ( ) ; } else { jaxbContext = JAXBContext . newInstance ( packName ) ; } Marshaller marshaller = jaxbContext . createMarshaller ( ) ; marshaller . setProperty ( Marshaller . JAXB_FORMATTED_OUTPUT , prettyPrint ) ; marshaller . setProperty ( Marshaller . JAXB_ENCODING , "UTF-8" ) ; try { marshaller . marshal ( jaxbElement , document ) ; } catch ( JAXBException e ) { QName qualifiedName = new QName ( STIXSchema . getNamespaceURI ( jaxbElement ) , jaxbElement . getClass ( ) . getSimpleName ( ) ) ; @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) JAXBElement root = new JAXBElement ( qualifiedName , jaxbElement . getClass ( ) , jaxbElement ) ; marshaller . marshal ( root , document ) ; } removeUnusedNamespaces ( document ) ; } catch ( ParserConfigurationException e ) { throw new RuntimeException ( e ) ; } catch ( JAXBException e ) { throw new RuntimeException ( e ) ; } return document ; }
Returns a Document for a JAXBElement
9,723
public static String toXMLString ( JAXBElement < ? > jaxbElement , boolean prettyPrint ) { Document document = toDocument ( jaxbElement ) ; return toXMLString ( document , prettyPrint ) ; }
Returns a String for a JAXBElement
9,724
private final static void traverse ( Element element , ElementVisitor visitor ) { visitor . visit ( element ) ; NodeList children = element . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { Node node = children . item ( i ) ; if ( node . getNodeType ( ) != Node . ELEMENT_NODE ) continue ; traverse ( ( Element ) node , visitor ) ; } }
Used to traverse an XML document .
9,725
public static Document toDocument ( String xml ) { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory . newInstance ( ) ; documentBuilderFactory . setNamespaceAware ( true ) ; documentBuilderFactory . setIgnoringElementContentWhitespace ( true ) ; documentBuilderFactory . isIgnoringComments ( ) ; documentBuilderFactory . setCoalescing ( true ) ; DocumentBuilder documentBuilder = documentBuilderFactory . newDocumentBuilder ( ) ; InputSource inputSource = new InputSource ( ) ; inputSource . setCharacterStream ( new StringReader ( xml ) ) ; Document document = documentBuilder . parse ( inputSource ) ; removeUnusedNamespaces ( document ) ; return document ; } catch ( ParserConfigurationException e ) { throw new RuntimeException ( e ) ; } catch ( SAXException e ) { throw new RuntimeException ( e ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Creates a Document from XML String
9,726
public static String stripFormattingfromXMLString ( String xml ) { try { Document document = DocumentUtilities . toDocument ( xml ) ; DOMImplementationRegistry registry = DOMImplementationRegistry . newInstance ( ) ; DOMImplementationLS domImplementationLS = ( DOMImplementationLS ) registry . getDOMImplementation ( "LS" ) ; LSSerializer serializaer = domImplementationLS . createLSSerializer ( ) ; serializaer . getDomConfig ( ) . setParameter ( "format-pretty-print" , Boolean . FALSE ) ; serializaer . getDomConfig ( ) . setParameter ( "xml-declaration" , Boolean . TRUE ) ; LSOutput lsOutput = domImplementationLS . createLSOutput ( ) ; lsOutput . setEncoding ( "UTF-8" ) ; ByteArrayOutputStream byteStream = new ByteArrayOutputStream ( ) ; lsOutput . setByteStream ( byteStream ) ; serializaer . write ( document , lsOutput ) ; return new String ( byteStream . toByteArray ( ) , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } catch ( InstantiationException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( ClassCastException e ) { throw new RuntimeException ( e ) ; } }
Strips formatting from an XML String
9,727
public static PagerDuty create ( String apiKey ) { Retrofit retrofit = new Retrofit . Builder ( ) . baseUrl ( HOST ) . addConverterFactory ( GsonConverterFactory . create ( ) ) . build ( ) ; return create ( apiKey , retrofit ) ; }
Create a new instance using the specified API key .
9,728
public void add ( Article article ) { SQLiteDatabase db = this . getWritableDatabase ( ) ; ContentValues values = new ContentValues ( ) ; values . put ( KEY_TAGS , TextUtils . join ( "_PCX_" , article . getTags ( ) ) ) ; values . put ( KEY_MEDIA_CONTENT , Article . MediaContent . toByteArray ( article . getMediaContent ( ) ) ) ; values . put ( KEY_SOURCE , article . getSource ( ) . toString ( ) ) ; values . put ( KEY_IMAGE , article . getImage ( ) . toString ( ) ) ; values . put ( KEY_TITLE , article . getTitle ( ) ) ; values . put ( KEY_DESCRIPTION , article . getDescription ( ) ) ; values . put ( KEY_CONTENT , article . getContent ( ) ) ; values . put ( KEY_COMMENTS , article . getComments ( ) ) ; values . put ( KEY_AUTHOR , article . getAuthor ( ) ) ; values . put ( KEY_DATE , article . getDate ( ) ) ; values . put ( KEY_ID , article . getId ( ) ) ; db . insert ( TABLE_ARTICLES , null , values ) ; db . close ( ) ; }
Inserts an Article object to this database .
9,729
public void delete ( Article article ) { SQLiteDatabase db = this . getWritableDatabase ( ) ; db . delete ( TABLE_ARTICLES , KEY_ID + " = ?" , new String [ ] { String . valueOf ( article . getId ( ) ) } ) ; db . close ( ) ; }
Removes a specified Article from this database based on its ID value .
9,730
public void deleteAll ( ) { SQLiteDatabase db = this . getWritableDatabase ( ) ; db . delete ( TABLE_ARTICLES , null , null ) ; db . close ( ) ; }
Removes ALL content stored in this database!
9,731
public Article putExtra ( String key , String value ) { this . extras . putString ( key , value ) ; return this ; }
Inserts a given value into a Bundle associated with this Article instance .
9,732
public Article addMediaContent ( MediaContent mediaContent ) { if ( mediaContent == null ) return this ; if ( this . mediaContentVec == null ) this . mediaContentVec = new Vector < > ( ) ; this . mediaContentVec . add ( mediaContent ) ; return this ; }
Adds a single media content item to the list
9,733
public Article removeMediaContent ( MediaContent mediaContent ) { if ( mediaContent == null || this . mediaContentVec == null ) return this ; this . mediaContentVec . remove ( mediaContent ) ; return this ; }
Removes a single media content item from the list
9,734
public boolean markRead ( boolean read ) { if ( PkRSS . getInstance ( ) == null ) return false ; PkRSS . getInstance ( ) . markRead ( id , read ) ; return true ; }
Adds this article s id to the read index .
9,735
public boolean saveFavorite ( boolean favorite ) { if ( PkRSS . getInstance ( ) == null ) return false ; return PkRSS . getInstance ( ) . saveFavorite ( this , favorite ) ; }
Adds this article into the favorites database .
9,736
private boolean handleNode ( String tag , Article article ) { try { if ( xmlParser . next ( ) != XmlPullParser . TEXT ) return false ; if ( tag . equalsIgnoreCase ( "link" ) ) article . setSource ( Uri . parse ( xmlParser . getText ( ) ) ) ; else if ( tag . equalsIgnoreCase ( "title" ) ) article . setTitle ( xmlParser . getText ( ) ) ; else if ( tag . equalsIgnoreCase ( "description" ) ) { String encoded = xmlParser . getText ( ) ; article . setImage ( Uri . parse ( pullImageLink ( encoded ) ) ) ; article . setDescription ( Html . fromHtml ( encoded . replaceAll ( "<img.+?>" , "" ) ) . toString ( ) ) ; } else if ( tag . equalsIgnoreCase ( "content:encoded" ) ) article . setContent ( xmlParser . getText ( ) . replaceAll ( "[<](/)?div[^>]*[>]" , "" ) ) ; else if ( tag . equalsIgnoreCase ( "wfw:commentRss" ) ) article . setComments ( xmlParser . getText ( ) ) ; else if ( tag . equalsIgnoreCase ( "category" ) ) article . setNewTag ( xmlParser . getText ( ) ) ; else if ( tag . equalsIgnoreCase ( "dc:creator" ) ) article . setAuthor ( xmlParser . getText ( ) ) ; else if ( tag . equalsIgnoreCase ( "pubDate" ) ) { article . setDate ( getParsedDate ( xmlParser . getText ( ) ) ) ; } return true ; } catch ( IOException e ) { e . printStackTrace ( ) ; return false ; } catch ( XmlPullParserException e ) { e . printStackTrace ( ) ; return false ; } }
Handles a node from the tag node and assigns it to the correct article value .
9,737
private void handleMediaContent ( String tag , Article article ) { String url = xmlParser . getAttributeValue ( null , "url" ) ; if ( url == null ) { throw new IllegalArgumentException ( "Url argument must not be null" ) ; } Article . MediaContent mc = new Article . MediaContent ( ) ; article . addMediaContent ( mc ) ; mc . setUrl ( url ) ; if ( xmlParser . getAttributeValue ( null , "type" ) != null ) { mc . setType ( xmlParser . getAttributeValue ( null , "type" ) ) ; } if ( xmlParser . getAttributeValue ( null , "fileSize" ) != null ) { mc . setFileSize ( Integer . parseInt ( xmlParser . getAttributeValue ( null , "fileSize" ) ) ) ; } if ( xmlParser . getAttributeValue ( null , "medium" ) != null ) { mc . setMedium ( xmlParser . getAttributeValue ( null , "medium" ) ) ; } if ( xmlParser . getAttributeValue ( null , "isDefault" ) != null ) { mc . setIsDefault ( Boolean . parseBoolean ( xmlParser . getAttributeValue ( null , "isDefault" ) ) ) ; } if ( xmlParser . getAttributeValue ( null , "expression" ) != null ) { mc . setExpression ( xmlParser . getAttributeValue ( null , "expression" ) ) ; } if ( xmlParser . getAttributeValue ( null , "bitrate" ) != null ) { mc . setBitrate ( Integer . parseInt ( xmlParser . getAttributeValue ( null , "bitrate" ) ) ) ; } if ( xmlParser . getAttributeValue ( null , "framerate" ) != null ) { mc . setFramerate ( Integer . parseInt ( xmlParser . getAttributeValue ( null , "framerate" ) ) ) ; } if ( xmlParser . getAttributeValue ( null , "samplingrate" ) != null ) { mc . setSamplingrate ( Integer . parseInt ( xmlParser . getAttributeValue ( null , "samplingrate" ) ) ) ; } if ( xmlParser . getAttributeValue ( null , "channels" ) != null ) { mc . setChannels ( Integer . parseInt ( xmlParser . getAttributeValue ( null , "channels" ) ) ) ; } if ( xmlParser . getAttributeValue ( null , "duration" ) != null ) { mc . setDuration ( Integer . parseInt ( xmlParser . getAttributeValue ( null , "duration" ) ) ) ; } if ( xmlParser . getAttributeValue ( null , "height" ) != null ) { mc . setHeight ( Integer . parseInt ( xmlParser . getAttributeValue ( null , "height" ) ) ) ; } if ( xmlParser . getAttributeValue ( null , "width" ) != null ) { mc . setWidth ( Integer . parseInt ( xmlParser . getAttributeValue ( null , "width" ) ) ) ; } if ( xmlParser . getAttributeValue ( null , "lang" ) != null ) { mc . setLang ( xmlParser . getAttributeValue ( null , "lang" ) ) ; } }
Parses the media content of the entry
9,738
public static boolean deleteDir ( File dir ) { if ( dir != null && dir . isDirectory ( ) ) { String [ ] children = dir . list ( ) ; for ( int i = 0 ; i < children . length ; i ++ ) { if ( ! deleteDir ( new File ( dir , children [ i ] ) ) ) return false ; } } return dir . delete ( ) ; }
Deletes the specified directory . Returns true if successful false if not .
9,739
public static Downloader createDefaultDownloader ( Context context ) { Downloader downloaderInstance = null ; try { Class . forName ( "com.squareup.okhttp.OkHttpClient" ) ; downloaderInstance = new OkHttpDownloader ( context ) ; } catch ( ClassNotFoundException ignored ) { } try { Class . forName ( "okhttp3.OkHttpClient" ) ; downloaderInstance = new OkHttp3Downloader ( context ) ; } catch ( ClassNotFoundException ignored ) { } if ( downloaderInstance == null ) { downloaderInstance = new DefaultDownloader ( context ) ; } Log . d ( TAG , "Downloader is " + downloaderInstance ) ; return downloaderInstance ; }
Creates a Downloader object depending on the dependencies present .
9,740
public void start ( Class < ? extends Easing > clazz , EaseType type , double fromValue , double endValue , int durationMillis , long delayMillis ) { if ( ! mRunning ) { mEasing = createInstance ( clazz ) ; if ( null == mEasing ) { return ; } mMethod = getEasingMethod ( mEasing , type ) ; if ( mMethod == null ) { return ; } mInverted = fromValue > endValue ; if ( mInverted ) { mStartValue = endValue ; mEndValue = fromValue ; } else { mStartValue = fromValue ; mEndValue = endValue ; } mValue = mStartValue ; mDuration = durationMillis ; mBase = SystemClock . uptimeMillis ( ) + delayMillis ; mRunning = true ; mTicker = new Ticker ( ) ; long next = SystemClock . uptimeMillis ( ) + FRAME_TIME + delayMillis ; if ( delayMillis == 0 ) { mEasingCallback . onEasingStarted ( fromValue ) ; } else { mHandler . postAtTime ( new TickerStart ( fromValue ) , mToken , next - FRAME_TIME ) ; } mHandler . postAtTime ( mTicker , mToken , next ) ; } }
Start the easing with a delay
9,741
public static List < Map < String , Object > > mergeLists ( String [ ] names , List < Object > ... lists ) { List < Map < String , Object > > resultList = new ArrayList < Map < String , Object > > ( ) ; if ( lists . length != 0 ) { int expectedSize = lists [ 0 ] . size ( ) ; for ( int i = 1 ; i < lists . length ; i ++ ) { List < Object > list = lists [ i ] ; if ( list . size ( ) != expectedSize ) { throw new IllegalArgumentException ( "All lists and array of names must have the same size!" ) ; } } List < Object > masterList = lists [ 0 ] ; for ( int i = 0 ; i < masterList . size ( ) ; i ++ ) { Map < String , Object > map = new HashMap < String , Object > ( ) ; for ( int j = 0 ; j < lists . length ; j ++ ) { String name = names [ j ] ; List < Object > list = lists [ j ] ; Object value = list . get ( i ) ; map . put ( name , value ) ; } resultList . add ( map ) ; } } return resultList ; }
Merges any number of named lists into a single one containing their combined values . Can be very handy in case of a servlet request which might contain several lists of parameters that you want to iterate over in a combined way .
9,742
private void append ( StringBuilder buffer , char c ) { if ( c == escapeChar ) { if ( escaped || rawOutput ) { buffer . append ( c ) ; } escaped = ! escaped ; } else if ( c == quoteChar ) { if ( escaped ) { buffer . append ( c ) ; escaped = false ; } else { quoted = ! quoted ; if ( rawOutput ) { buffer . append ( c ) ; } } } else { buffer . append ( c ) ; escaped = false ; } }
the heart of it all
9,743
public boolean variablesAvailable ( Map < String , Object > model , String ... vars ) { final TemplateContext context = new TemplateContext ( null , null , null , new ScopedMap ( model ) , modelAdaptor , this , new SilentErrorHandler ( ) , null ) ; for ( String var : vars ) { final IfToken token = new IfToken ( var , false ) ; if ( ! ( Boolean ) token . evaluate ( context ) ) { return false ; } } return true ; }
Checks if all given variables are there and if so that they evaluate to true inside an if .
9,744
@ Deprecated ( ) public synchronized Set < String > getUsedVariables ( String template ) { Template templateImpl = getTemplate ( template , null ) ; return templateImpl . getUsedVariables ( ) ; }
Gets all variables used in the given template .
9,745
public synchronized List < VariableDescription > getUsedVariableDescriptions ( String template ) { Template templateImpl = getTemplate ( template , null ) ; return templateImpl . getUsedVariableDescriptions ( ) ; }
Gets all variables used in the given template as a detailed description .
9,746
public Token pop ( ) { if ( scopes . isEmpty ( ) ) { return null ; } else { Token token = scopes . remove ( scopes . size ( ) - 1 ) ; return token ; } }
Pops a token from the scope stack .
9,747
public Token peek ( ) { if ( scopes . isEmpty ( ) ) { return null ; } else { Token token = scopes . get ( scopes . size ( ) - 1 ) ; return token ; } }
Gets the top element from the stack without removing it .
9,748
public void notifyProcessListener ( Token token , Action action ) { if ( processListener != null ) { processListener . log ( this , token , action ) ; } }
Allows you to send additional notifications of executed processing steps .
9,749
public static String streamToString ( InputStream is , String charsetName ) { try { Reader r = null ; try { r = new BufferedReader ( new InputStreamReader ( is , charsetName ) ) ; return readerToString ( r ) ; } finally { if ( r != null ) { try { r . close ( ) ; } catch ( IOException e ) { } } } } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Transforms a stream into a string .
9,750
public static String resourceToString ( String resourceName , String charsetName ) { InputStream templateStream = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( resourceName ) ; String template = Util . streamToString ( templateStream , "UTF-8" ) ; return template ; }
Loads a stream from the classpath and transforms it into a string .
9,751
public static String readerToString ( Reader reader ) { try { StringBuilder sb = new StringBuilder ( ) ; char [ ] buf = new char [ 1024 ] ; int numRead = 0 ; while ( ( numRead = reader . read ( buf ) ) != - 1 ) { sb . append ( buf , 0 , numRead ) ; } return sb . toString ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Transforms a reader into a string .
9,752
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static List < Object > arrayAsList ( Object value ) { if ( value instanceof List ) { return ( List < Object > ) value ; } List list = null ; if ( value instanceof int [ ] ) { list = new ArrayList ( ) ; int [ ] array = ( int [ ] ) value ; for ( int i : array ) { list . add ( i ) ; } } else if ( value instanceof short [ ] ) { list = new ArrayList ( ) ; short [ ] array = ( short [ ] ) value ; for ( short i : array ) { list . add ( i ) ; } } else if ( value instanceof char [ ] ) { list = new ArrayList ( ) ; char [ ] array = ( char [ ] ) value ; for ( char i : array ) { list . add ( i ) ; } } else if ( value instanceof byte [ ] ) { list = new ArrayList ( ) ; byte [ ] array = ( byte [ ] ) value ; for ( byte i : array ) { list . add ( i ) ; } } else if ( value instanceof long [ ] ) { list = new ArrayList ( ) ; long [ ] array = ( long [ ] ) value ; for ( long i : array ) { list . add ( i ) ; } } else if ( value instanceof double [ ] ) { list = new ArrayList ( ) ; double [ ] array = ( double [ ] ) value ; for ( double i : array ) { list . add ( i ) ; } } else if ( value instanceof float [ ] ) { list = new ArrayList ( ) ; float [ ] array = ( float [ ] ) value ; for ( float i : array ) { list . add ( i ) ; } } else if ( value instanceof boolean [ ] ) { list = new ArrayList ( ) ; boolean [ ] array = ( boolean [ ] ) value ; for ( boolean i : array ) { list . add ( i ) ; } } else if ( value . getClass ( ) . isArray ( ) ) { Object [ ] array = ( Object [ ] ) value ; list = Arrays . asList ( array ) ; } return list ; }
Transforms any array to a matching list
9,753
public static String trimFront ( String input ) { int i = 0 ; while ( i < input . length ( ) && Character . isWhitespace ( input . charAt ( i ) ) ) i ++ ; return input . substring ( i ) ; }
Trims off white space from the beginning of a string .
9,754
public MisplacedClassProcessor getProcessorForName ( String name ) { if ( name == null ) { return getDefaultProcessor ( ) ; } switch ( Strategy . valueOf ( name . toUpperCase ( ) ) ) { case FATAL : return new FatalMisplacedClassProcessor ( ) ; case MOVE : return new MoveMisplacedClassProcessor ( ) ; case OMIT : return new OmitMisplacedClassProcessor ( ) ; case SKIP : return new SkipMisplacedClassProcessor ( ) ; } throw new IllegalArgumentException ( "Unrecognized strategy name \"" + name + "\"." ) ; }
Creates a MisplacedClassProcessor according for the given strategy name .
9,755
public static int safeRead ( final InputStream inputStream , final byte [ ] buffer ) throws IOException { int readBytes = inputStream . read ( buffer ) ; if ( readBytes == - 1 ) { return - 1 ; } if ( readBytes < buffer . length ) { int offset = readBytes ; int left = buffer . length ; left = left - readBytes ; do { try { final int nr = inputStream . read ( buffer , offset , left ) ; if ( nr == - 1 ) { return nr ; } offset += nr ; left -= nr ; } catch ( InterruptedIOException exp ) { } } while ( left > 0 ) ; } return buffer . length ; }
Read a number of bytes from the stream and store it in the buffer and fix the problem with incomplete reads by doing another read if we don t have all of the data yet .
9,756
public static boolean eofIsNext ( final RawPacket rawPacket ) { final ByteBuffer buf = rawPacket . getByteBuffer ( ) ; return ( buf . get ( 0 ) == ( byte ) 0xfe && buf . capacity ( ) < 9 ) ; }
Checks whether the next packet is EOF .
9,757
static RawPacket nextPacket ( final InputStream is ) throws IOException { byte [ ] lengthBuffer = readLengthSeq ( is ) ; int length = ( lengthBuffer [ 0 ] & 0xff ) + ( ( lengthBuffer [ 1 ] & 0xff ) << 8 ) + ( ( lengthBuffer [ 2 ] & 0xff ) << 16 ) ; if ( length == - 1 ) { return null ; } if ( length < 0 ) { throw new IOException ( "Got negative packet size: " + length ) ; } final int packetSeq = lengthBuffer [ 3 ] ; final byte [ ] rawBytes = new byte [ length ] ; final int nr = ReadUtil . safeRead ( is , rawBytes ) ; if ( nr != length ) { throw new IOException ( "EOF. Expected " + length + ", got " + nr ) ; } return new RawPacket ( ByteBuffer . wrap ( rawBytes ) . order ( ByteOrder . LITTLE_ENDIAN ) , packetSeq ) ; }
Get the next packet from the stream
9,758
public boolean execute ( final String query ) throws SQLException { startTimer ( ) ; try { if ( queryResult != null ) { queryResult . close ( ) ; } queryResult = protocol . executeQuery ( queryFactory . createQuery ( query ) ) ; if ( queryResult . getResultSetType ( ) == ResultSetType . SELECT ) { setResultSet ( new DrizzleResultSet ( queryResult , this , getProtocol ( ) ) ) ; return true ; } setUpdateCount ( ( ( ModifyQueryResult ) queryResult ) . getUpdateCount ( ) ) ; return false ; } catch ( QueryException e ) { throw SQLExceptionMapper . get ( e ) ; } finally { stopTimer ( ) ; } }
executes a query .
9,759
public final int writeTo ( final OutputStream os , int offset , int maxWriteSize ) throws IOException { int bytesToWrite = Math . min ( blobReference . getBytes ( ) . length - offset , maxWriteSize ) ; os . write ( blobReference . getBytes ( ) , offset , blobReference . getBytes ( ) . length ) ; return bytesToWrite ; }
Writes the parameter to an outputstream .
9,760
public String readString ( final String charset ) throws IOException { byte ch ; int cnt = 0 ; final byte [ ] byteArrBuff = new byte [ byteBuffer . remaining ( ) ] ; while ( byteBuffer . remaining ( ) > 0 && ( ( ch = byteBuffer . get ( ) ) != 0 ) ) { byteArrBuff [ cnt ++ ] = ch ; } return new String ( byteArrBuff , 0 , cnt ) ; }
Reads a string from the buffer looks for a 0 to end the string
9,761
public ValueObject getValueObject ( final int i ) throws NoSuchColumnException { if ( i < 0 || i > resultSet . get ( rowPointer ) . size ( ) ) { throw new NoSuchColumnException ( "No such column: " + i ) ; } return resultSet . get ( rowPointer ) . get ( i ) ; }
gets the value at position i in the result set . i starts at zero!
9,762
public static String sqlEscapeString ( final String str ) { StringBuilder buffer = new StringBuilder ( str . length ( ) * 2 ) ; boolean neededEscaping = false ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { final char c = str . charAt ( i ) ; if ( needsEscaping ( ( byte ) c ) ) { neededEscaping = true ; buffer . append ( '\\' ) ; } buffer . append ( c ) ; } return neededEscaping ? buffer . toString ( ) : str ; }
escapes the given string new string length is at most twice the length of str
9,763
public static long unpackTime ( final int packedTime ) { final int hours = ( packedTime & MASK_HOURS ) ; final int minutes = ( packedTime & MASK_MINUTES ) >> ( START_BIT_MINUTES ) ; final int seconds = ( packedTime & MASK_SECONDS ) >> ( START_BIT_SECONDS ) ; final int millis = ( packedTime & MASK_MILLISECONDS ) >> ( START_BIT_MILLISECONDS ) ; long returnValue = ( long ) hours * 60 * 60 * 1000 ; returnValue += ( long ) minutes * 60 * 1000 ; returnValue += ( long ) seconds * 1000 ; returnValue += ( long ) millis ; return returnValue ; }
unpacks an integer packed by packTime
9,764
public static boolean isJava5 ( ) { if ( ! java5Determined ) { try { java . util . Arrays . copyOf ( new byte [ 0 ] , 0 ) ; isJava5 = false ; } catch ( java . lang . NoSuchMethodError e ) { isJava5 = true ; } java5Determined = true ; } return isJava5 ; }
Returns if it is a Java version up to Java 5 .
9,765
public void setTime ( final int parameterIndex , final Time x ) throws SQLException { if ( x == null ) { setNull ( parameterIndex , Types . TIME ) ; return ; } setParameter ( parameterIndex , new TimeParameter ( x . getTime ( ) ) ) ; }
Since Drizzle has no TIME datatype time in milliseconds is stored in a packed integer
9,766
private QueryResult createDrizzleQueryResult ( final ResultSetPacket packet ) throws IOException , QueryException { final List < ColumnInformation > columnInformation = new ArrayList < ColumnInformation > ( ) ; for ( int i = 0 ; i < packet . getFieldCount ( ) ; i ++ ) { final RawPacket rawPacket = packetFetcher . getRawPacket ( ) ; final ColumnInformation columnInfo = MySQLFieldPacket . columnInformationFactory ( rawPacket ) ; columnInformation . add ( columnInfo ) ; } packetFetcher . getRawPacket ( ) ; final List < List < ValueObject > > valueObjects = new ArrayList < List < ValueObject > > ( ) ; while ( true ) { final RawPacket rawPacket = packetFetcher . getRawPacket ( ) ; if ( ReadUtil . isErrorPacket ( rawPacket ) ) { ErrorPacket errorPacket = ( ErrorPacket ) ResultPacketFactory . createResultPacket ( rawPacket ) ; checkIfCancelled ( ) ; throw new QueryException ( errorPacket . getMessage ( ) , errorPacket . getErrorNumber ( ) , errorPacket . getSqlState ( ) ) ; } if ( ReadUtil . eofIsNext ( rawPacket ) ) { final EOFPacket eofPacket = ( EOFPacket ) ResultPacketFactory . createResultPacket ( rawPacket ) ; this . hasMoreResults = eofPacket . getStatusFlags ( ) . contains ( EOFPacket . ServerStatus . SERVER_MORE_RESULTS_EXISTS ) ; checkIfCancelled ( ) ; return new DrizzleQueryResult ( columnInformation , valueObjects , eofPacket . getWarningCount ( ) ) ; } if ( getDatabaseType ( ) == SupportedDatabases . MYSQL ) { final MySQLRowPacket rowPacket = new MySQLRowPacket ( rawPacket , columnInformation ) ; valueObjects . add ( rowPacket . getRow ( packetFetcher ) ) ; } else { final DrizzleRowPacket rowPacket = new DrizzleRowPacket ( rawPacket , columnInformation ) ; valueObjects . add ( rowPacket . getRow ( ) ) ; } } }
create a DrizzleQueryResult - precondition is that a result set packet has been read
9,767
public Time getTime ( ) throws ParseException { if ( rawBytes == null ) { return null ; } String rawValue = getString ( ) ; SimpleDateFormat sdf = new SimpleDateFormat ( "HH:mm:ss" ) ; sdf . setLenient ( false ) ; final java . util . Date utilTime = sdf . parse ( rawValue ) ; return new Time ( utilTime . getTime ( ) ) ; }
Since drizzle has no TIME datatype JDBC Time is stored in a packed integer
9,768
public PreparedStatement prepareStatement ( final String sql ) throws SQLException { if ( parameterizedBatchHandlerFactory == null ) { this . parameterizedBatchHandlerFactory = new DefaultParameterizedBatchHandlerFactory ( ) ; } final String strippedQuery = Utils . stripQuery ( sql ) ; return new DrizzlePreparedStatement ( protocol , this , strippedQuery , queryFactory , parameterizedBatchHandlerFactory . get ( strippedQuery , protocol ) ) ; }
creates a new prepared statement . Only client side prepared statement emulation right now .
9,769
public boolean getAutoCommit ( ) throws SQLException { Statement stmt = createStatement ( ) ; ResultSet rs = stmt . executeQuery ( "select @@autocommit" ) ; rs . next ( ) ; boolean autocommit = rs . getBoolean ( 1 ) ; rs . close ( ) ; stmt . close ( ) ; return autocommit ; }
returns true if statements on this connection are auto commited .
9,770
public void close ( ) throws SQLException { if ( isClosed ( ) ) return ; try { this . timeoutExecutor . shutdown ( ) ; protocol . close ( ) ; } catch ( QueryException e ) { throw SQLExceptionMapper . get ( e ) ; } }
close the connection .
9,771
public DatabaseMetaData getMetaData ( ) throws SQLException { return new CommonDatabaseMetaData . Builder ( protocol . getDatabaseType ( ) , this ) . url ( "jdbc:drizzle://" + protocol . getHost ( ) + ":" + protocol . getPort ( ) + "/" + protocol . getDatabase ( ) ) . username ( protocol . getUsername ( ) ) . version ( protocol . getServerVersion ( ) ) . databaseProductName ( protocol . getDatabaseType ( ) . getDatabaseName ( ) ) . build ( ) ; }
returns the meta data about the database .
9,772
public List < RawPacket > startBinlogDump ( final int position , final String logfile ) throws SQLException { try { return this . protocol . startBinlogDump ( position , logfile ) ; } catch ( BinlogDumpException e ) { throw SQLExceptionMapper . getSQLException ( "Could not dump binlog" , e ) ; } }
returns a list of binlog entries .
9,773
protected void addCommandLineArgument ( StringBuilder buffer , String argument , String value ) { if ( ( value != null ) && ( value . length ( ) > 0 ) ) { buffer . append ( argument ) ; buffer . append ( Fax4jExeConstants . SPACE_STR ) ; buffer . append ( Fax4jExeConstants . VALUE_WRAPPER ) ; buffer . append ( value ) ; buffer . append ( Fax4jExeConstants . VALUE_WRAPPER ) ; buffer . append ( Fax4jExeConstants . SPACE_STR ) ; } }
This function adds the given command line argument to the buffer .
9,774
protected String createProcessCommand ( String commandArguments ) { StringBuilder buffer = new StringBuilder ( 500 ) ; buffer . append ( "\"" ) ; buffer . append ( this . fax4jExecutableFileLocation ) ; buffer . append ( "\"" ) ; buffer . append ( Fax4jExeConstants . SPACE_STR ) ; buffer . append ( commandArguments ) ; String command = buffer . toString ( ) ; return command ; }
This function creates and returns the fax4j . exe command .
9,775
protected String createProcessCommandArgumentsForSubmitFaxJob ( FaxJob faxJob ) { String targetAddress = faxJob . getTargetAddress ( ) ; String targetName = faxJob . getTargetName ( ) ; String senderName = faxJob . getSenderName ( ) ; File file = faxJob . getFile ( ) ; String fileName = null ; try { fileName = file . getCanonicalPath ( ) ; } catch ( Exception exception ) { throw new FaxException ( "Unable to extract canonical path from file: " + file , exception ) ; } String documentName = faxJob . getProperty ( WindowsFaxClientSpi . FaxJobExtendedPropertyConstants . DOCUMENT_NAME_PROPERTY_KEY . toString ( ) , null ) ; StringBuilder buffer = new StringBuilder ( ) ; this . addCommandLineArgument ( buffer , Fax4jExeConstants . ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT . toString ( ) , Fax4jExeConstants . SUBMIT_ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT_VALUE . toString ( ) ) ; this . addCommandLineArgument ( buffer , Fax4jExeConstants . SERVER_FAX4J_EXE_COMMAND_LINE_ARGUMENT . toString ( ) , this . faxServerName ) ; this . addCommandLineArgument ( buffer , Fax4jExeConstants . TARGET_ADDRESS_FAX4J_EXE_COMMAND_LINE_ARGUMENT . toString ( ) , targetAddress ) ; this . addCommandLineArgument ( buffer , Fax4jExeConstants . TARGET_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT . toString ( ) , targetName ) ; this . addCommandLineArgument ( buffer , Fax4jExeConstants . SENDER_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT . toString ( ) , senderName ) ; this . addCommandLineArgument ( buffer , Fax4jExeConstants . FILE_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT . toString ( ) , fileName ) ; this . addCommandLineArgument ( buffer , Fax4jExeConstants . DOCUMENT_NAME_FAX4J_EXE_COMMAND_LINE_ARGUMENT . toString ( ) , documentName ) ; String commandArguments = buffer . toString ( ) ; return commandArguments ; }
This function creates and returns the command line arguments for the fax4j external exe when running the submit fax job action .
9,776
protected String createProcessCommandArgumentsForExistingFaxJob ( String faxActionTypeArgument , FaxJob faxJob ) { String faxJobID = faxJob . getID ( ) ; StringBuilder buffer = new StringBuilder ( ) ; this . addCommandLineArgument ( buffer , Fax4jExeConstants . ACTION_FAX4J_EXE_COMMAND_LINE_ARGUMENT . toString ( ) , faxActionTypeArgument ) ; this . addCommandLineArgument ( buffer , Fax4jExeConstants . SERVER_FAX4J_EXE_COMMAND_LINE_ARGUMENT . toString ( ) , this . faxServerName ) ; this . addCommandLineArgument ( buffer , Fax4jExeConstants . FAX_JOB_ID_FAX4J_EXE_COMMAND_LINE_ARGUMENT . toString ( ) , String . valueOf ( faxJobID ) ) ; String commandArguments = buffer . toString ( ) ; return commandArguments ; }
This function creates and returns the command line arguments for the fax4j external exe when running an action on an existing fax job .
9,777
public final synchronized void initialize ( Object flowOwner ) { if ( this . initialized ) { throw new FaxException ( "Vendor policy already initialized." ) ; } if ( flowOwner == null ) { throw new FaxException ( "Flow owner not provided." ) ; } this . initialized = true ; this . vendorPolicyFlowOwner = flowOwner ; this . initializeImpl ( ) ; }
This function initializes the vendor policy .
9,778
protected HTTPClientConfiguration createHTTPClientConfiguration ( ) { CommonHTTPClientConfiguration configuration = new CommonHTTPClientConfiguration ( ) ; configuration . setHostName ( "api.phaxio.com" ) ; configuration . setSSL ( true ) ; configuration . setMethod ( FaxActionType . SUBMIT_FAX_JOB , HTTPMethod . POST ) ; configuration . setMethod ( FaxActionType . CANCEL_FAX_JOB , HTTPMethod . POST ) ; configuration . setMethod ( FaxActionType . GET_FAX_JOB_STATUS , HTTPMethod . POST ) ; return configuration ; }
This function creates and returns the HTTP configuration object .
9,779
public void updateFaxJob ( FaxJob faxJob , HTTPResponse httpResponse , FaxActionType faxActionType ) { String path = this . getPathToResponseData ( faxActionType ) ; String id = this . findValue ( httpResponse , path ) ; if ( id != null ) { faxJob . setID ( id ) ; } }
Updates the fax job based on the data from the HTTP response data .
9,780
public FaxJobStatus getFaxJobStatus ( HTTPResponse httpResponse ) { String path = this . getPathToResponseData ( FaxActionType . GET_FAX_JOB_STATUS ) ; String faxJobStatusStr = this . findValue ( httpResponse , path ) ; FaxJobStatus faxJobStatus = FaxJobStatus . UNKNOWN ; if ( faxJobStatusStr != null ) { faxJobStatus = this . getFaxJobStatusFromStatusString ( faxJobStatusStr ) ; if ( faxJobStatus == null ) { faxJobStatus = FaxJobStatus . UNKNOWN ; } } return faxJobStatus ; }
This function extracts the fax job status from the HTTP response data .
9,781
protected String getVBSFailedLineErrorMessage ( String errorPut ) { String message = "" ; if ( errorPut != null ) { String prefix = ".vbs(" ; int start = errorPut . indexOf ( prefix ) ; if ( start != - 1 ) { start = start + prefix . length ( ) ; int end = errorPut . indexOf ( ", " , start - 1 ) ; if ( end != - 1 ) { String lineNumberStr = errorPut . substring ( start , end ) ; if ( lineNumberStr . length ( ) > 0 ) { int lineNumber = - 1 ; try { lineNumber = Integer . parseInt ( lineNumberStr ) ; } catch ( NumberFormatException exception ) { } if ( lineNumber >= 1 ) { message = " error found at line " + lineNumber + ", " ; } } } } } return message ; }
This function returns the VBS error line for the exception message .
9,782
protected void logEvent ( FaxClientSpiProxyEventType eventType , Method method , Object [ ] arguments , Object output , Throwable throwable ) { int amount = 3 ; int argumentsAmount = 0 ; if ( arguments != null ) { argumentsAmount = arguments . length ; } if ( eventType == FaxClientSpiProxyEventType . POST_EVENT_TYPE ) { amount = amount + 2 ; } Object [ ] logData = new Object [ amount + argumentsAmount ] ; switch ( eventType ) { case PRE_EVENT_TYPE : logData [ 0 ] = "Invoking " ; break ; case POST_EVENT_TYPE : logData [ 0 ] = "Invoked " ; break ; case ERROR_EVENT_TYPE : logData [ 0 ] = "Error while invoking " ; break ; } logData [ 1 ] = method . getName ( ) ; if ( argumentsAmount > 0 ) { logData [ 2 ] = " with data: " ; System . arraycopy ( arguments , 0 , logData , 3 , argumentsAmount ) ; } else { logData [ 2 ] = "" ; } if ( eventType == FaxClientSpiProxyEventType . POST_EVENT_TYPE ) { logData [ 3 + argumentsAmount ] = "\nOutput: " ; logData [ 4 + argumentsAmount ] = output ; } Logger logger = this . getLogger ( ) ; switch ( eventType ) { case PRE_EVENT_TYPE : case POST_EVENT_TYPE : logger . logDebug ( logData , throwable ) ; break ; case ERROR_EVENT_TYPE : logger . logError ( logData , throwable ) ; break ; } }
This function logs the event .
9,783
public final void preMethodInvocation ( Method method , Object [ ] arguments ) { this . logEvent ( FaxClientSpiProxyEventType . PRE_EVENT_TYPE , method , arguments , null , null ) ; }
This function is invoked by the fax client SPI proxy before invoking the method in the fax client SPI itself .
9,784
public final void postMethodInvocation ( Method method , Object [ ] arguments , Object output ) { this . logEvent ( FaxClientSpiProxyEventType . POST_EVENT_TYPE , method , arguments , output , null ) ; }
This function is invoked by the fax client SPI proxy after invoking the method in the fax client SPI itself .
9,785
public final void onMethodInvocationError ( Method method , Object [ ] arguments , Throwable throwable ) { this . logEvent ( FaxClientSpiProxyEventType . ERROR_EVENT_TYPE , method , arguments , null , throwable ) ; }
This function is invoked by the fax client SPI proxy in of an error while invoking the method in the fax client SPI itself .
9,786
public FaxJobPriority getPriority ( ) { int priority = Job . PRIORITY_NORMAL ; try { priority = this . JOB . getPriority ( ) ; } catch ( Exception exception ) { throw new FaxException ( "Error while extracting job priority." , exception ) ; } FaxJobPriority faxJobPriority = null ; switch ( priority ) { case Job . PRIORITY_HIGH : faxJobPriority = FaxJobPriority . HIGH_PRIORITY ; break ; default : faxJobPriority = FaxJobPriority . MEDIUM_PRIORITY ; break ; } return faxJobPriority ; }
This function returns the priority .
9,787
public void setPriority ( FaxJobPriority priority ) { try { if ( priority == FaxJobPriority . HIGH_PRIORITY ) { this . JOB . setPriority ( Job . PRIORITY_HIGH ) ; } else { this . JOB . setPriority ( Job . PRIORITY_NORMAL ) ; } } catch ( Exception exception ) { throw new FaxException ( "Error while setting job priority." , exception ) ; } }
This function sets the priority .
9,788
public String getTargetAddress ( ) { String value = null ; try { value = this . JOB . getDialstring ( ) ; } catch ( Exception exception ) { throw new FaxException ( "Error while extracting job target address." , exception ) ; } return value ; }
This function returns the fax job target address .
9,789
public void setTargetAddress ( String targetAddress ) { try { this . JOB . setDialstring ( targetAddress ) ; } catch ( Exception exception ) { throw new FaxException ( "Error while setting job target address." , exception ) ; } }
This function sets the fax job target address .
9,790
public String getSenderName ( ) { String value = null ; try { value = this . JOB . getFromUser ( ) ; } catch ( Exception exception ) { throw new FaxException ( "Error while extracting job sender name." , exception ) ; } return value ; }
This function returns the fax job sender name .
9,791
public void setSenderName ( String senderName ) { try { this . JOB . setFromUser ( senderName ) ; } catch ( Exception exception ) { throw new FaxException ( "Error while setting job sender name." , exception ) ; } }
This function sets the fax job sender name .
9,792
public void setProperty ( String key , String value ) { try { this . JOB . setProperty ( key , value ) ; } catch ( Exception exception ) { throw new FaxException ( "Error while setting job property." , exception ) ; } }
This function sets the fax job property .
9,793
protected String formatHTTPResource ( HTTPFaxClientSpi faxClientSpi , FaxActionType faxActionType , FaxJob faxJob ) { String resourceTemplate = faxClientSpi . getHTTPResource ( faxActionType ) ; String resource = SpiUtil . formatTemplate ( resourceTemplate , faxJob , SpiUtil . URL_ENCODER , false , false ) ; return resource ; }
This function formats the HTTP resource .
9,794
protected String formatHTTPURLParameters ( HTTPFaxClientSpi faxClientSpi , FaxJob faxJob ) { String urlParametersTemplate = faxClientSpi . getHTTPURLParameters ( ) ; String urlParameters = SpiUtil . formatTemplate ( urlParametersTemplate , faxJob , SpiUtil . URL_ENCODER , false , false ) ; return urlParameters ; }
This function formats the HTTP URL parameters .
9,795
private static void loadProperties ( Properties properties , InputStream inputStream , boolean internal ) { try { properties . load ( inputStream ) ; LibraryConfigurationLoader . closeResource ( inputStream ) ; } catch ( Exception exception ) { LibraryConfigurationLoader . closeResource ( inputStream ) ; String prefix = "External" ; if ( internal ) { prefix = "Internal" ; } throw new FaxException ( prefix + " " + LibraryConfigurationLoader . CONFIGURATION_FILE_NAME + " not found." , exception ) ; } }
This function loads the properties from the input stream to the provided properties object .
9,796
public static Properties readInternalConfiguration ( ) { Properties properties = new Properties ( ) ; ClassLoader classLoader = ReflectionHelper . getThreadContextClassLoader ( ) ; InputStream inputStream = classLoader . getResourceAsStream ( "org/fax4j/" + LibraryConfigurationLoader . CONFIGURATION_FILE_NAME ) ; LibraryConfigurationLoader . loadProperties ( properties , inputStream , true ) ; return properties ; }
This function reads and returns the internal fax4j properties .
9,797
public static Properties readInternalAndExternalConfiguration ( ) { Properties properties = LibraryConfigurationLoader . readInternalConfiguration ( ) ; ClassLoader classLoader = ReflectionHelper . getThreadContextClassLoader ( ) ; InputStream inputStream = classLoader . getResourceAsStream ( LibraryConfigurationLoader . CONFIGURATION_FILE_NAME ) ; if ( inputStream != null ) { LibraryConfigurationLoader . loadProperties ( properties , inputStream , false ) ; } return properties ; }
This function reads and returns the internal and external fax4j properties .
9,798
public boolean implies ( final MqttTopicPermission other ) { if ( other == null ) { return false ; } return implies ( other . getTopic ( ) , other . splitTopic , other . getQos ( ) , other . getActivity ( ) ) ; }
Checks the MqttTopicPermission implies a given MqttTopicPermission
9,799
private boolean topicImplicity ( final String topic , final String [ ] splitTopic ) { try { return topicMatcher . matches ( stripedTopic , this . splitTopic , nonWildCard , endsWithWildCard , rootWildCard , topic , splitTopic ) ; } catch ( InvalidTopicException e ) { return false ; } }
Checks if the topic implies a given MqttTopicPermissions topic