org.w3c.css.sac.CSSParseException Java Examples
The following examples show how to use
org.w3c.css.sac.CSSParseException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CssErrorHandling.java From Recaf with MIT License | 5 votes |
@Override protected void handleCodeChangeError(Throwable ex) { if (ex == null) // Clear displayed errors updateProblem(null); else if (ex instanceof CSSParseException) { // Handle displaying errors updateProblem((CSSParseException)ex); } }
Example #2
Source File: CssErrorHandling.java From Recaf with MIT License | 5 votes |
/** * Update problem. */ private void updateProblem(CSSParseException ex) { // No problem. if (ex == null) { setProblems(Collections.emptyList()); return; } // Convert problem to <Line:Message> format // - Yeah, line needs a -2 offset for some reason. setProblems(Collections.singletonList(new Pair<>(ex.getLineNumber() - 2, ex.getMessage()))); }
Example #3
Source File: CssErrorHandler.java From birt with Eclipse Public License 1.0 | 5 votes |
public void error( CSSParseException exception ) throws CSSException { StringBuffer sb = new StringBuffer( ); if ( !StringUtil.isBlank( exception.getURI( ) ) ) sb.append( exception.getURI( ) ).append( " " );; //$NON-NLS-1$ sb.append( "[" ).append( //$NON-NLS-1$ exception.getLineNumber( ) ).append( ":" ).append( //$NON-NLS-1$ exception.getColumnNumber( ) ).append( "] " ).append( //$NON-NLS-1$ exception.getMessage( ) ); System.err.println( sb.toString( ) ); errors.add( sb.toString( ) ); }
Example #4
Source File: CssErrorHandler.java From birt with Eclipse Public License 1.0 | 5 votes |
public void fatalError( CSSParseException exception ) throws CSSException { StringBuffer sb = new StringBuffer( ); if ( !StringUtil.isBlank( exception.getURI( ) ) ) sb.append( exception.getURI( ) ).append( " " );; //$NON-NLS-1$ sb.append( "[" ).append( //$NON-NLS-1$ exception.getLineNumber( ) ).append( ":" ).append( //$NON-NLS-1$ exception.getColumnNumber( ) ).append( "] " ).append( //$NON-NLS-1$ exception.getMessage( ) ); System.err.println( sb.toString( ) ); fatalErrors.add( sb.toString( ) ); }
Example #5
Source File: CssErrorHandler.java From birt with Eclipse Public License 1.0 | 5 votes |
public void warning( CSSParseException exception ) throws CSSException { StringBuffer sb = new StringBuffer( ); if ( !StringUtil.isBlank( exception.getURI( ) ) ) sb.append( exception.getURI( ) ).append( " " );; //$NON-NLS-1$ sb.append( "[" ).append( //$NON-NLS-1$ exception.getLineNumber( ) ).append( ":" ).append( //$NON-NLS-1$ exception.getColumnNumber( ) ).append( "] " ).append( //$NON-NLS-1$ exception.getMessage( ) ); System.err.println( sb.toString( ) ); warnings.add( sb.toString( ) ); }
Example #6
Source File: Parser.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private void reportError( Locator l, Exception e ) { if ( errorHandler != null ) { if ( e instanceof ParseException ) { // construct a clean error message. ParseException pe = (ParseException) e; if ( pe.specialConstructor ) { StringBuffer errorM = new StringBuffer(); if ( pe.currentToken != null ) { errorM.append( "encountered \"" ) .append( pe.currentToken.next ); } errorM.append( '"' ); if ( pe.expectedTokenSequences.length != 0 ) { errorM.append( ". Was expecting one of: " ); for ( int i = 0; i < pe.expectedTokenSequences.length; i++ ) { for ( int j = 0; j < pe.expectedTokenSequences[ i ].length; j++ ) { int kind = pe.expectedTokenSequences[ i ][ j ]; if ( kind != S ) { errorM.append( pe.tokenImage[ kind ] ); errorM.append( ' ' ); } } } } errorHandler.error( new CSSParseException( errorM.toString(), l, e ) ); } else { errorHandler.error( new CSSParseException( e.getMessage(), l, e ) ); } } else if ( e == null ) { errorHandler.error( new CSSParseException( "error", l, null ) ); } else { errorHandler.error( new CSSParseException( e.getMessage(), l, e ) ); } } }
Example #7
Source File: StyleParser.java From svgtoandroid with MIT License | 4 votes |
@Override public void warning(CSSParseException e) throws CSSException { Logger.warn(e.toString()); }
Example #8
Source File: StyleParser.java From svgtoandroid with MIT License | 4 votes |
@Override public void error(CSSParseException e) throws CSSException { Logger.error(e.toString()); }
Example #9
Source File: StyleParser.java From svgtoandroid with MIT License | 4 votes |
@Override public void fatalError(CSSParseException e) throws CSSException { Logger.error("Fatal Error: " + e.toString()); }
Example #10
Source File: Parser.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
private void reportWarningSkipText( Locator l, String text ) { if ( errorHandler != null && text != null ) { errorHandler.warning( new CSSParseException( "Skipping: " + text, l ) ); } }
Example #11
Source File: Parser.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * @throws ParseException exception during the parse */ final public LexicalUnitImpl hexcolor( LexicalUnitImpl prev ) throws ParseException { Token n; n = jj_consume_token( HASH ); int r; LexicalUnitImpl first, params = null; String s = n.image.substring( 1 ); if ( s.length() == 3 ) { String sh = s.substring( 0, 1 ); r = Integer.parseInt( sh + sh, 16 ); first = params = LexicalUnitImpl.createInteger( n.beginLine, n.beginColumn, params, r ); params = LexicalUnitImpl.createComma( n.beginLine, n.beginColumn, params ); sh = s.substring( 1, 2 ); r = Integer.parseInt( sh + sh, 16 ); params = LexicalUnitImpl.createInteger( n.beginLine, n.beginColumn, params, r ); params = LexicalUnitImpl.createComma( n.beginLine, n.beginColumn, params ); sh = s.substring( 2, 3 ); r = Integer.parseInt( sh + sh, 16 ); params = LexicalUnitImpl.createInteger( n.beginLine, n.beginColumn, params, r ); } else if ( s.length() == 6 ) { r = Integer.parseInt( s.substring( 0, 2 ), 16 ); first = params = LexicalUnitImpl.createInteger( n.beginLine, n.beginColumn, params, r ); params = LexicalUnitImpl.createComma( n.beginLine, n.beginColumn, params ); r = Integer.parseInt( s.substring( 2, 4 ), 16 ); params = LexicalUnitImpl.createInteger( n.beginLine, n.beginColumn, params, r ); params = LexicalUnitImpl.createComma( n.beginLine, n.beginColumn, params ); r = Integer.parseInt( s.substring( 4, 6 ), 16 ); params = LexicalUnitImpl.createInteger( n.beginLine, n.beginColumn, params, r ); } else { first = null; { if ( true ) { throw new CSSParseException( "invalid hexadecimal notation for RGB: " + s, getLocator() ); } } } { if ( true ) { return LexicalUnitImpl.createRGBColor( n.beginLine, n.beginColumn, prev, first ); } } throw new Error( "Missing return statement in function" ); }
Example #12
Source File: Parser.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
String convertStringIndex( String s, int start, int len ) throws ParseException { StringBuffer buf = new StringBuffer( len ); int index = start; while ( index < len ) { char c = s.charAt( index ); if ( c == '\\' ) { if ( ++index < len ) { c = s.charAt( index ); switch( c ) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': int numValue = Character.digit( c, 16 ); int count = 0; int p = 16; while ( index + 1 < len && count < 6 ) { c = s.charAt( index + 1 ); if ( Character.digit( c, 16 ) != -1 ) { numValue = ( numValue * 16 ) + Character.digit( c, 16 ); p *= 16; index++; } else { if ( c == ' ' ) { // skip the latest white space index++; } break; } } buf.append( (char) numValue ); break; case '\n': case '\f': break; case '\r': if ( index + 1 < len ) { if ( s.charAt( index + 1 ) == '\n' ) { index++; } } break; default: buf.append( c ); } } else { throw new CSSParseException( "invalid string " + s, getLocator() ); } } else { buf.append( c ); } index++; } return buf.toString(); }
Example #13
Source File: Parser.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * The following functions are useful for a DOM CSS implementation only and are not part of the general CSS2 parser. */ final public void _parseRule() throws ParseException { String ret = null; label_69: while ( true ) { switch( ( jj_ntk == -1 ) ? jj_ntk() : jj_ntk ) { case S: ; break; default: jj_la1[ 107 ] = jj_gen; break label_69; } jj_consume_token( S ); } switch( ( jj_ntk == -1 ) ? jj_ntk() : jj_ntk ) { case IMPORT_SYM: importDeclaration(); break; case LBRACKET: case ANY: case DOT: case COLON: case IDENT: case NAMESPACE_IDENT: case HASH: styleRule(); break; case MEDIA_SYM: media(); break; case PAGE_SYM: page(); break; case FONT_FACE_SYM: fontFace(); break; default: jj_la1[ 108 ] = jj_gen; ret = skipStatement(); if ( ( ret == null ) || ( ret.length() == 0 ) ) { { if ( true ) { return; } } } if ( ret.charAt( 0 ) == '@' ) { documentHandler.ignorableAtRule( ret ); } else { { if ( true ) { throw new CSSParseException( "unrecognize rule: " + ret, getLocator() ); } } } } }
Example #14
Source File: StyleSheetHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 2 votes |
/** * Receive notification of a warning. <p/> <p>CSS parsers will use this method to report conditions that are not * errors or fatal errors as defined by the XML 1.0 recommendation. The default behaviour is to take no action.</p> * <p/> <p>The CSS parser must continue to provide normal parsing events after invoking this method: it should still * be possible for the application to process the document through to the end.</p> * * @param exception The warning information encapsulated in a CSS parse exception. * @throws CSSException Any CSS exception, possibly wrapping another exception. * @see CSSParseException */ public void warning( CSSParseException exception ) throws CSSException { logger.warn( "Warning: " + exception.getMessage() ); }
Example #15
Source File: StyleSheetHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 2 votes |
/** * Receive notification of a recoverable error. <p/> <p>This corresponds to the definition of "error" in section 1.2 * of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the * violation of a validity constraint. The default behaviour is to take no action.</p> <p/> <p>The CSS parser must * continue to provide normal parsing events after invoking this method: it should still be possible for the * application to process the document through to the end. If the application cannot do so, then the parser should * report a fatal error even if the XML 1.0 recommendation does not require it to do so.</p> * * @param exception The error information encapsulated in a CSS parse exception. * @throws CSSException Any CSS exception, possibly wrapping another exception. * @see CSSParseException */ public void error( CSSParseException exception ) throws CSSException { logger.warn( "Error: ", exception ); }
Example #16
Source File: StyleSheetHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 2 votes |
/** * Receive notification of a non-recoverable error. <p/> <p>This corresponds to the definition of "fatal error" in * section 1.2 of the W3C XML 1.0 Recommendation. For example, a parser would use this callback to report the * violation of a well-formedness constraint.</p> <p/> <p>The application must assume that the document is unusable * after the parser has invoked this method, and should continue (if at all) only for the sake of collecting addition * error messages: in fact, CSS parsers are free to stop reporting any other events once this method has been * invoked.</p> * * @param exception The error information encapsulated in a CSS parse exception. * @throws CSSException Any CSS exception, possibly wrapping another exception. * @see CSSParseException */ public void fatalError( CSSParseException exception ) throws CSSException { logger.warn( "Fatal Error: ", exception ); }