aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/fo/GenericShorthandParser.java
blob: 90f2b725d6843c5a1dcde65c1478094813a306ca (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package org.apache.fop.fo;

import java.util.Vector;
import java.util.Enumeration;

public class GenericShorthandParser implements ShorthandParser {

  protected Vector list; // Vector of Property objects

  public GenericShorthandParser(ListProperty listprop) {
    this.list=listprop.getList();
  }

  protected Property getElement(int index) {
    if (list.size() > index) return (Property)list.elementAt(index);
    else return null;
  }

  protected int count() {
    return list.size();
  }

  // Stores 1 to 3 values for border width, style, color
  // Used for: border, border-top, border-right etc
  public Property getValueForProperty(String propName, Property.Maker maker,
    PropertyList propertyList) {
    Property prop = null;
    // Check for keyword "inherit"
    if (count() == 1) {
      String sval = ((Property)list.elementAt(0)).getString();
      if (sval != null && sval.equals("inherit")) {
	return propertyList.getFromParent(propName);
      }
    }
    return convertValueForProperty(propName, maker, propertyList);
  }


  protected Property convertValueForProperty(String propName, Property.Maker maker,
    PropertyList propertyList) {
    Property prop = null;
    // Try each of the stored values in turn
    Enumeration eprop = list.elements();
    while (eprop.hasMoreElements() && prop == null) {
      Property p = (Property)eprop.nextElement();
      prop = maker.convertShorthandProperty(propertyList, p, null);
    }
    return prop;
  }
}