Would the following be valid as a feature request - getting / setting the ";" delimited properties of the STYLE attribute of a tag? Or is there already a way to do this?
e.g. (very rough and ready example)
public String getStyleProperty(Tag tag, String propName) {
String prop = "";
String ret = "";
String styleString = tag.getAttribute("STYLE");
if (styleString != null) {
StringTokenizer st = new StringTokenizer(styleString,":;");
while (ret == "" && st.hasMoreTokens()) {
prop = st.nextToken().trim();
if (prop.toUpperCase().equals(propName.toUpperCase())) {
if (st.hasMoreTokens()) {
ret = st.nextToken();
}
}
else {
if (st.hasMoreTokens()) {
st.nextToken();
}
}
}
}
return ret;
}
public void setStyleProperty(Tag tag, String propName, String propValue) {
String prop = "";
String value = "";
String newStyle = "";
boolean set = false;
String styleString = tag.getAttribute("STYLE");
if (styleString != null) {
StringTokenizer st = new StringTokenizer(styleString,":;");
while (st.hasMoreTokens()) {
prop = st.nextToken().trim();
newStyle += prop + ":";
value = "";
if (prop.toUpperCase().equals(propName.toUpperCase())) {
if (st.hasMoreTokens()) {
value = propValue;
set = true;
st.nextToken();
}
}
else {
if (st.hasMoreTokens()) {
value = st.nextToken();
}
}
Would the following be valid as a feature request - getting / setting the ";" delimited properties of the STYLE attribute of a tag? Or is there already a way to do this?
e.g. (very rough and ready example)
public String getStyleProperty(Tag tag, String propName) {
String prop = "";
String ret = "";
String styleString = tag.getAttribute("STYLE");
if (styleString != null) {
StringTokenizer st = new StringTokenizer(styleString,":;");
while (ret == "" && st.hasMoreTokens()) {
prop = st.nextToken().trim();
if (prop.toUpperCase().equals(propName.toUpperCase())) {
if (st.hasMoreTokens()) {
ret = st.nextToken();
}
}
else {
if (st.hasMoreTokens()) {
st.nextToken();
}
}
}
}
return ret;
}
public void setStyleProperty(Tag tag, String propName, String propValue) {
String prop = "";
String value = "";
String newStyle = "";
boolean set = false;
String styleString = tag.getAttribute("STYLE");
if (styleString != null) {
StringTokenizer st = new StringTokenizer(styleString,":;");
while (st.hasMoreTokens()) {
prop = st.nextToken().trim();
newStyle += prop + ":";
value = "";
if (prop.toUpperCase().equals(propName.toUpperCase())) {
if (st.hasMoreTokens()) {
value = propValue;
set = true;
st.nextToken();
}
}
else {
if (st.hasMoreTokens()) {
value = st.nextToken();
}
}
newStyle += value + ";";
}
}
if (!set) {
newStyle += propName + ":" + propValue + ";";
}
tag.setAttribute("STYLE", newStyle);
}
Enter it as a Request For Enhancement on the StyleTag class...
http://sourceforge.net/tracker/?atid=381402&group_id=24399&func=browse
...or do it yourself, it's easy to become a developer on the project.