Package org.w3c.css.sac

Examples of org.w3c.css.sac.LexicalUnit


    if (value == null)
    {
      return null;
    }

    LexicalUnit maybeComma = value.getNextLexicalUnit();
    if (maybeComma == null)
    {
      return null;
    }
    if (maybeComma.getLexicalUnitType() == LexicalUnit.SAC_OPERATOR_COMMA)
    {
      return maybeComma.getNextLexicalUnit();
    }
    return null;
  }
View Full Code Here


        source.setCharacterStream(new StringReader(value));

        handler.initParseContext(source);
        handler.setStyleRule(new CSSStyleRule(new StyleSheet(), null));
        parser.setDocumentHandler(handler);
        final LexicalUnit lu = parser.parsePropertyValue(source);
        handler.property(key.getName(), lu, false);
        final CSSStyleRule rule = (CSSStyleRule) handler.getStyleRule();

        CSSParserContext.getContext().destroy();
View Full Code Here

        source.setCharacterStream(new StringReader(value));

        handler.initParseContext(source);
        handler.setStyleRule(baseRule);
        parser.setDocumentHandler(handler);
        final LexicalUnit lu = parser.parsePropertyValue(source);
        handler.property(name, lu, false);
        final CSSStyleRule rule = (CSSStyleRule) handler.getStyleRule();

        CSSParserContext.getContext().destroy();
        return rule;
View Full Code Here

* @exception ParseException exception during the parse
*/
  final public void declaration() throws ParseException {
  boolean important = false;
  String name;
  LexicalUnit exp;
  Token save;
    try {
      name = property();
       save = token;
      jj_consume_token(COLON);
View Full Code Here

* Handle all CSS2 functions.
* @exception ParseException exception during the parse
*/
  final public LexicalUnitImpl function(char operator, LexicalUnitImpl prev) throws ParseException {
Token n;
LexicalUnit params = null;
    n = jj_consume_token(FUNCTION);
    label_68:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case S:
        ;
        break;
      default:
        jj_la1[105] = jj_gen;
        break label_68;
      }
      jj_consume_token(S);
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case PLUS:
    case MINUS:
    case STRING:
    case IDENT:
    case NUMBER:
    case URL:
    case NAMESPACE_IDENT:
    case PERCENTAGE:
    case PT:
    case MM:
    case CM:
    case PC:
    case IN:
    case PX:
    case EMS:
    case EXS:
    case DEG:
    case RAD:
    case GRAD:
    case MS:
    case SECOND:
    case HZ:
    case KHZ:
    case DIMEN:
    case HASH:
    case UNICODERANGE:
    case FUNCTION:
      params = expr();
      break;
    default:
      jj_la1[106] = jj_gen;
      ;
    }
    jj_consume_token(LPARAN);
        if (operator != ' ') {
            {if (true) throw new CSSParseException("invalid operator before a function.",
                                        getLocator());}
        }
        String f = convertIdent(n.image);
        LexicalUnitImpl l = (LexicalUnitImpl) params;
        boolean loop = true;
        if ("rgb(".equals(f)) {
            // this is a RGB declaration (e.g. rgb(255, 50%, 0) )
            int i = 0;
            while (loop && l != null && i < 5) {
                switch (i) {
                    case 0:
                    case 2:
                    case 4:
                        if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER)
                            && (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) {
                            loop = false;
                        }
                        break;
                    case 1:
                    case 3:
                        if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
                            loop = false;
                        }
                        break;
                    default:
                        {if (true) throw new ParseException("implementation error");}
                }
                if (loop) {
                    l = (LexicalUnitImpl) l.getNextLexicalUnit();
                    i ++;
                }
            }
            if ((i == 5) && loop && (l == null)) {
                {if (true) return LexicalUnitImpl.createRGBColor(n.beginLine,
                                                      n.beginColumn,
                                                      prev, params);}
            } else {
                if (errorHandler != null) {
                    String errorText;
                    Locator loc;
                    if (i < 5) {
                        if (params == null) {
                            loc = new LocatorImpl(this, n.beginLine,
                                                  n.beginColumn-1);
                            errorText = "not enough parameters.";
                        } else if (l == null) {
                            loc = new LocatorImpl(this, n.beginLine,
                                                  n.beginColumn-1);
                            errorText = "not enough parameters: "
                                + params.toString();
                        } else {
                            loc = new LocatorImpl(this, l.getLineNumber(),
                                                  l.getColumnNumber());
                            errorText = "invalid parameter: "
                                + l.toString();
View Full Code Here

        if (styleSheetParserUtil == null)
        {
            styleSheetParserUtil = StyleSheetParserUtil.getInstance();
        }

        final LexicalUnit cssValue = styleSheetParserUtil.parseLexicalStyleValue(
                text);
        return CSSValueFactory.createLengthValue(cssValue);
    }
View Full Code Here

            for (int i = 0; i < len; i++) {
                Node attr = attrs.item(i);
                String an = attr.getNodeName();
                if (nonCSSPresentationalHints.contains(an)) {
                    try {
                        LexicalUnit lu;
                        int idx = getPropertyIndex(an);
                        lu = parser.parsePropertyValue(attr.getNodeValue());
                        ValueManager vm = valueManagers[idx];
                        Value v = vm.createValue(lu, this);
                        putAuthorProperty(result, idx, v, false,
View Full Code Here

     * @param prop The property name.
     * @param value The property value.
     */
    public Value parsePropertyValue(String prop, String value) {
        try {
            LexicalUnit lu;
            int idx = getPropertyIndex(prop);
            lu = parser.parsePropertyValue(value);
            ValueManager vm = valueManagers[idx];
            return vm.createValue(lu, this);
        } catch (Exception e) {
View Full Code Here

       
        boolean comp = style.isComputed(idx);

        element = elt;
        try {
            LexicalUnit lu;
            lu = parser.parsePropertyValue(evt.getNewValue());
            ValueManager vm = valueManagers[idx];
            Value v = vm.createValue(lu, CSSEngine.this);
            style.putMask(idx, (short)0);
            style.putValue(idx, v);
View Full Code Here

            for (int i = 0; i < len; i++) {
                Node attr = attrs.item(i);
                String an = attr.getNodeName();
                if (nonCSSPresentationalHints.contains(an)) {
                    try {
                        LexicalUnit lu;
                        int idx = getPropertyIndex(an);
                        lu = parser.parsePropertyValue(attr.getNodeValue());
                        ValueManager vm = valueManagers[idx];
                        Value v = vm.createValue(lu, this);
                        putAuthorProperty(result, idx, v, false,
View Full Code Here

TOP

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

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.