Package org.w3c.css.sac

Examples of org.w3c.css.sac.CSSException


    /**
     * <b>SAC</b>: Implements {@link
     * org.w3c.css.sac.ConditionFactory#createOnlyChildCondition()}.
     */   
    public Condition createOnlyChildCondition() throws CSSException {
  throw new CSSException("Not implemented in CSS2");
    }
View Full Code Here


    /**
     * <b>SAC</b>: Implements {@link
     * org.w3c.css.sac.ConditionFactory#createOnlyTypeCondition()}.
     */   
    public Condition createOnlyTypeCondition() throws CSSException {
  throw new CSSException("Not implemented in CSS2");
    }
View Full Code Here

     * <b>SAC</b>: Implements {@link
     * org.w3c.css.sac.ConditionFactory#createContentCondition(String)}.
     */   
    public ContentCondition createContentCondition(String data)
        throws CSSException {
  throw new CSSException("Not implemented in CSS2");
    }
View Full Code Here

                    try {
                        ParsedURL purl = new ParsedURL(uri);
                        is = purl.openStreamRaw(CSSConstants.CSS_MIME_TYPE);
                        r = characterStream(source, is, enc);
                    } catch (IOException e) {
                        throw new CSSException(e);
                    }
                } else {
                    throw new CSSException(formatMessage("empty.source", null));
                }
            }
        }
        return r;
    }
View Full Code Here

            String encoding = source.getEncoding();
            if (encoding == null && enc == null) {
                return new InputStreamReader(is);
            } else if (encoding != null && enc != null) {
                if (!javaEncoding(encoding).equals(javaEncoding(enc))) {
                    throw new CSSException(formatMessage("encoding",
                                                         new Object[] { enc }));
                }
                return new InputStreamReader(is, javaEncoding(encoding));
            } else {
                return new InputStreamReader(is, javaEncoding((enc != null)
                                                              ? enc : encoding));
            }
        } catch (UnsupportedEncodingException e) {
            throw new CSSException(e);
        }
    }
View Full Code Here

   */
  public ProcessingInstructionSelector createProcessingInstructionSelector(
      String target,
      String data) throws CSSException
  {
    throw new CSSException
        ("LibLayout does not support ProcessingInstructions.");
  }
View Full Code Here

   * @throws CSSException If this selector is not supported.
   */
  public CharacterDataSelector createCommentSelector(String data)
      throws CSSException
  {
    throw new CSSException
        ("LibLayout does not support CommenSelectors.");
  }
View Full Code Here

    /**
     * @@TODO
     * @exception CSSException Not yet implemented
     */
    public void setLocale(Locale locale) throws CSSException {
        throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
    }
View Full Code Here

                                             source.getEncoding());
            }
        } else {
            // systemId
            // @@TODO
            throw new CSSException("not yet implemented");
        }
    }
View Full Code Here

                source.setByteStream(new URL(source.getURI()).openStream());
            } catch (Exception e) {
                try {
                    source.setByteStream(new FileInputStream(source.getURI()));
                } catch (IOException ex) {
                    throw new CSSException("invalid url ?");
                }
            }
        }
        String encoding = "ASCII";
        InputStream input = source.getByteStream();
        char c = ' ';

        if (!input.markSupported()) {
            input = new BufferedInputStream(input);
            source.setByteStream(input);
        }
        input.mark(100);
        c = (char) input.read();

        if (c == '@') {
            // hum, is it a charset ?
            int size   = 100;
            byte[] buf = new byte[size];
            input.read(buf, 0, 7);
            String keyword = new String(buf, 0, 7);
            if (keyword.equals("charset")) {
                // Yes, this is the charset declaration !

                // here I don't use the right declaration : white space are ' '.
                while ((c = (char) input.read()) == ' ') {
                    // find the first quote
                }
                char endChar = c;
                int i = 0;

                if ((endChar != '"') && (endChar != '\'')) {
                    // hum this is not a quote.
                    throw new CSSException("invalid charset declaration");
                }

                while ((c = (char) input.read()) != endChar) {
                    buf[i++] = (byte) c;
                    if (i == size) {
                        byte[] old = buf;
                        buf = new byte[size + 100];
                        System.arraycopy(old, 0, buf, 0, size);
                        size += 100;
                    }
                }
                while ((c = (char) input.read()) == ' ') {
                    // find the next relevant character
                }
                if (c != ';') {
                    // no semi colon at the end ?
                    throw new CSSException("invalid charset declaration: "
                                           + "missing semi colon");
                }
                encoding = new String(buf, 0, i);
                if (source.getEncoding() != null) {
                    // compare the two encoding informations.
                    // For example, I don't accept to have ASCII and after UTF-8.
                    // Is it really good ? That is the question.
                    if (!encoding.equals(source.getEncoding())) {
                        throw new CSSException("invalid encoding information.");
                    }
                }
            } // else no charset declaration available
        }
        // ok set the real encoding of this source.
View Full Code Here

TOP

Related Classes of org.w3c.css.sac.CSSException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.