jStyleParser

16:38:15.935 INFO  jd.cli.Main - Decompiling jStyleParser.jar
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.Declaration;
import cz.vutbr.web.css.RuleBlock.Priority;
import cz.vutbr.web.css.RuleMargin;
import cz.vutbr.web.css.RuleMargin.MarginArea;

public class RuleMarginImpl
  extends AbstractRuleBlock<Declaration>
  implements RuleMargin
{
  private RuleMargin.MarginArea marginArea;
  
  protected RuleMarginImpl(String area, RuleBlock.Priority priority)
  {
    super(priority);
    RuleMargin.MarginArea[] arrayOfMarginArea;
    int j = (arrayOfMarginArea = RuleMargin.MarginArea.values()).length;
    for (int i = 0; i < j; i++)
    {
      RuleMargin.MarginArea a = arrayOfMarginArea[i];
      if (value.equals(area))
      {
        marginArea = a;
        break;
      }
    }
    if (marginArea == null) {
      throw new IllegalArgumentException("Illegal value for margin area: " + area);
    }
  }
  
  public RuleMargin.MarginArea getMarginArea()
  {
    return marginArea;
  }
  
  public String toString()
  {
    return toString(0);
  }
  
  public String toString(int depth)
  {
    StringBuilder sb = new StringBuilder();
    
    sb = OutputUtil.appendTimes(sb, "\t", depth);
    sb.append("@").append(marginArea.value);
    
    sb.append(" {\n");
    sb = OutputUtil.appendList(sb, list, "\n", depth + 1);
    sb.append("}\n");
    
    return sb.toString();
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = super.hashCode();
    result = 31 * result + (marginArea == null ? 0 : marginArea.hashCode());
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (!super.equals(obj)) {
      return false;
    }
    if (!(obj instanceof RuleMarginImpl)) {
      return false;
    }
    RuleMarginImpl other = (RuleMarginImpl)obj;
    if (marginArea == null)
    {
      if (marginArea != null) {
        return false;
      }
    }
    else if (!marginArea.equals(marginArea)) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.RuleMarginImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.Term;
import cz.vutbr.web.css.Term.Operator;
import cz.vutbr.web.css.TermList;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TermListImpl
  extends AbstractList<Term<?>>
  implements TermList
{
  protected List<Term<?>> value;
  protected Term.Operator operator;
  
  protected TermListImpl()
  {
    value = new ArrayList();
  }
  
  protected TermListImpl(int initialSize)
  {
    value = new ArrayList(initialSize);
  }
  
  public List<Term<?>> getValue()
  {
    return value;
  }
  
  public TermList setValue(List<Term<?>> value)
  {
    this.value = value;
    return this;
  }
  
  public Term.Operator getOperator()
  {
    return operator;
  }
  
  public TermList setOperator(Term.Operator operator)
  {
    this.operator = operator;
    return this;
  }
  
  public Term<?> get(int arg0)
  {
    return (Term)value.get(arg0);
  }
  
  public void add(int index, Term<?> element)
  {
    value.add(index, element);
  }
  
  public Term<?> remove(int index)
  {
    return (Term)value.remove(index);
  }
  
  public int size()
  {
    return value.size();
  }
  
  public Iterator<Term<?>> iterator()
  {
    return value.iterator();
  }
  
  public boolean add(Term<?> o)
  {
    return value.add(o);
  }
  
  public String toString()
  {
    StringBuilder sb = new StringBuilder();
    if (operator != null) {
      sb.append(operator.value());
    }
    OutputUtil.appendList(sb, value, " ");
    return sb.toString();
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = 1;
    result = 31 * result + (
      operator == null ? 0 : operator.hashCode());
    result = 31 * result + (value == null ? 0 : value.hashCode());
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (!(obj instanceof TermListImpl)) {
      return false;
    }
    TermListImpl other = (TermListImpl)obj;
    if (operator == null)
    {
      if (operator != null) {
        return false;
      }
    }
    else if (!operator.equals(operator)) {
      return false;
    }
    if (value == null)
    {
      if (value != null) {
        return false;
      }
    }
    else if (!value.equals(value)) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.TermListImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.CombinedSelector;
import cz.vutbr.web.css.CombinedSelector.Specificity;
import cz.vutbr.web.css.CombinedSelector.Specificity.Level;
import cz.vutbr.web.css.Selector;
import cz.vutbr.web.css.Selector.PseudoDeclaration;
import java.util.Arrays;
import java.util.List;

public class CombinedSelectorImpl
  extends AbstractRule<Selector>
  implements CombinedSelector
{
  public Selector getLastSelector()
    throws UnsupportedOperationException
  {
    if (list.size() == 0) {
      throw new UnsupportedOperationException("There is no \"last\" simple selector");
    }
    return (Selector)list.get(list.size() - 1);
  }
  
  public Selector.PseudoDeclaration getPseudoElement()
  {
    return getLastSelector().getPseudoElement();
  }
  
  public CombinedSelector.Specificity computeSpecificity()
  {
    CombinedSelector.Specificity spec = new SpecificityImpl();
    for (Selector s : list) {
      s.computeSpecificity(spec);
    }
    return spec;
  }
  
  public String toString(int depth)
  {
    StringBuilder sb = new StringBuilder();
    sb = OutputUtil.appendList(sb, list, "");
    
    return sb.toString();
  }
  
  public String toString()
  {
    return toString(0);
  }
  
  public static class SpecificityImpl
    implements CombinedSelector.Specificity
  {
    protected int[] spec = new int[CombinedSelector.Specificity.Level.values().length];
    
    public int compareTo(CombinedSelector.Specificity o)
    {
      if (get(CombinedSelector.Specificity.Level.A) > o.get(CombinedSelector.Specificity.Level.A)) {
        return 1;
      }
      if (get(CombinedSelector.Specificity.Level.A) < o.get(CombinedSelector.Specificity.Level.A)) {
        return -1;
      }
      if (get(CombinedSelector.Specificity.Level.B) > o.get(CombinedSelector.Specificity.Level.B)) {
        return 1;
      }
      if (get(CombinedSelector.Specificity.Level.B) < o.get(CombinedSelector.Specificity.Level.B)) {
        return -1;
      }
      if (get(CombinedSelector.Specificity.Level.C) > o.get(CombinedSelector.Specificity.Level.C)) {
        return 1;
      }
      if (get(CombinedSelector.Specificity.Level.C) < o.get(CombinedSelector.Specificity.Level.C)) {
        return -1;
      }
      if (get(CombinedSelector.Specificity.Level.D) > o.get(CombinedSelector.Specificity.Level.D)) {
        return 1;
      }
      if (get(CombinedSelector.Specificity.Level.D) < o.get(CombinedSelector.Specificity.Level.D)) {
        return -1;
      }
      return 0;
    }
    
    public int get(CombinedSelector.Specificity.Level level)
    {
      switch (level)
      {
      case A: 
        return spec[0];
      case B: 
        return spec[1];
      case C: 
        return spec[2];
      case D: 
        return spec[3];
      }
      return 0;
    }
    
    public void add(CombinedSelector.Specificity.Level level)
    {
      switch (level)
      {
      case A: 
        spec[0] += 1;
      case B: 
        spec[1] += 1;
      case C: 
        spec[2] += 1;
      case D: 
        spec[3] += 1;
      }
    }
    
    public int hashCode()
    {
      int prime = 31;
      int result = 1;
      result = 31 * result + Arrays.hashCode(spec);
      return result;
    }
    
    public boolean equals(Object obj)
    {
      if (this == obj) {
        return true;
      }
      if (obj == null) {
        return false;
      }
      if (!(obj instanceof SpecificityImpl)) {
        return false;
      }
      SpecificityImpl other = (SpecificityImpl)obj;
      if (!Arrays.equals(spec, spec)) {
        return false;
      }
      return true;
    }
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.CombinedSelectorImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.TermNumber;

public class TermNumberImpl
  extends TermNumericImpl<Float>
  implements TermNumber
{}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.TermNumberImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.TermInteger;
import cz.vutbr.web.css.TermNumeric.Unit;

public class TermIntegerImpl
  extends TermLengthImpl
  implements TermInteger
{
  protected TermIntegerImpl()
  {
    setUnit(TermNumeric.Unit.none);
  }
  
  public int getIntValue()
  {
    return ((Float)getValue()).intValue();
  }
  
  public TermInteger setValue(int value)
  {
    setValue(Float.valueOf(value));
    return this;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.TermIntegerImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.PrettyOutput;
import java.util.List;

public class OutputUtil
{
  public static final String EMPTY_DELIM = "";
  public static final String SPACE_DELIM = " ";
  public static final String DEPTH_DELIM = "\t";
  public static final String RULE_OPENING = " {\n";
  public static final String RULE_CLOSING = "}\n";
  public static final String MEDIA_DELIM = ", ";
  public static final String SELECTOR_DELIM = ", ";
  public static final String IMPORT_KEYWORD = "@import ";
  public static final String URL_OPENING = "url('";
  public static final String URL_CLOSING = "')";
  public static final String LINE_CLOSING = ";\n";
  public static final String NEW_LINE = "\n";
  public static final String MEDIA_KEYWORD = "@media ";
  public static final String RULE_DELIM = "\n";
  public static final String CHARSET_KEYWORD = "@charset ";
  public static final String CHARSET_OPENING = "\"";
  public static final String CHARSET_CLOSING = "\";\n";
  public static final String PROPERTY_OPENING = ": ";
  public static final String PROPERTY_CLOSING = ";\n";
  public static final String IMPORTANT_KEYWORD = "!important";
  public static final String PAGE_KEYWORD = "@page";
  public static final String PAGE_OPENING = ":";
  public static final String PAGE_CLOSING = "";
  public static final String VIEWPORT_KEYWORD = "@viewport";
  public static final String FONT_FACE_KEYWORD = "@font-face";
  public static final String FUNCTION_OPENING = "(";
  public static final String FUNCTION_CLOSING = ")";
  public static final String STRING_OPENING = "'";
  public static final String STRING_CLOSING = "'";
  public static final String ATTRIBUTE_OPENING = "[";
  public static final String ATTRIBUTE_CLOSING = "]";
  public static final String PERCENT_SIGN = "%";
  public static final String HASH_SIGN = "#";
  public static final String MARGIN_AREA_OPENING = "@";
  
  public static StringBuilder appendTimes(StringBuilder sb, String append, int times)
  {
    for (; times > 0; times--) {
      sb.append(append);
    }
    return sb;
  }
  
  public static <T> StringBuilder appendList(StringBuilder sb, List<T> list, String delimiter)
  {
    boolean firstRun = true;
    for (T elem : list)
    {
      if (!firstRun) {
        sb.append(delimiter);
      } else {
        firstRun = false;
      }
      sb.append(elem.toString());
    }
    return sb;
  }
  
  public static <T extends PrettyOutput> StringBuilder appendList(StringBuilder sb, List<T> list, String delimiter, int depth)
  {
    boolean firstRun = true;
    for (T elem : list)
    {
      if (!firstRun) {
        sb.append(delimiter);
      } else {
        firstRun = false;
      }
      sb.append(elem.toString(depth));
    }
    return sb;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.OutputUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.Declaration;
import cz.vutbr.web.css.RuleBlock.Priority;
import cz.vutbr.web.css.RuleViewport;

public class RuleViewportImpl
  extends AbstractRuleBlock<Declaration>
  implements RuleViewport
{
  protected RuleViewportImpl(RuleBlock.Priority priority)
  {
    super(priority);
  }
  
  public String toString()
  {
    return toString(0);
  }
  
  public String toString(int depth)
  {
    StringBuilder sb = new StringBuilder();
    
    sb.append("@viewport").append(" ");
    
    sb.append(" {\n");
    sb = OutputUtil.appendList(sb, list, "", depth + 1);
    sb.append("}\n");
    
    return sb.toString();
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.RuleViewportImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.Declaration;
import cz.vutbr.web.css.Term;

public class DeclarationImpl
  extends AbstractRule<Term<?>>
  implements Declaration
{
  protected String property;
  protected boolean important;
  
  protected DeclarationImpl()
  {
    property = "";
    important = false;
  }
  
  protected DeclarationImpl(Declaration clone)
  {
    property = clone.getProperty();
    important = clone.isImportant();
    replaceAll(clone.asList());
  }
  
  public boolean isInherited(int level)
  {
    return false;
  }
  
  public int getInheritanceLevel()
  {
    return 0;
  }
  
  public int compareTo(Declaration o)
  {
    if ((isImportant()) && (!o.isImportant())) {
      return 1;
    }
    if ((o.isImportant()) && (!isImportant())) {
      return -1;
    }
    return 0;
  }
  
  public String getProperty()
  {
    return property;
  }
  
  public void setProperty(String property)
  {
    this.property = property;
  }
  
  public boolean isImportant()
  {
    return important;
  }
  
  public void setImportant(boolean important)
  {
    this.important = important;
  }
  
  public String toString()
  {
    return toString(0);
  }
  
  public String toString(int depth)
  {
    StringBuilder sb = new StringBuilder();
    
    sb = OutputUtil.appendTimes(sb, "\t", depth);
    sb.append(property).append(": ");
    
    sb = OutputUtil.appendList(sb, list, "");
    if (important) {
      sb.append(" ").append("!important");
    }
    sb.append(";\n");
    
    return sb.toString();
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = super.hashCode();
    result = 31 * result + (important ? 1231 : 1237);
    result = 31 * result + (
      property == null ? 0 : property.hashCode());
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (!super.equals(obj)) {
      return false;
    }
    if (!(obj instanceof DeclarationImpl)) {
      return false;
    }
    DeclarationImpl other = (DeclarationImpl)obj;
    if (important != important) {
      return false;
    }
    if (property == null)
    {
      if (property != null) {
        return false;
      }
    }
    else if (!property.equals(property)) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.DeclarationImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.CombinedSelector.Specificity;
import cz.vutbr.web.css.CombinedSelector.Specificity.Level;
import cz.vutbr.web.css.Selector.ElementID;
import org.w3c.dom.Element;

public class SelectorImpl$ElementIDImpl
  implements Selector.ElementID
{
  private String id;
  
  protected SelectorImpl$ElementIDImpl(String value)
  {
    setID(value);
  }
  
  public void computeSpecificity(CombinedSelector.Specificity spec)
  {
    spec.add(CombinedSelector.Specificity.Level.B);
  }
  
  public boolean matches(Element e)
  {
    return ElementUtil.matchesID(e, id);
  }
  
  public Selector.ElementID setID(String id)
  {
    if (id == null) {
      throw new IllegalArgumentException("Invalid element ID (null)");
    }
    this.id = id;
    return this;
  }
  
  public String getID()
  {
    return id;
  }
  
  public String toString()
  {
    return "#" + id;
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = 1;
    result = 31 * result + (id == null ? 0 : id.hashCode());
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (!(obj instanceof ElementIDImpl)) {
      return false;
    }
    ElementIDImpl other = (ElementIDImpl)obj;
    if (id == null)
    {
      if (id != null) {
        return false;
      }
    }
    else if (!id.equals(id)) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.SelectorImpl.ElementIDImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.Selector.Operator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class ElementUtil
{
  public static final String CLASS_DELIM = " ";
  public static final String CLASS_ATTR = "class";
  public static final String ID_ATTR = "id";
  
  public static Collection<String> elementClasses(Element e)
  {
    if (e.hasAttribute("class"))
    {
      String classNames = e.getAttribute("class");
      
      Collection<String> list = new ArrayList();
      String[] arrayOfString;
      int j = (arrayOfString = classNames.toLowerCase().split(" ")).length;
      for (int i = 0; i < j; i++)
      {
        String cname = arrayOfString[i];
        
        cname = cname.trim();
        if (cname.length() > 0) {
          list.add(cname);
        }
      }
      return list;
    }
    return Collections.emptyList();
  }
  
  public static boolean matchesClass(Element e, String className)
  {
    if (e.hasAttribute("class"))
    {
      String classNames = e.getAttribute("class").toLowerCase();
      int len = className.length();
      int start = classNames.indexOf(className.toLowerCase());
      if (start == -1) {
        return false;
      }
      return ((start == 0) || (Character.isWhitespace(classNames.charAt(start - 1)))) && (
        (start + len == classNames.length()) || (Character.isWhitespace(classNames.charAt(start + len))));
    }
    return false;
  }
  
  public static String elementID(Element e)
  {
    String id = e.getAttribute("id");
    return id;
  }
  
  public static boolean matchesID(Element e, String id)
  {
    return id.equalsIgnoreCase(elementID(e));
  }
  
  public static String elementName(Element e)
  {
    String name = e.getNodeName();
    return name;
  }
  
  public static boolean matchesName(Element e, String name)
  {
    if (name == null) {
      return false;
    }
    return name.equalsIgnoreCase(elementName(e));
  }
  
  public static boolean matchesAttribute(Element e, String name, String value, Selector.Operator o)
  {
    Node attributeNode = e.getAttributeNode(name);
    if ((attributeNode != null) && (o != null))
    {
      String attributeValue = attributeNode.getNodeValue();
      switch (o)
      {
      case CONTAINS: 
        return attributeValue.equals(value);
      case DASHMATCH: 
        attributeValue = " " + attributeValue + " ";
        return attributeValue.matches(".* " + value + " .*");
      case ENDSWITH: 
        return attributeValue.matches("^" + value + "(-.*|$)");
      case EQUALS: 
        return attributeValue.matches(".*" + value + ".*");
      case INCLUDES: 
        return attributeValue.matches("^" + value + ".*");
      case NO_OPERATOR: 
        return attributeValue.matches(".*" + value + "$");
      }
      return true;
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.ElementUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.TermIdent;

public class TermIdentImpl
  extends TermImpl<String>
  implements TermIdent
{}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.TermIdentImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.Term;
import cz.vutbr.web.css.TermAngle;
import cz.vutbr.web.css.TermColor;
import cz.vutbr.web.css.TermExpression;
import cz.vutbr.web.css.TermFactory;
import cz.vutbr.web.css.TermFrequency;
import cz.vutbr.web.css.TermFunction;
import cz.vutbr.web.css.TermIdent;
import cz.vutbr.web.css.TermInteger;
import cz.vutbr.web.css.TermLength;
import cz.vutbr.web.css.TermList;
import cz.vutbr.web.css.TermNumber;
import cz.vutbr.web.css.TermNumeric;
import cz.vutbr.web.css.TermNumeric.Unit;
import cz.vutbr.web.css.TermPair;
import cz.vutbr.web.css.TermPercent;
import cz.vutbr.web.css.TermString;
import cz.vutbr.web.css.TermTime;
import cz.vutbr.web.css.TermURI;
import java.net.URL;

public class TermFactoryImpl
  implements TermFactory
{
  private static final TermFactory instance = new TermFactoryImpl();
  
  public static final TermFactory getInstance()
  {
    return instance;
  }
  
  public TermAngle createAngle(Float value)
  {
    return (TermAngle)new TermAngleImpl().setValue(value);
  }
  
  public TermAngle createAngle(String value, TermNumeric.Unit unit, int unary)
  {
    return (TermAngle)new TermAngleImpl().setUnit(unit).setValue(
      convertFloat(value, unit.value(), unary));
  }
  
  public TermColor createColor(TermIdent ident)
  {
    return TermColorImpl.getColorByIdent(ident);
  }
  
  public TermColor createColor(String hash)
  {
    return TermColorImpl.getColorByHash(hash);
  }
  
  public TermColor createColor(int r, int g, int b)
  {
    return new TermColorImpl(r, g, b);
  }
  
  public TermColor createColor(int r, int g, int b, int a)
  {
    return new TermColorImpl(r, g, b, a);
  }
  
  public TermColor createColor(TermFunction function)
  {
    return TermColorImpl.getColorByFunction(function);
  }
  
  public TermFrequency createFrequency(Float value)
  {
    return new TermFrequencyImpl().setValue(value);
  }
  
  public TermFrequency createFrequency(String value, TermNumeric.Unit unit, int unary)
  {
    return (TermFrequency)new TermFrequencyImpl().setUnit(unit)
      .setValue(convertFloat(value, unit.value(), unary));
  }
  
  public TermExpression createExpression(String expr)
  {
    return new TermExpressionImpl().setValue(expr);
  }
  
  public TermFunction createFunction()
  {
    return new TermFunctionImpl();
  }
  
  public TermIdent createIdent(String value)
  {
    return (TermIdent)new TermIdentImpl().setValue(value);
  }
  
  public TermIdent createIdent(String value, boolean dash)
  {
    if (!dash) {
      return (TermIdent)new TermIdentImpl().setValue(value);
    }
    return (TermIdent)new TermIdentImpl().setValue("-" + value);
  }
  
  public TermInteger createInteger(Integer value)
  {
    return new TermIntegerImpl().setValue(value.intValue());
  }
  
  public TermInteger createInteger(String value, int unary)
  {
    return new TermIntegerImpl().setValue(convertInteger(
      value, null, unary).intValue());
  }
  
  public TermLength createLength(Float value)
  {
    return (TermLength)new TermLengthImpl().setValue(value);
  }
  
  public TermLength createLength(Float value, TermNumeric.Unit unit)
  {
    return (TermLength)new TermLengthImpl().setUnit(unit).setValue(value);
  }
  
  public TermLength createLength(String value, TermNumeric.Unit unit, int unary)
  {
    return (TermLength)new TermLengthImpl().setUnit(unit).setValue(
      convertFloat(value, unit.value(), unary));
  }
  
  public TermList createList()
  {
    return new TermListImpl();
  }
  
  public TermList createList(int initialSize)
  {
    return new TermListImpl(initialSize);
  }
  
  public TermNumber createNumber(Float value)
  {
    return (TermNumber)new TermNumberImpl().setValue(value);
  }
  
  public TermNumber createNumber(String value, int unary)
  {
    return (TermNumber)new TermNumberImpl().setValue(convertFloat(value, 
      null, unary));
  }
  
  public TermNumeric<?> createNumeric(String value, int unary)
  {
    try
    {
      return createInteger(value, unary);
    }
    catch (IllegalArgumentException e) {}
    return createNumber(value, unary);
  }
  
  public TermNumeric<Float> createDimension(String value, int unary)
  {
    TermNumeric.Unit[] arrayOfUnit;
    int j = (arrayOfUnit = TermNumeric.Unit.values()).length;
    for (int i = 0; i < j; i++)
    {
      TermNumeric.Unit unit = arrayOfUnit[i];
      if (value.matches("^[0-9]*\\.?[0-9]+" + unit.value() + "$"))
      {
        Float f = convertFloat(value, unit.value(), unary);
        if (unit.isAngle()) {
          return (TermNumeric)new TermAngleImpl().setUnit(
            unit).setValue(f);
        }
        if (unit.isFrequency()) {
          return (TermNumeric)new TermFrequencyImpl()
            .setUnit(unit).setValue(f);
        }
        if (unit.isLength()) {
          return (TermNumeric)new TermLengthImpl().setUnit(
            unit).setValue(f);
        }
        if (unit.isTime()) {
          return (TermNumeric)new TermTimeImpl().setUnit(
            unit).setValue(f);
        }
      }
    }
    return null;
  }
  
  public <K, V> TermPair<K, V> createPair(K key, V value)
  {
    return (TermPair)new TermPairImpl().setKey(key)
      .setValue(value);
  }
  
  public TermPercent createPercent(Float value)
  {
    return (TermPercent)new TermPercentImpl().setValue(value);
  }
  
  public TermPercent createPercent(String value, int unary)
  {
    return (TermPercent)new TermPercentImpl().setValue(convertFloat(
      value, "%", unary));
  }
  
  public TermString createString(String value)
  {
    return new TermStringImpl().setValue(value);
  }
  
  public <V> Term<V> createTerm(V value)
  {
    return new TermImpl().setValue(value);
  }
  
  public TermTime createTime(Float value)
  {
    return new TermTimeImpl().setValue(value);
  }
  
  public TermTime createTime(String value, TermNumeric.Unit unit, int unary)
  {
    return (TermTime)new TermTimeImpl().setUnit(unit).setValue(
      convertFloat(value, unit.value(), unary));
  }
  
  public TermURI createURI(String value)
  {
    return new TermURIImpl().setValue(value);
  }
  
  public TermURI createURI(String value, URL base)
  {
    return new TermURIImpl().setValue(value).setBase(base);
  }
  
  protected Float convertFloat(String value, String unit, int unary)
    throws IllegalArgumentException
  {
    try
    {
      value = value.trim().toLowerCase();
      if (unit != null) {
        value = value.replaceAll(unit + "$", "");
      }
      return Float.valueOf(Float.parseFloat(value) * unary);
    }
    catch (NumberFormatException e)
    {
      throw new IllegalArgumentException(
        "Invalid number format " + value, e);
    }
    catch (NullPointerException e)
    {
      throw new IllegalArgumentException("Invalid null format");
    }
  }
  
  protected Integer convertInteger(String value, String unit, int unary)
    throws IllegalArgumentException
  {
    try
    {
      value = value.trim().toLowerCase();
      if (unit != null) {
        value = value.replaceAll(unit + "$", "");
      }
      return Integer.valueOf(Integer.valueOf(value).intValue() * unary);
    }
    catch (NumberFormatException e)
    {
      throw new IllegalArgumentException(
        "Invalid number format " + value, e);
    }
    catch (NullPointerException e)
    {
      throw new IllegalArgumentException("Invalid null format");
    }
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.TermFactoryImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.CombinedSelector.Specificity;
import cz.vutbr.web.css.CombinedSelector.Specificity.Level;
import java.util.Arrays;

public class CombinedSelectorImpl$SpecificityImpl
  implements CombinedSelector.Specificity
{
  protected int[] spec = new int[CombinedSelector.Specificity.Level.values().length];
  
  public int compareTo(CombinedSelector.Specificity o)
  {
    if (get(CombinedSelector.Specificity.Level.A) > o.get(CombinedSelector.Specificity.Level.A)) {
      return 1;
    }
    if (get(CombinedSelector.Specificity.Level.A) < o.get(CombinedSelector.Specificity.Level.A)) {
      return -1;
    }
    if (get(CombinedSelector.Specificity.Level.B) > o.get(CombinedSelector.Specificity.Level.B)) {
      return 1;
    }
    if (get(CombinedSelector.Specificity.Level.B) < o.get(CombinedSelector.Specificity.Level.B)) {
      return -1;
    }
    if (get(CombinedSelector.Specificity.Level.C) > o.get(CombinedSelector.Specificity.Level.C)) {
      return 1;
    }
    if (get(CombinedSelector.Specificity.Level.C) < o.get(CombinedSelector.Specificity.Level.C)) {
      return -1;
    }
    if (get(CombinedSelector.Specificity.Level.D) > o.get(CombinedSelector.Specificity.Level.D)) {
      return 1;
    }
    if (get(CombinedSelector.Specificity.Level.D) < o.get(CombinedSelector.Specificity.Level.D)) {
      return -1;
    }
    return 0;
  }
  
  public int get(CombinedSelector.Specificity.Level level)
  {
    switch (level)
    {
    case A: 
      return spec[0];
    case B: 
      return spec[1];
    case C: 
      return spec[2];
    case D: 
      return spec[3];
    }
    return 0;
  }
  
  public void add(CombinedSelector.Specificity.Level level)
  {
    switch (level)
    {
    case A: 
      spec[0] += 1;
    case B: 
      spec[1] += 1;
    case C: 
      spec[2] += 1;
    case D: 
      spec[3] += 1;
    }
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = 1;
    result = 31 * result + Arrays.hashCode(spec);
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (!(obj instanceof SpecificityImpl)) {
      return false;
    }
    SpecificityImpl other = (SpecificityImpl)obj;
    if (!Arrays.equals(spec, spec)) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.CombinedSelectorImpl.SpecificityImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.CombinedSelector;
import cz.vutbr.web.css.Declaration;
import cz.vutbr.web.css.RuleBlock.Priority;
import cz.vutbr.web.css.RuleSet;
import java.util.Collections;
import java.util.List;

public class RuleSetImpl
  extends AbstractRuleBlock<Declaration>
  implements RuleSet
{
  protected List<CombinedSelector> selectors;
  
  protected RuleSetImpl(RuleBlock.Priority priority)
  {
    super(priority);
    selectors = Collections.emptyList();
  }
  
  protected RuleSetImpl(RuleSet rs)
  {
    super(rs.getPriority());
    selectors = rs.getSelectors();
    replaceAll(rs.asList());
  }
  
  public List<CombinedSelector> getSelectors()
  {
    return selectors;
  }
  
  public RuleSet setSelectors(List<CombinedSelector> selectors)
  {
    this.selectors = selectors;
    return this;
  }
  
  public String toString()
  {
    return toString(0);
  }
  
  public String toString(int depth)
  {
    StringBuilder sb = new StringBuilder();
    
    sb = OutputUtil.appendTimes(sb, "\t", depth);
    sb = OutputUtil.appendList(sb, selectors, ", ");
    
    sb.append(" {\n");
    sb = OutputUtil.appendList(sb, list, "", depth + 1);
    sb = OutputUtil.appendTimes(sb, "\t", depth);
    sb.append("}\n");
    
    return sb.toString();
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = super.hashCode();
    result = 31 * result + (
      selectors == null ? 0 : selectors.hashCode());
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (!super.equals(obj)) {
      return false;
    }
    if (!(obj instanceof RuleSetImpl)) {
      return false;
    }
    RuleSetImpl other = (RuleSetImpl)obj;
    if (selectors == null)
    {
      if (selectors != null) {
        return false;
      }
    }
    else if (!selectors.equals(selectors)) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.RuleSetImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.CombinedSelector.Specificity;
import cz.vutbr.web.css.CombinedSelector.Specificity.Level;
import cz.vutbr.web.css.Selector.ElementClass;
import org.w3c.dom.Element;

public class SelectorImpl$ElementClassImpl
  implements Selector.ElementClass
{
  private String className;
  
  protected SelectorImpl$ElementClassImpl(String className)
  {
    setClassName(className);
  }
  
  public void computeSpecificity(CombinedSelector.Specificity spec)
  {
    spec.add(CombinedSelector.Specificity.Level.C);
  }
  
  public boolean matches(Element e)
  {
    return ElementUtil.matchesClass(e, className);
  }
  
  public String getClassName()
  {
    return className;
  }
  
  public Selector.ElementClass setClassName(String className)
  {
    if (className == null) {
      throw new IllegalArgumentException("Invalid element class (null)");
    }
    this.className = className;
    return this;
  }
  
  public String toString()
  {
    return "." + className;
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = 1;
    result = 31 * result + (
      className == null ? 0 : className.hashCode());
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (!(obj instanceof ElementClassImpl)) {
      return false;
    }
    ElementClassImpl other = (ElementClassImpl)obj;
    if (className == null)
    {
      if (className != null) {
        return false;
      }
    }
    else if (!className.equals(className)) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.SelectorImpl.ElementClassImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.RuleBlock.Priority;
import cz.vutbr.web.css.RuleImport;
import java.util.List;

@Deprecated
public class RuleImportImpl
  extends AbstractRuleBlock<String>
  implements RuleImport
{
  protected String uri;
  
  protected RuleImportImpl(RuleBlock.Priority priority)
  {
    super(priority);
    uri = "";
  }
  
  public String getURI()
  {
    return uri;
  }
  
  public RuleImport setURI(String uri)
  {
    if (uri == null) {
      return this;
    }
    this.uri = uri.replaceAll("^url\\(", "")
      .replaceAll("\\)$", "")
      .replaceAll("^'", "")
      .replaceAll("^\"", "")
      .replaceAll("'$", "")
      .replaceAll("\"$", "");
    return this;
  }
  
  public String toString(int depth)
  {
    StringBuilder sb = new StringBuilder();
    
    sb.append("@import ").append("url('")
      .append(uri).append("')");
    if (list.size() != 0) {
      sb.append(" ");
    }
    sb = OutputUtil.appendList(sb, list, ", ");
    sb.append(";\n");
    
    return sb.toString();
  }
  
  public String toString()
  {
    return toString(0);
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = super.hashCode();
    result = 31 * result + (uri == null ? 0 : uri.hashCode());
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (!super.equals(obj)) {
      return false;
    }
    if (!(obj instanceof RuleImportImpl)) {
      return false;
    }
    RuleImportImpl other = (RuleImportImpl)obj;
    if (uri == null)
    {
      if (uri != null) {
        return false;
      }
    }
    else if (!uri.equals(uri)) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.RuleImportImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.TermTime;

public class TermTimeImpl
  extends TermNumericImpl<Float>
  implements TermTime
{
  public TermTime setValue(Float value)
  {
    if ((value == null) || (new Float(0.0F).compareTo(value) > 0)) {
      throw new IllegalArgumentException("Null or negative value for CSS time");
    }
    this.value = value;
    return this;
  }
}

/* Location:
 * Qualified Name:     cz.vutbr.web.csskit.TermTimeImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package cz.vutbr.web.csskit;

import cz.vutbr.web.css.CombinedSelector.Specificity;
import cz.vutbr.web.css.CombinedSelector.Specificity.Level;
import cz.vutbr.web.css.Selector;
import cz.vutbr.web.css.Selector.Combinator;
import cz.vutbr.web.css.Selector.ElementAttribute;
import cz.vutbr.web.css.Selector.ElementClass;
import cz.vutbr.web.css.Selector.ElementDOM;
import cz.vutbr.web.css.Selector.ElementID;
import cz.vutbr.web.css.Selector.ElementName;
import cz.vutbr.web.css.Selector.Operator;
import cz.vutbr.web.css.Selector.PseudoDeclaration;
import cz.vutbr.web.css.Selector.PseudoPage;
import cz.vutbr.web.css.Selector.SelectorPart;
import java.util.HashMap;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class SelectorImpl
  extends AbstractRule<Selector.SelectorPart>
  implements Selector
{
  protected Selector.Combinator combinator;
  
  public Selector.Combinator getCombinator()
  {
    return combinator;
  }
  
  public Selector setCombinator(Selector.Combinator combinator)
  {
    this.combinator = combinator;
    return this;
  }
  
  public String toString()
  {
    StringBuilder sb = new StringBuilder();
    if (combinator != null) {
      sb.append(combinator.value());
    }
    sb = OutputUtil.appendList(sb, list, "");
    
    return sb.toString();
  }
  
  public String getClassName()
  {
    String className = null;
    for (Selector.SelectorPart item : list) {
      if ((item instanceof Selector.ElementClass)) {
        className = ((Selector.ElementClass)item).getClassName();
      }
    }
    return className;
  }
  
  public String getIDName()
  {
    String idName = null;
    for (Selector.SelectorPart item : list) {
      if ((item instanceof Selector.ElementID)) {
        idName = ((Selector.ElementID)item).getID();
      }
    }
    return idName;
  }
  
  public String getElementName()
  {
    String elementName = null;
    for (Selector.SelectorPart item : list) {
      if ((item instanceof Selector.ElementName)) {
        elementName = ((Selector.ElementName)item).getName();
      }
    }
    return elementName;
  }
  
  public Selector.PseudoDeclaration getPseudoElement()
  {
    Selector.PseudoDeclaration ret = null;
    for (Selector.SelectorPart item : list) {
      if ((item instanceof Selector.PseudoPage))
      {
        ret = ((Selector.PseudoPage)item).getDeclaration();
        if (ret.isPseudoElement()) {
          break;
        }
        ret = null;
      }
    }
    return ret;
  }
  
  public boolean matches(Element e)
  {
    for (Selector.SelectorPart item : list) {
      if ((item == null) || (!item.matches(e))) {
        return false;
      }
    }
    return true;
  }
  
  public void computeSpecificity(CombinedSelector.Specificity spec)
  {
    for (Selector.SelectorPart item : list) {
      item.computeSpecificity(spec);
    }
  }
  
  public int hashCode()
  {
    int prime = 31;
    int result = super.hashCode();
    result = 31 * result + (
      combinator == null ? 0 : combinator.hashCode());
    return result;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
  
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd