idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
16,700
public void drain ( final HttpClient httpClient , final String path , final boolean gzip ) { if ( ! resendQueue . isEmpty ( ) ) { try { LOGGER . info ( "Attempting to retransmit {} requests" , resendQueue . size ( ) ) ; while ( ! resendQueue . isEmpty ( ) ) { HttpResendQueueItem item = resendQueue . peek ( ) ; try { byte [ ] jsonBytes = item . getJsonBytes ( ) ; httpClient . post ( path , jsonBytes , gzip ) ; resendQueue . remove ( ) ; Threads . sleepQuietly ( 250 , TimeUnit . MILLISECONDS ) ; } catch ( Throwable t ) { item . failed ( ) ; if ( MAX_POST_ATTEMPTS <= item . getNumFailures ( ) ) { resendQueue . remove ( ) ; } throw t ; } } } catch ( Throwable t ) { LOGGER . info ( "Failure retransmitting queued requests" , t ) ; } } }
Drains the resend queue until empty or error
16,701
public int flush ( final LogSender sender ) throws IOException , HttpException { int numSent = 0 ; int maxToSend = queue . size ( ) ; if ( 0 < maxToSend ) { AppIdentity appIdentity = appIdentityService . getAppIdentity ( ) ; while ( numSent < maxToSend ) { int batchSize = Math . min ( maxToSend - numSent , MAX_BATCH ) ; List < LogMsg > batch = new ArrayList < LogMsg > ( batchSize ) ; for ( int i = 0 ; i < batchSize ; ++ i ) { batch . add ( queue . remove ( ) ) ; } LogMsgGroup group = createLogMessageGroup ( batch , platform , logger , envDetail , appIdentity ) ; int httpStatus = sender . send ( group ) ; if ( httpStatus != HttpURLConnection . HTTP_OK ) { throw new HttpException ( httpStatus ) ; } numSent += batchSize ; } } return numSent ; }
Flushes the queue by sending all messages to Stackify
16,702
private String readAndClose ( final InputStream stream ) throws IOException { String contents = null ; if ( stream != null ) { contents = CharStreams . toString ( new InputStreamReader ( new BufferedInputStream ( stream ) , "UTF-8" ) ) ; stream . close ( ) ; } return contents ; }
Reads all remaining contents from the stream and closes it
16,703
public static Properties loadProperties ( final String path ) { if ( path != null ) { try { File file = new File ( path ) ; if ( file . exists ( ) ) { try { Properties p = new Properties ( ) ; p . load ( new FileInputStream ( file ) ) ; return p ; } catch ( Exception e ) { log . error ( "Error loading properties from file: " + path ) ; } } } catch ( Throwable e ) { log . debug ( e . getMessage ( ) , e ) ; } InputStream inputStream = null ; try { inputStream = PropertyUtil . class . getResourceAsStream ( path ) ; if ( inputStream != null ) { try { Properties p = new Properties ( ) ; p . load ( inputStream ) ; return p ; } catch ( Exception e ) { log . error ( "Error loading properties from resource: " + path ) ; } } } catch ( Exception e ) { log . error ( "Error loading properties from resource: " + path ) ; } finally { if ( inputStream != null ) { try { inputStream . close ( ) ; } catch ( Throwable t ) { log . debug ( "Error closing: " + path , t ) ; } } } } return new Properties ( ) ; }
Loads properties with given path - will load as file is able or classpath resource
16,704
public static Map < String , String > read ( final String path ) { Map < String , String > map = new HashMap < String , String > ( ) ; if ( path != null ) { try { Properties p = loadProperties ( path ) ; for ( Object key : p . keySet ( ) ) { String value = p . getProperty ( String . valueOf ( key ) ) ; if ( ( value . startsWith ( "\"" ) && value . endsWith ( "\"" ) ) || ( value . startsWith ( "\'" ) && value . endsWith ( "\'" ) ) ) { value = value . substring ( 1 , value . length ( ) - 1 ) ; } value = value . trim ( ) ; if ( ! value . equals ( "" ) ) { map . put ( String . valueOf ( key ) , value ) ; } } } catch ( Exception e ) { log . error ( e . getMessage ( ) , e ) ; } } return map ; }
Reads properties from file path or classpath
16,705
public static void sleepQuietly ( final long sleepFor , final TimeUnit unit ) { try { Thread . sleep ( unit . toMillis ( sleepFor ) ) ; } catch ( Throwable t ) { } }
Sleeps and eats any exceptions
16,706
public void activate ( final ApiConfiguration apiConfig ) { Preconditions . checkNotNull ( apiConfig ) ; Preconditions . checkNotNull ( apiConfig . getApiUrl ( ) ) ; Preconditions . checkArgument ( ! apiConfig . getApiUrl ( ) . isEmpty ( ) ) ; Preconditions . checkNotNull ( apiConfig . getApiKey ( ) ) ; Preconditions . checkArgument ( ! apiConfig . getApiKey ( ) . isEmpty ( ) ) ; ObjectMapper objectMapper = new ObjectMapper ( ) ; AppIdentityService appIdentityService = new AppIdentityService ( apiConfig , objectMapper ) ; this . collector = new LogCollector ( logger , apiConfig . getEnvDetail ( ) , appIdentityService ) ; LogSender sender = new LogSender ( apiConfig , objectMapper , this . masker , this . skipJson ) ; if ( Boolean . TRUE . equals ( apiConfig . getAllowComDotStackify ( ) ) ) { this . allowComDotStackify = true ; } this . backgroundService = new LogBackgroundService ( collector , sender ) ; this . backgroundService . start ( ) ; }
Activates the appender
16,707
public void append ( final T event ) { if ( backgroundService == null ) { return ; } if ( ! backgroundService . isRunning ( ) ) { return ; } if ( ! allowComDotStackify ) { String className = eventAdapter . getClassName ( event ) ; if ( className != null ) { if ( className . startsWith ( COM_DOT_STACKIFY ) ) { return ; } } } Throwable exception = eventAdapter . getThrowable ( event ) ; StackifyError error = null ; if ( ( exception != null ) || ( eventAdapter . isErrorLevel ( event ) ) ) { StackifyError e = eventAdapter . getStackifyError ( event , exception ) ; if ( errorGovernor . errorShouldBeSent ( e ) ) { error = e ; } } LogMsg logMsg = eventAdapter . getLogMsg ( event , error ) ; collector . addLogMsg ( logMsg ) ; }
Adds the log message to the collector
16,708
private String buildTemplates ( ) { String [ ] templateString = new String [ model . getTemplates ( ) . size ( ) ] ; for ( int i = 0 ; i < ( model . getTemplates ( ) . size ( ) ) ; i ++ ) { String templateLoaded = loadTemplateFile ( model . getTemplates ( ) . get ( i ) ) ; if ( templateLoaded != null ) { templateString [ i ] = templateLoaded ; } } return implode ( templateString , File . pathSeparator ) ; }
Builds the path for the list of templates .
16,709
private String loadTemplateFile ( String templateName ) { String name = templateName . replace ( '.' , '/' ) + ".java" ; InputStream in = SpoonMojoGenerate . class . getClassLoader ( ) . getResourceAsStream ( name ) ; String packageName = templateName . substring ( 0 , templateName . lastIndexOf ( '.' ) ) ; String fileName = templateName . substring ( templateName . lastIndexOf ( '.' ) + 1 ) + ".java" ; try { return TemplateLoader . loadToTmpFolder ( in , packageName , fileName ) . getAbsolutePath ( ) ; } catch ( IOException e ) { LogWrapper . warn ( spoon , String . format ( "Template %s cannot be loaded." , templateName ) , e ) ; return null ; } }
Loads the template file at the path given .
16,710
private Element addRoot ( Document document , Map < ReportBuilderImpl . ReportKey , Object > reportsData ) { Element rootElement = document . createElement ( "project" ) ; if ( reportsData . containsKey ( ReportKey . PROJECT_NAME ) ) { rootElement . setAttribute ( "name" , ( String ) reportsData . get ( ReportKey . PROJECT_NAME ) ) ; } document . appendChild ( rootElement ) ; return rootElement ; }
Adds root element .
16,711
private Element addProcessors ( Document document , Element root , Map < ReportBuilderImpl . ReportKey , Object > reportsData ) { if ( reportsData . containsKey ( ReportKey . PROCESSORS ) ) { Element processors = document . createElement ( "processors" ) ; root . appendChild ( processors ) ; String [ ] tabProcessors = ( String [ ] ) reportsData . get ( ReportKey . PROCESSORS ) ; for ( String processor : tabProcessors ) { Element current = document . createElement ( "processor" ) ; current . appendChild ( document . createTextNode ( processor ) ) ; processors . appendChild ( current ) ; } return processors ; } return null ; }
Adds processors child of root element .
16,712
private Element addElement ( Document document , Element parent , Map < ReportKey , Object > reportsData , ReportKey key , String value ) { if ( reportsData . containsKey ( key ) ) { Element child = document . createElement ( key . name ( ) . toLowerCase ( ) ) ; child . appendChild ( document . createTextNode ( value ) ) ; parent . appendChild ( child ) ; return child ; } return null ; }
Generic method to add a element for a parent element given .
16,713
protected String implode ( String [ ] tabToConcatenate , String pathSeparator ) { final StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < tabToConcatenate . length ; i ++ ) { builder . append ( tabToConcatenate [ i ] ) ; if ( i < tabToConcatenate . length - 1 ) { builder . append ( pathSeparator ) ; } } return builder . toString ( ) ; }
Concatenates a tab in a string with a path separator given .
16,714
public static Uri createUri ( Class < ? extends Model > type , Long id ) { final StringBuilder uri = new StringBuilder ( ) ; uri . append ( "content://" ) ; uri . append ( sAuthority ) ; uri . append ( "/" ) ; uri . append ( Ollie . getTableName ( type ) . toLowerCase ( ) ) ; if ( id != null ) { uri . append ( "/" ) ; uri . append ( id . toString ( ) ) ; } return Uri . parse ( uri . toString ( ) ) ; }
Create a Uri for a model row .
16,715
public static < T extends Model > List < T > processCursor ( Class < T > cls , Cursor cursor ) { final List < T > entities = new ArrayList < T > ( ) ; try { Constructor < T > entityConstructor = cls . getConstructor ( ) ; if ( cursor . moveToFirst ( ) ) { do { T entity = getEntity ( cls , cursor . getLong ( cursor . getColumnIndex ( BaseColumns . _ID ) ) ) ; if ( entity == null ) { entity = entityConstructor . newInstance ( ) ; } entity . load ( cursor ) ; entities . add ( entity ) ; } while ( cursor . moveToNext ( ) ) ; } } catch ( Exception e ) { Log . e ( TAG , "Failed to process cursor." , e ) ; } return entities ; }
Iterate over a cursor and load entities .
16,716
public static < T extends Model > List < T > processAndCloseCursor ( Class < T > cls , Cursor cursor ) { List < T > entities = processCursor ( cls , cursor ) ; cursor . close ( ) ; return entities ; }
Iterate over a cursor and load entities . Closes the cursor when finished .
16,717
static synchronized < T extends Model > void load ( T entity , Cursor cursor ) { sAdapterHolder . getModelAdapter ( entity . getClass ( ) ) . load ( entity , cursor ) ; }
Model adapter methods
16,718
public List < ClasspathResourceVersion > getResourceVersions ( ) throws URISyntaxException , IOException { if ( ! lazyLoadDone ) { if ( isClassFolder ( ) ) { logger . debug ( "\nScanning class folder: " + getUrl ( ) ) ; URI uri = new URI ( getUrl ( ) ) ; Path start = Paths . get ( uri ) ; scanClasspathEntry ( start ) ; } else if ( isJar ( ) ) { logger . debug ( "\nScanning jar: " + getUrl ( ) ) ; URI uri = new URI ( "jar:" + getUrl ( ) ) ; try ( FileSystem jarFS = FileSystems . newFileSystem ( uri , new HashMap < String , String > ( ) ) ) { Path zipInJarPath = jarFS . getPath ( "/" ) ; scanClasspathEntry ( zipInJarPath ) ; } catch ( Exception exc ) { logger . debug ( "Could not scan jar: " + getUrl ( ) + " - reason:" + exc . getMessage ( ) ) ; } } lazyLoadDone = true ; } return resourceVersions ; }
The contents of a jar are only loaded if accessed the first time .
16,719
public CSSStyleSheetImpl merge ( ) { final CSSStyleSheetImpl merged = new CSSStyleSheetImpl ( ) ; final CSSRuleListImpl cssRuleList = new CSSRuleListImpl ( ) ; final Iterator < CSSStyleSheetImpl > it = getCSSStyleSheets ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final CSSStyleSheetImpl cssStyleSheet = it . next ( ) ; final CSSMediaRuleImpl cssMediaRule = new CSSMediaRuleImpl ( merged , null , cssStyleSheet . getMedia ( ) ) ; cssMediaRule . setRuleList ( cssStyleSheet . getCssRules ( ) ) ; cssRuleList . add ( cssMediaRule ) ; } merged . setCssRules ( cssRuleList ) ; merged . setMediaText ( "all" ) ; return merged ; }
Merges all StyleSheets in this list into one .
16,720
public void insertRule ( final String rule , final int index ) throws DOMException { try { final CSSOMParser parser = new CSSOMParser ( ) ; parser . setParentStyleSheet ( this ) ; parser . setErrorHandler ( ThrowCssExceptionErrorHandler . INSTANCE ) ; final AbstractCSSRuleImpl r = parser . parseRule ( rule ) ; if ( r == null ) { throw new DOMExceptionImpl ( DOMException . SYNTAX_ERR , DOMExceptionImpl . SYNTAX_ERROR , "Parsing rule '" + rule + "' failed." ) ; } if ( getCssRules ( ) . getLength ( ) > 0 ) { int msg = - 1 ; if ( r instanceof CSSCharsetRuleImpl ) { if ( index != 0 ) { msg = DOMExceptionImpl . CHARSET_NOT_FIRST ; } else if ( getCssRules ( ) . getRules ( ) . get ( 0 ) instanceof CSSCharsetRuleImpl ) { msg = DOMExceptionImpl . CHARSET_NOT_UNIQUE ; } } else if ( r instanceof CSSImportRuleImpl ) { if ( index <= getCssRules ( ) . getLength ( ) ) { for ( int i = 0 ; i < index ; i ++ ) { final AbstractCSSRuleImpl ri = getCssRules ( ) . getRules ( ) . get ( i ) ; if ( ! ( ri instanceof CSSCharsetRuleImpl ) && ! ( ri instanceof CSSImportRuleImpl ) ) { msg = DOMExceptionImpl . IMPORT_NOT_FIRST ; break ; } } } } else { if ( index <= getCssRules ( ) . getLength ( ) ) { for ( int i = index ; i < getCssRules ( ) . getLength ( ) ; i ++ ) { final AbstractCSSRuleImpl ri = getCssRules ( ) . getRules ( ) . get ( i ) ; if ( ( ri instanceof CSSCharsetRuleImpl ) || ( ri instanceof CSSImportRuleImpl ) ) { msg = DOMExceptionImpl . INSERT_BEFORE_IMPORT ; break ; } } } } if ( msg > - 1 ) { throw new DOMExceptionImpl ( DOMException . HIERARCHY_REQUEST_ERR , msg ) ; } } getCssRules ( ) . insert ( r , index ) ; } catch ( final IndexOutOfBoundsException e ) { throw new DOMExceptionImpl ( DOMException . INDEX_SIZE_ERR , DOMExceptionImpl . INDEX_OUT_OF_BOUNDS , e . getMessage ( ) ) ; } catch ( final CSSException e ) { throw new DOMExceptionImpl ( DOMException . SYNTAX_ERR , DOMExceptionImpl . SYNTAX_ERROR , e . getMessage ( ) ) ; } catch ( final IOException e ) { throw new DOMExceptionImpl ( DOMException . SYNTAX_ERR , DOMExceptionImpl . SYNTAX_ERROR , e . getMessage ( ) ) ; } }
inserts a new rule .
16,721
public void deleteRule ( final int index ) throws DOMException { try { getCssRules ( ) . delete ( index ) ; } catch ( final IndexOutOfBoundsException e ) { throw new DOMExceptionImpl ( DOMException . INDEX_SIZE_ERR , DOMExceptionImpl . INDEX_OUT_OF_BOUNDS , e . getMessage ( ) ) ; } }
delete the rule at the given pos .
16,722
public void setMediaText ( final String mediaText ) { try { final CSSOMParser parser = new CSSOMParser ( ) ; final MediaQueryList sml = parser . parseMedia ( mediaText ) ; media_ = new MediaListImpl ( sml ) ; } catch ( final IOException e ) { } }
Set the media text .
16,723
protected Locator createLocator ( final Token t ) { return new Locator ( getInputSource ( ) . getURI ( ) , t == null ? 0 : t . beginLine , t == null ? 0 : t . beginColumn ) ; }
Returns a new locator for the given token .
16,724
protected String addEscapes ( final String str ) { final StringBuilder sb = new StringBuilder ( ) ; char ch ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { ch = str . charAt ( i ) ; switch ( ch ) { case 0 : continue ; case '\b' : sb . append ( "\\b" ) ; continue ; case '\t' : sb . append ( "\\t" ) ; continue ; case '\n' : sb . append ( "\\n" ) ; continue ; case '\f' : sb . append ( "\\f" ) ; continue ; case '\r' : sb . append ( "\\r" ) ; continue ; case '\"' : sb . append ( "\\\"" ) ; continue ; case '\'' : sb . append ( "\\\'" ) ; continue ; case '\\' : sb . append ( "\\\\" ) ; continue ; default : if ( ch < 0x20 || ch > 0x7e ) { final String s = "0000" + Integer . toString ( ch , 16 ) ; sb . append ( "\\u" + s . substring ( s . length ( ) - 4 , s . length ( ) ) ) ; } else { sb . append ( ch ) ; } continue ; } } return sb . toString ( ) ; }
Escapes some chars in the given string .
16,725
public MediaQueryList parseMedia ( final InputSource source ) throws IOException { source_ = source ; ReInit ( getCharStream ( source ) ) ; final MediaQueryList ml = new MediaQueryList ( ) ; try { mediaList ( ml ) ; } catch ( final ParseException e ) { getErrorHandler ( ) . error ( toCSSParseException ( "invalidMediaList" , e ) ) ; } catch ( final TokenMgrError e ) { getErrorHandler ( ) . error ( toCSSParseException ( e ) ) ; } catch ( final CSSParseException e ) { getErrorHandler ( ) . error ( e ) ; } return ml ; }
Parse the given input source and return the media list .
16,726
protected void handleImportStyle ( final String uri , final MediaQueryList media , final String defaultNamespaceURI , final Locator locator ) { getDocumentHandler ( ) . importStyle ( uri , media , defaultNamespaceURI , locator ) ; }
import style handler .
16,727
protected void handleStartPage ( final String name , final String pseudoPage , final Locator locator ) { getDocumentHandler ( ) . startPage ( name , pseudoPage , locator ) ; }
start page handler .
16,728
protected void handleProperty ( final String name , final LexicalUnit value , final boolean important , final Locator locator ) { getDocumentHandler ( ) . property ( name , value , important , locator ) ; }
property handler .
16,729
protected LexicalUnit functionInternal ( final LexicalUnit prev , final String funct , final LexicalUnit params ) { if ( "counter(" . equalsIgnoreCase ( funct ) ) { return LexicalUnitImpl . createCounter ( prev , params ) ; } else if ( "counters(" . equalsIgnoreCase ( funct ) ) { return LexicalUnitImpl . createCounters ( prev , params ) ; } else if ( "attr(" . equalsIgnoreCase ( funct ) ) { return LexicalUnitImpl . createAttr ( prev , params . getStringValue ( ) ) ; } else if ( "rect(" . equalsIgnoreCase ( funct ) ) { return LexicalUnitImpl . createRect ( prev , params ) ; } else if ( "rgb(" . equalsIgnoreCase ( funct ) ) { return LexicalUnitImpl . createRgbColor ( prev , params ) ; } return LexicalUnitImpl . createFunction ( prev , funct . substring ( 0 , funct . length ( ) - 1 ) , params ) ; }
Process a function decl .
16,730
protected LexicalUnit hexcolorInternal ( final LexicalUnit prev , final Token t ) { final int i = 1 ; int r = 0 ; int g = 0 ; int b = 0 ; final int len = t . image . length ( ) - 1 ; try { if ( len == 3 ) { r = Integer . parseInt ( t . image . substring ( i + 0 , i + 1 ) , 16 ) ; g = Integer . parseInt ( t . image . substring ( i + 1 , i + 2 ) , 16 ) ; b = Integer . parseInt ( t . image . substring ( i + 2 , i + 3 ) , 16 ) ; r = ( r << 4 ) | r ; g = ( g << 4 ) | g ; b = ( b << 4 ) | b ; } else if ( len == 6 ) { r = Integer . parseInt ( t . image . substring ( i + 0 , i + 2 ) , 16 ) ; g = Integer . parseInt ( t . image . substring ( i + 2 , i + 4 ) , 16 ) ; b = Integer . parseInt ( t . image . substring ( i + 4 , i + 6 ) , 16 ) ; } else { final String pattern = getParserMessage ( "invalidColor" ) ; throw new CSSParseException ( MessageFormat . format ( pattern , new Object [ ] { t } ) , getInputSource ( ) . getURI ( ) , t . beginLine , t . beginColumn ) ; } final LexicalUnit lr = LexicalUnitImpl . createNumber ( null , r ) ; final LexicalUnit lc1 = LexicalUnitImpl . createComma ( lr ) ; final LexicalUnit lg = LexicalUnitImpl . createNumber ( lc1 , g ) ; final LexicalUnit lc2 = LexicalUnitImpl . createComma ( lg ) ; LexicalUnitImpl . createNumber ( lc2 , b ) ; return LexicalUnitImpl . createRgbColor ( prev , lr ) ; } catch ( final NumberFormatException ex ) { final String pattern = getParserMessage ( "invalidColor" ) ; throw new CSSParseException ( MessageFormat . format ( pattern , new Object [ ] { t } ) , getInputSource ( ) . getURI ( ) , t . beginLine , t . beginColumn , ex ) ; } }
Processes a hexadecimal color definition .
16,731
protected int intValue ( final char op , final String s ) { final int result = Integer . parseInt ( s ) ; if ( op == '-' ) { return - 1 * result ; } return result ; }
Parses the sting into an integer .
16,732
protected double doubleValue ( final char op , final String s ) { final double result = Double . parseDouble ( s ) ; if ( op == '-' ) { return - 1 * result ; } return result ; }
Parses the sting into an double .
16,733
protected int getLastNumPos ( final String s ) { int i = 0 ; for ( ; i < s . length ( ) ; i ++ ) { if ( NUM_CHARS . indexOf ( s . charAt ( i ) ) < 0 ) { break ; } } return i - 1 ; }
Returns the pos of the last numeric char in the given string .
16,734
public static void sortByNumberOfVersionsDesc ( List < ClasspathResource > resources ) { Comparator < ClasspathResource > sortByNumberOfVersionsDesc = new Comparator < ClasspathResource > ( ) { public int compare ( ClasspathResource resource1 , ClasspathResource resource2 ) { return - 1 * new Integer ( resource1 . getResourceFileVersions ( ) . size ( ) ) . compareTo ( resource2 . getResourceFileVersions ( ) . size ( ) ) ; } } ; Collections . sort ( resources , sortByNumberOfVersionsDesc ) ; }
Takes a list of classpath resources and sorts them by the number of classpath versions .
16,735
public static List < ClasspathResource > findResourcesWithDuplicates ( List < ClasspathResource > resourceFiles , boolean excludeSameSizeDups ) { List < ClasspathResource > resourcesWithDuplicates = new ArrayList < > ( ) ; for ( ClasspathResource resource : resourceFiles ) { if ( resource . hasDuplicates ( excludeSameSizeDups ) ) { resourcesWithDuplicates . add ( resource ) ; } } return resourcesWithDuplicates ; }
Inspects a given list of classpath resources and returns only the resources that contain multiple versions .
16,736
public void setMediaText ( final String mediaText ) throws DOMException { try { final CSSOMParser parser = new CSSOMParser ( ) ; parser . setErrorHandler ( ThrowCssExceptionErrorHandler . INSTANCE ) ; final MediaQueryList sml = parser . parseMedia ( mediaText ) ; setMediaList ( sml ) ; } catch ( final CSSParseException e ) { throw new DOMException ( DOMException . SYNTAX_ERR , e . getLocalizedMessage ( ) ) ; } catch ( final IOException e ) { throw new DOMException ( DOMException . NOT_FOUND_ERR , e . getLocalizedMessage ( ) ) ; } }
Parses the given media text .
16,737
public void setMedia ( final List < String > media ) { mediaQueries_ . clear ( ) ; for ( String medium : media ) { mediaQueries_ . add ( new MediaQuery ( medium ) ) ; } }
Resets the list of media queries .
16,738
public CSSStyleSheetImpl parseStyleSheet ( final InputSource source , final String href ) throws IOException { final CSSOMHandler handler = new CSSOMHandler ( ) ; handler . setHref ( href ) ; parser_ . setDocumentHandler ( handler ) ; parser_ . parseStyleSheet ( source ) ; final Object o = handler . getRoot ( ) ; if ( o instanceof CSSStyleSheetImpl ) { return ( CSSStyleSheetImpl ) o ; } return null ; }
Parses a SAC input source into a CSSOM style sheet .
16,739
public CSSValueImpl parsePropertyValue ( final String propertyValue ) throws IOException { try ( InputSource source = new InputSource ( new StringReader ( propertyValue ) ) ) { final CSSOMHandler handler = new CSSOMHandler ( ) ; parser_ . setDocumentHandler ( handler ) ; final LexicalUnit lu = parser_ . parsePropertyValue ( source ) ; if ( null == lu ) { return null ; } return new CSSValueImpl ( lu ) ; } }
Parses a input string into a CSSValue .
16,740
public AbstractCSSRuleImpl parseRule ( final String rule ) throws IOException { try ( InputSource source = new InputSource ( new StringReader ( rule ) ) ) { final CSSOMHandler handler = new CSSOMHandler ( ) ; parser_ . setDocumentHandler ( handler ) ; parser_ . parseRule ( source ) ; return ( AbstractCSSRuleImpl ) handler . getRoot ( ) ; } }
Parses a string into a CSSRule .
16,741
public SelectorList parseSelectors ( final String selectors ) throws IOException { try ( InputSource source = new InputSource ( new StringReader ( selectors ) ) ) { final HandlerBase handler = new HandlerBase ( ) ; parser_ . setDocumentHandler ( handler ) ; return parser_ . parseSelectors ( source ) ; } }
Parses a string into a CSSSelectorList .
16,742
public MediaQueryList parseMedia ( final String media ) throws IOException { try ( InputSource source = new InputSource ( new StringReader ( media ) ) ) { final HandlerBase handler = new HandlerBase ( ) ; parser_ . setDocumentHandler ( handler ) ; if ( parser_ instanceof AbstractCSSParser ) { return ( ( AbstractCSSParser ) parser_ ) . parseMedia ( source ) ; } return null ; } }
Parses a string into a MediaQueryList .
16,743
public String removeProperty ( final String propertyName ) throws DOMException { if ( null == propertyName ) { return "" ; } for ( int i = 0 ; i < properties_ . size ( ) ; i ++ ) { final Property p = properties_ . get ( i ) ; if ( p != null && propertyName . equalsIgnoreCase ( p . getName ( ) ) ) { properties_ . remove ( i ) ; if ( p . getValue ( ) == null ) { return "" ; } return p . getValue ( ) . toString ( ) ; } } return "" ; }
Remove a property .
16,744
public void insertRule ( final String rule , final int index ) throws DOMException { final CSSStyleSheetImpl parentStyleSheet = getParentStyleSheet ( ) ; try { final CSSOMParser parser = new CSSOMParser ( ) ; parser . setParentStyleSheet ( parentStyleSheet ) ; parser . setErrorHandler ( ThrowCssExceptionErrorHandler . INSTANCE ) ; final AbstractCSSRuleImpl r = parser . parseRule ( rule ) ; getCssRules ( ) . insert ( r , index ) ; } catch ( final IndexOutOfBoundsException e ) { throw new DOMExceptionImpl ( DOMException . INDEX_SIZE_ERR , DOMExceptionImpl . INDEX_OUT_OF_BOUNDS , e . getMessage ( ) ) ; } catch ( final CSSException e ) { throw new DOMExceptionImpl ( DOMException . SYNTAX_ERR , DOMExceptionImpl . SYNTAX_ERROR , e . getMessage ( ) ) ; } catch ( final IOException e ) { throw new DOMExceptionImpl ( DOMException . SYNTAX_ERR , DOMExceptionImpl . SYNTAX_ERROR , e . getMessage ( ) ) ; } }
Insert a new rule at the given index .
16,745
public static String trimBy ( final StringBuilder s , final int left , final int right ) { return s . substring ( left , s . length ( ) - right ) ; }
Remove the given number of chars from start and end . There is no parameter checking the caller has to take care of this .
16,746
public String getMessage ( ) { if ( message_ != null ) { return message_ ; } if ( getCause ( ) != null ) { return getCause ( ) . getMessage ( ) ; } switch ( code_ ) { case UNSPECIFIED_ERR : return "unknown error" ; case NOT_SUPPORTED_ERR : return "not supported" ; case SYNTAX_ERR : return "syntax error" ; default : return null ; } }
Returns the detail message of this throwable object .
16,747
public void addCondition ( final Condition condition ) { if ( conditions_ == null ) { conditions_ = new ArrayList < > ( ) ; } conditions_ . add ( condition ) ; }
Add a condition .
16,748
public void setSelectorText ( final String selectorText ) throws DOMException { try { final CSSOMParser parser = new CSSOMParser ( ) ; selectors_ = parser . parseSelectors ( selectorText ) ; } catch ( final CSSException e ) { throw new DOMExceptionImpl ( DOMException . SYNTAX_ERR , DOMExceptionImpl . SYNTAX_ERROR , e . getMessage ( ) ) ; } catch ( final IOException e ) { throw new DOMExceptionImpl ( DOMException . SYNTAX_ERR , DOMExceptionImpl . SYNTAX_ERROR , e . getMessage ( ) ) ; } }
Sets the selector text .
16,749
public static void setDebugAll ( final boolean bDebug ) { setDebugText ( bDebug ) ; setDebugFont ( bDebug ) ; setDebugSplit ( bDebug ) ; setDebugPrepare ( bDebug ) ; setDebugRender ( bDebug ) ; }
Shortcut to globally en - or disable debugging
16,750
public Version withPreRelease ( String newPreRelease ) { require ( newPreRelease != null , "newPreRelease is null" ) ; final String [ ] newPreReleaseParts = parsePreRelease ( newPreRelease ) ; return new Version ( this . major , this . minor , this . patch , newPreReleaseParts , this . buildMetaDataParts ) ; }
Creates a new Version from this one replacing only the pre - release part with the given String . All other parts will remain the same as in this Version . You can remove the pre - release part by passing an empty String .
16,751
public Version withBuildMetaData ( String newBuildMetaData ) { require ( newBuildMetaData != null , "newBuildMetaData is null" ) ; final String [ ] newBuildMdParts = parseBuildMd ( newBuildMetaData ) ; return new Version ( this . major , this . minor , this . patch , this . preReleaseParts , newBuildMdParts ) ; }
Creates a new Version from this one replacing only the build - meta - data part with the given String . All other parts will remain the same as in this Version . You can remove the build - meta - data part by passing an empty String .
16,752
public Version nextPreRelease ( ) { final String [ ] newPreReleaseParts = incrementIdentifier ( this . preReleaseParts ) ; return new Version ( this . major , this . minor , this . patch , newPreReleaseParts , EMPTY_ARRAY ) ; }
Derives a new Version instance from this one by only incrementing the pre - release identifier . The build - meta - data will be dropped all other fields remain the same .
16,753
public Version nextBuildMetaData ( ) { final String [ ] newBuildMetaData = incrementIdentifier ( this . buildMetaDataParts ) ; return new Version ( this . major , this . minor , this . patch , this . preReleaseParts , newBuildMetaData ) ; }
Derives a new Version instance from this one by only incrementing the build - meta - data identifier . All other fields remain the same .
16,754
private static int isNumeric ( String s ) { final char [ ] chars = s . toCharArray ( ) ; int num = 0 ; for ( int i = 0 ; i < chars . length ; ++ i ) { final char c = chars [ i ] ; if ( c >= '0' && c <= '9' ) { num = num * DECIMAL + Character . digit ( c , DECIMAL ) ; } else { return - 1 ; } } return num ; }
Determines whether s is a positive number . If it is the number is returned otherwise the result is - 1 .
16,755
public String [ ] getPreReleaseParts ( ) { if ( this . preReleaseParts . length == 0 ) { return EMPTY_ARRAY ; } return Arrays . copyOf ( this . preReleaseParts , this . preReleaseParts . length ) ; }
Gets the pre release identifier parts of this version as array . Modifying the resulting array will have no influence on the internal state of this object .
16,756
public String [ ] getBuildMetaDataParts ( ) { if ( this . buildMetaDataParts . length == 0 ) { return EMPTY_ARRAY ; } return Arrays . copyOf ( this . buildMetaDataParts , this . buildMetaDataParts . length ) ; }
Gets the build meta data identifier parts of this version as array . Modifying the resulting array will have no influence on the internal state of this object .
16,757
public Version toUpperCase ( ) { return new Version ( this . major , this . minor , this . patch , copyCase ( this . preReleaseParts , true ) , copyCase ( this . buildMetaDataParts , true ) ) ; }
Returns a new Version where all identifiers are converted to upper case letters .
16,758
public Version toLowerCase ( ) { return new Version ( this . major , this . minor , this . patch , copyCase ( this . preReleaseParts , false ) , copyCase ( this . buildMetaDataParts , false ) ) ; }
Returns a new Version where all identifiers are converted to lower case letters .
16,759
private Object readResolve ( ) throws ObjectStreamException { if ( this . preRelease != null || this . buildMetaData != null ) { return createInternal ( this . major , this . minor , this . patch , this . preRelease , this . buildMetaData ) ; } return this ; }
Handles proper deserialization of objects serialized with a version prior to 1 . 1 . 0
16,760
public static void avoidDoubleBorders ( final PLTable ret ) { boolean bPreviousRowHasBottomBorder = false ; for ( int i = 0 ; i < ret . getRowCount ( ) ; i ++ ) { boolean bRowHasBottomBorder = true ; boolean bRowHasTopBorder = true ; final PLTableRow aRow = ret . getRowAtIndex ( i ) ; for ( int j = 0 ; j < aRow . getColumnCount ( ) ; j ++ ) { final PLTableCell aCell = aRow . getCellAtIndex ( j ) ; if ( aCell . getBorderBottomWidth ( ) == 0 ) bRowHasBottomBorder = false ; if ( aCell . getBorderTopWidth ( ) == 0 ) bRowHasTopBorder = false ; } if ( bPreviousRowHasBottomBorder && bRowHasTopBorder ) aRow . setBorderTop ( null ) ; bPreviousRowHasBottomBorder = bRowHasBottomBorder ; } }
If two joined rows both have borders at their connecting side the doubles width has to be removed
16,761
public FontSpec getCloneWithDifferentFont ( final PreloadFont aNewFont ) { ValueEnforcer . notNull ( aNewFont , "NewFont" ) ; if ( aNewFont . equals ( m_aPreloadFont ) ) return this ; return new FontSpec ( aNewFont , m_fFontSize , m_aColor ) ; }
Return a clone of this object but with a different font .
16,762
public FontSpec getCloneWithDifferentFontSize ( final float fNewFontSize ) { ValueEnforcer . isGT0 ( fNewFontSize , "FontSize" ) ; if ( EqualsHelper . equals ( fNewFontSize , m_fFontSize ) ) return this ; return new FontSpec ( m_aPreloadFont , fNewFontSize , m_aColor ) ; }
Return a clone of this object but with a different font size .
16,763
public FontSpec getCloneWithDifferentColor ( final Color aNewColor ) { ValueEnforcer . notNull ( aNewColor , "NewColor" ) ; if ( aNewColor . equals ( m_aColor ) ) return this ; return new FontSpec ( m_aPreloadFont , m_fFontSize , aNewColor ) ; }
Return a clone of this object but with a different color .
16,764
public float getEffectiveValue ( final float fAvailableHeight ) { switch ( m_eType ) { case ABSOLUTE : return Math . min ( m_fValue , fAvailableHeight ) ; case PERCENTAGE : return fAvailableHeight * m_fValue / 100 ; default : throw new IllegalStateException ( "Unsupported: " + m_eType + " - must be calculated outside!" ) ; } }
Get the effective height based on the passed available height . This may not be called for star or auto height elements .
16,765
public static HeightSpec abs ( final float fValue ) { ValueEnforcer . isGT0 ( fValue , "Value" ) ; return new HeightSpec ( EValueUOMType . ABSOLUTE , fValue ) ; }
Create a height element with an absolute value .
16,766
public static HeightSpec perc ( final float fPerc ) { ValueEnforcer . isGT0 ( fPerc , "Perc" ) ; return new HeightSpec ( EValueUOMType . PERCENTAGE , fPerc ) ; }
Create a height element with an percentage value .
16,767
public static PLTable createWithPercentage ( final float ... aPercentages ) { ValueEnforcer . notEmpty ( aPercentages , "Percentages" ) ; final ICommonsList < WidthSpec > aWidths = new CommonsArrayList < > ( aPercentages . length ) ; for ( final float fPercentage : aPercentages ) aWidths . add ( WidthSpec . perc ( fPercentage ) ) ; return new PLTable ( aWidths ) ; }
Create a new table with the specified percentages .
16,768
public static PLTable createWithEvenlySizedColumns ( final int nColumnCount ) { ValueEnforcer . isGT0 ( nColumnCount , "ColumnCount" ) ; final ICommonsList < WidthSpec > aWidths = new CommonsArrayList < > ( nColumnCount ) ; for ( int i = 0 ; i < nColumnCount ; ++ i ) aWidths . add ( WidthSpec . star ( ) ) ; return new PLTable ( aWidths ) ; }
Create a new table with evenly sized columns .
16,769
private void _setPreparedSize ( final SizeSpec aPreparedSize ) { ValueEnforcer . notNull ( aPreparedSize , "PreparedSize" ) ; m_bPrepared = true ; m_aPreparedSize = aPreparedSize ; m_aRenderSize = getRenderSize ( aPreparedSize ) ; if ( PLDebugLog . isDebugPrepare ( ) ) { String sSuffix = "" ; if ( this instanceof IPLHasMarginBorderPadding < ? > ) { sSuffix = " with " + PLDebugLog . getXMBP ( ( IPLHasMarginBorderPadding < ? > ) this ) + " and " + PLDebugLog . getYMBP ( ( IPLHasMarginBorderPadding < ? > ) this ) ; } PLDebugLog . debugPrepare ( this , "Prepared object: " + PLDebugLog . getWH ( aPreparedSize ) + sSuffix + "; Render size: " + PLDebugLog . getWH ( m_aRenderSize ) ) ; } }
Set the prepared size of this object . This method also handles min and max size
16,770
protected final IMPLTYPE internalMarkAsPrepared ( final SizeSpec aPreparedSize ) { internalCheckNotPrepared ( ) ; _setPreparedSize ( aPreparedSize ) ; return thisAsT ( ) ; }
INTERNAL method . Do not call from outside!
16,771
public void setFont ( final PDFont font , final float fontSize ) throws IOException { if ( fontStack . isEmpty ( ) ) fontStack . add ( font ) ; else fontStack . set ( fontStack . size ( ) - 1 , font ) ; PDDocumentHelper . handleFontSubset ( m_aDoc , font ) ; writeOperand ( resources . add ( font ) ) ; writeOperand ( fontSize ) ; writeOperator ( ( byte ) 'T' , ( byte ) 'f' ) ; }
Set the font and font size to draw text with .
16,772
public void showText ( final String text ) throws IOException { if ( ! inTextMode ) { throw new IllegalStateException ( "Must call beginText() before showText()" ) ; } if ( fontStack . isEmpty ( ) ) { throw new IllegalStateException ( "Must call setFont() before showText()" ) ; } final PDFont font = fontStack . peek ( ) ; if ( font . willBeSubset ( ) ) { for ( int offset = 0 ; offset < text . length ( ) ; ) { final int codePoint = text . codePointAt ( offset ) ; font . addToSubset ( codePoint ) ; offset += Character . charCount ( codePoint ) ; } } COSWriter . writeString ( font . encode ( text ) , m_aOS ) ; write ( ( byte ) ' ' ) ; writeOperator ( ( byte ) 'T' , ( byte ) 'j' ) ; }
Shows the given text at the location specified by the current text matrix .
16,773
public void setTextMatrix ( final Matrix matrix ) throws IOException { if ( ! inTextMode ) { throw new IllegalStateException ( "Error: must call beginText() before setTextMatrix" ) ; } writeAffineTransform ( matrix . createAffineTransform ( ) ) ; writeOperator ( ( byte ) 'T' , ( byte ) 'm' ) ; }
The Tm operator . Sets the text matrix to the given values . A current text matrix will be replaced with the new one .
16,774
public void drawImage ( final PDImageXObject image , final float x , final float y ) throws IOException { drawImage ( image , x , y , image . getWidth ( ) , image . getHeight ( ) ) ; }
Draw an image at the x y coordinates with the default size of the image .
16,775
public void drawImage ( final PDImageXObject image , final float x , final float y , final float width , final float height ) throws IOException { if ( inTextMode ) { throw new IllegalStateException ( "Error: drawImage is not allowed within a text block." ) ; } saveGraphicsState ( ) ; final AffineTransform transform = new AffineTransform ( width , 0 , 0 , height , x , y ) ; transform ( new Matrix ( transform ) ) ; writeOperand ( resources . add ( image ) ) ; writeOperator ( ( byte ) 'D' , ( byte ) 'o' ) ; restoreGraphicsState ( ) ; }
Draw an image at the x y coordinates with the given size .
16,776
public void drawImage ( final PDInlineImage inlineImage , final float x , final float y ) throws IOException { drawImage ( inlineImage , x , y , inlineImage . getWidth ( ) , inlineImage . getHeight ( ) ) ; }
Draw an inline image at the x y coordinates with the default size of the image .
16,777
public void drawImage ( final PDInlineImage inlineImage , final float x , final float y , final float width , final float height ) throws IOException { if ( inTextMode ) { throw new IllegalStateException ( "Error: drawImage is not allowed within a text block." ) ; } saveGraphicsState ( ) ; transform ( new Matrix ( width , 0 , 0 , height , x , y ) ) ; final StringBuilder sb = new StringBuilder ( ) ; sb . append ( "BI" ) ; sb . append ( "\n /W " ) ; sb . append ( inlineImage . getWidth ( ) ) ; sb . append ( "\n /H " ) ; sb . append ( inlineImage . getHeight ( ) ) ; sb . append ( "\n /CS " ) ; sb . append ( "/" ) ; sb . append ( inlineImage . getColorSpace ( ) . getName ( ) ) ; if ( inlineImage . getDecode ( ) != null && inlineImage . getDecode ( ) . size ( ) > 0 ) { sb . append ( "\n /D " ) ; sb . append ( "[" ) ; for ( final COSBase base : inlineImage . getDecode ( ) ) { sb . append ( ( ( COSNumber ) base ) . intValue ( ) ) ; sb . append ( " " ) ; } sb . append ( "]" ) ; } if ( inlineImage . isStencil ( ) ) { sb . append ( "\n /IM true" ) ; } sb . append ( "\n /BPC " ) ; sb . append ( inlineImage . getBitsPerComponent ( ) ) ; write ( sb . toString ( ) ) ; writeLine ( ) ; writeOperator ( ( byte ) 'I' , ( byte ) 'D' ) ; writeBytes ( inlineImage . getData ( ) ) ; writeLine ( ) ; writeOperator ( ( byte ) 'E' , ( byte ) 'I' ) ; restoreGraphicsState ( ) ; }
Draw an inline image at the x y coordinates and a certain width and height .
16,778
public void drawForm ( final PDFormXObject form ) throws IOException { if ( inTextMode ) { throw new IllegalStateException ( "Error: drawForm is not allowed within a text block." ) ; } writeOperand ( resources . add ( form ) ) ; writeOperator ( ( byte ) 'D' , ( byte ) 'o' ) ; }
Draws the given Form XObject at the current location .
16,779
public void saveGraphicsState ( ) throws IOException { if ( ! fontStack . isEmpty ( ) ) { fontStack . push ( fontStack . peek ( ) ) ; } if ( ! strokingColorSpaceStack . isEmpty ( ) ) { strokingColorSpaceStack . push ( strokingColorSpaceStack . peek ( ) ) ; } if ( ! nonStrokingColorSpaceStack . isEmpty ( ) ) { nonStrokingColorSpaceStack . push ( nonStrokingColorSpaceStack . peek ( ) ) ; } writeOperator ( ( byte ) 'q' ) ; }
q operator . Saves the current graphics state .
16,780
public void restoreGraphicsState ( ) throws IOException { if ( ! fontStack . isEmpty ( ) ) { fontStack . pop ( ) ; } if ( ! strokingColorSpaceStack . isEmpty ( ) ) { strokingColorSpaceStack . pop ( ) ; } if ( ! nonStrokingColorSpaceStack . isEmpty ( ) ) { nonStrokingColorSpaceStack . pop ( ) ; } writeOperator ( ( byte ) 'Q' ) ; }
Q operator . Restores the current graphics state .
16,781
public void setStrokingColor ( final double g ) throws IOException { if ( _isOutsideOneInterval ( g ) ) { throw new IllegalArgumentException ( "Parameter must be within 0..1, but is " + g ) ; } writeOperand ( ( float ) g ) ; writeOperator ( ( byte ) 'G' ) ; }
Set the stroking color in the DeviceGray color space . Range is 0 .. 1 .
16,782
public void setNonStrokingColor ( final PDColor color ) throws IOException { if ( nonStrokingColorSpaceStack . isEmpty ( ) || nonStrokingColorSpaceStack . peek ( ) != color . getColorSpace ( ) ) { writeOperand ( getName ( color . getColorSpace ( ) ) ) ; writeOperator ( ( byte ) 'c' , ( byte ) 's' ) ; if ( nonStrokingColorSpaceStack . isEmpty ( ) ) { nonStrokingColorSpaceStack . add ( color . getColorSpace ( ) ) ; } else { nonStrokingColorSpaceStack . set ( nonStrokingColorSpaceStack . size ( ) - 1 , color . getColorSpace ( ) ) ; } } for ( final float value : color . getComponents ( ) ) { writeOperand ( value ) ; } if ( color . getColorSpace ( ) instanceof PDPattern ) { writeOperand ( color . getPatternName ( ) ) ; } if ( color . getColorSpace ( ) instanceof PDPattern || color . getColorSpace ( ) instanceof PDSeparation || color . getColorSpace ( ) instanceof PDDeviceN || color . getColorSpace ( ) instanceof PDICCBased ) { writeOperator ( ( byte ) 's' , ( byte ) 'c' , ( byte ) 'n' ) ; } else { writeOperator ( ( byte ) 's' , ( byte ) 'c' ) ; } }
Sets the non - stroking color and if necessary the non - stroking color space .
16,783
public void setNonStrokingColor ( final Color color ) throws IOException { final float [ ] components = new float [ ] { color . getRed ( ) / 255f , color . getGreen ( ) / 255f , color . getBlue ( ) / 255f } ; final PDColor pdColor = new PDColor ( components , PDDeviceRGB . INSTANCE ) ; setNonStrokingColor ( pdColor ) ; }
Set the non - stroking color using an AWT color . Conversion uses the default sRGB color space .
16,784
public void setNonStrokingColor ( final int r , final int g , final int b ) throws IOException { if ( _isOutside255Interval ( r ) || _isOutside255Interval ( g ) || _isOutside255Interval ( b ) ) { throw new IllegalArgumentException ( "Parameters must be within 0..255, but are (" + r + "," + g + "," + b + ")" ) ; } writeOperand ( r / 255f ) ; writeOperand ( g / 255f ) ; writeOperand ( b / 255f ) ; writeOperator ( ( byte ) 'r' , ( byte ) 'g' ) ; }
Set the non - stroking color in the DeviceRGB color space . Range is 0 .. 255 .
16,785
public void setNonStrokingColor ( final int c , final int m , final int y , final int k ) throws IOException { if ( _isOutside255Interval ( c ) || _isOutside255Interval ( m ) || _isOutside255Interval ( y ) || _isOutside255Interval ( k ) ) { throw new IllegalArgumentException ( "Parameters must be within 0..255, but are (" + c + "," + m + "," + y + "," + k + ")" ) ; } setNonStrokingColor ( c / 255f , m / 255f , y / 255f , k / 255f ) ; }
Set the non - stroking color in the DeviceCMYK color space . Range is 0 .. 255 .
16,786
public void setNonStrokingColor ( final double c , final double m , final double y , final double k ) throws IOException { if ( _isOutsideOneInterval ( c ) || _isOutsideOneInterval ( m ) || _isOutsideOneInterval ( y ) || _isOutsideOneInterval ( k ) ) { throw new IllegalArgumentException ( "Parameters must be within 0..1, but are (" + c + "," + m + "," + y + "," + k + ")" ) ; } writeOperand ( ( float ) c ) ; writeOperand ( ( float ) m ) ; writeOperand ( ( float ) y ) ; writeOperand ( ( float ) k ) ; writeOperator ( ( byte ) 'k' ) ; }
Set the non - stroking color in the DeviceRGB color space . Range is 0 .. 1 .
16,787
public void setNonStrokingColor ( final double g ) throws IOException { if ( _isOutsideOneInterval ( g ) ) { throw new IllegalArgumentException ( "Parameter must be within 0..1, but is " + g ) ; } writeOperand ( ( float ) g ) ; writeOperator ( ( byte ) 'g' ) ; }
Set the non - stroking color in the DeviceGray color space . Range is 0 .. 1 .
16,788
public void addRect ( final float x , final float y , final float width , final float height ) throws IOException { if ( inTextMode ) { throw new IllegalStateException ( "Error: addRect is not allowed within a text block." ) ; } writeOperand ( x ) ; writeOperand ( y ) ; writeOperand ( width ) ; writeOperand ( height ) ; writeOperator ( ( byte ) 'r' , ( byte ) 'e' ) ; }
Add a rectangle to the current path .
16,789
public void moveTo ( final float x , final float y ) throws IOException { if ( inTextMode ) { throw new IllegalStateException ( "Error: moveTo is not allowed within a text block." ) ; } writeOperand ( x ) ; writeOperand ( y ) ; writeOperator ( ( byte ) 'm' ) ; }
Move the current position to the given coordinates .
16,790
public void lineTo ( final float x , final float y ) throws IOException { if ( inTextMode ) { throw new IllegalStateException ( "Error: lineTo is not allowed within a text block." ) ; } writeOperand ( x ) ; writeOperand ( y ) ; writeOperator ( ( byte ) 'l' ) ; }
Draw a line from the current position to the given coordinates .
16,791
public void shadingFill ( final PDShading shading ) throws IOException { if ( inTextMode ) { throw new IllegalStateException ( "Error: shadingFill is not allowed within a text block." ) ; } writeOperand ( resources . add ( shading ) ) ; writeOperator ( ( byte ) 's' , ( byte ) 'h' ) ; }
Fills the clipping area with the given shading .
16,792
public void setLineJoinStyle ( final int lineJoinStyle ) throws IOException { if ( inTextMode ) { throw new IllegalStateException ( "Error: setLineJoinStyle is not allowed within a text block." ) ; } if ( lineJoinStyle >= 0 && lineJoinStyle <= 2 ) { writeOperand ( lineJoinStyle ) ; writeOperator ( ( byte ) 'j' ) ; } else { throw new IllegalArgumentException ( "Error: unknown value for line join style" ) ; } }
Set the line join style .
16,793
public void setLineCapStyle ( final int lineCapStyle ) throws IOException { if ( inTextMode ) { throw new IllegalStateException ( "Error: setLineCapStyle is not allowed within a text block." ) ; } if ( lineCapStyle >= 0 && lineCapStyle <= 2 ) { writeOperand ( lineCapStyle ) ; writeOperator ( ( byte ) 'J' ) ; } else { throw new IllegalArgumentException ( "Error: unknown value for line cap style" ) ; } }
Set the line cap style .
16,794
public void setLineDashPattern ( final float [ ] pattern , final float phase ) throws IOException { if ( inTextMode ) { throw new IllegalStateException ( "Error: setLineDashPattern is not allowed within a text block." ) ; } write ( ( byte ) '[' ) ; for ( final float value : pattern ) { writeOperand ( value ) ; } write ( ( byte ) ']' , ( byte ) ' ' ) ; writeOperand ( phase ) ; writeOperator ( ( byte ) 'd' ) ; }
Set the line dash pattern .
16,795
public void beginMarkedContent ( final COSName tag , final PDPropertyList propertyList ) throws IOException { writeOperand ( tag ) ; writeOperand ( resources . add ( propertyList ) ) ; writeOperator ( ( byte ) 'B' , ( byte ) 'D' , ( byte ) 'C' ) ; }
Begin a marked content sequence with a reference to an entry in the page resources Properties dictionary .
16,796
protected void writeOperand ( final float real ) throws IOException { final int byteCount = NumberFormatUtil . formatFloatFast ( real , formatDecimal . getMaximumFractionDigits ( ) , formatBuffer ) ; if ( byteCount == - 1 ) { write ( formatDecimal . format ( real ) ) ; } else { m_aOS . write ( formatBuffer , 0 , byteCount ) ; } m_aOS . write ( ' ' ) ; }
Writes a real real to the content stream .
16,797
private void writeAffineTransform ( final AffineTransform transform ) throws IOException { final double [ ] values = new double [ 6 ] ; transform . getMatrix ( values ) ; for ( final double v : values ) { writeOperand ( ( float ) v ) ; } }
Writes an AffineTransform to the content stream as an array .
16,798
public void addPageSet ( final PLPageSet aPageSet ) { ValueEnforcer . notNull ( aPageSet , "PageSet" ) ; m_aPageSets . add ( aPageSet ) ; }
Add a new page set
16,799
void setHeaderHeight ( final float fHeaderHeight ) { if ( Float . isNaN ( m_fHeaderHeight ) ) m_fHeaderHeight = fHeaderHeight ; else m_fHeaderHeight = Math . max ( m_fHeaderHeight , fHeaderHeight ) ; }
Set the page header height .