本文整理汇总了Java中org.w3c.css.sac.LexicalUnit.SAC_STRING_VALUE属性的典型用法代码示例。如果您正苦于以下问题:Java LexicalUnit.SAC_STRING_VALUE属性的具体用法?Java LexicalUnit.SAC_STRING_VALUE怎么用?Java LexicalUnit.SAC_STRING_VALUE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.w3c.css.sac.LexicalUnit
的用法示例。
在下文中一共展示了LexicalUnit.SAC_STRING_VALUE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStringValue
public String getStringValue() throws DOMException {
short lexicalUnit = value.getLexicalUnitType();
if ((lexicalUnit == LexicalUnit.SAC_IDENT) || (lexicalUnit == LexicalUnit.SAC_STRING_VALUE)
|| (lexicalUnit == LexicalUnit.SAC_URI))
return value.getStringValue();
// TODO There are more cases to catch of getLexicalUnitType()
throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
}
示例2: getPrimitiveType
public short getPrimitiveType() {
switch (value.getLexicalUnitType()) {
case LexicalUnit.SAC_IDENT:
return CSS_IDENT;
case LexicalUnit.SAC_INTEGER:
case LexicalUnit.SAC_REAL:
return CSS_NUMBER;
case LexicalUnit.SAC_URI:
return CSS_URI;
case LexicalUnit.SAC_PERCENTAGE:
return CSS_PERCENTAGE;
case LexicalUnit.SAC_PIXEL:
return CSS_PX;
case LexicalUnit.SAC_CENTIMETER:
return CSS_CM;
case LexicalUnit.SAC_EM:
return CSS_EMS;
case LexicalUnit.SAC_EX:
return CSS_EXS;
case LexicalUnit.SAC_INCH:
return CSS_IN;
case LexicalUnit.SAC_STRING_VALUE:
return CSS_STRING;
case LexicalUnit.SAC_DIMENSION:
return CSS_DIMENSION;
case LexicalUnit.SAC_OPERATOR_COMMA:
return CSS_CUSTOM; // TODO don't think this is right, see bug
// #278139
case LexicalUnit.SAC_INHERIT:
return CSS_INHERIT;
}
// TODO Auto-generated method stub
throw new UnsupportedOperationException(
"NOT YET IMPLEMENTED - LexicalUnit type: " + value.getLexicalUnitType());
}
示例3: createValue
/**
* Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
*/
public Value createValue(LexicalUnit lu, CSSEngine engine)
throws DOMException {
switch (lu.getLexicalUnitType()) {
case LexicalUnit.SAC_INHERIT:
return ValueConstants.INHERIT_VALUE;
default:
throw createInvalidLexicalUnitDOMException
(lu.getLexicalUnitType());
case LexicalUnit.SAC_IDENT:
case LexicalUnit.SAC_STRING_VALUE:
}
ListValue result = new ListValue();
for (;;) {
switch (lu.getLexicalUnitType()) {
case LexicalUnit.SAC_STRING_VALUE:
result.append(new StringValue(CSSPrimitiveValue.CSS_STRING,
lu.getStringValue()));
lu = lu.getNextLexicalUnit();
break;
case LexicalUnit.SAC_IDENT:
StringBuffer sb = new StringBuffer(lu.getStringValue());
lu = lu.getNextLexicalUnit();
if (lu != null && isIdentOrNumber(lu)) {
do {
sb.append(' ');
switch (lu.getLexicalUnitType()) {
case LexicalUnit.SAC_IDENT:
sb.append(lu.getStringValue());
break;
case LexicalUnit.SAC_INTEGER:
//Some font names contain integer values but are not quoted!
//Example: "Univers 45 Light"
sb.append(Integer.toString(lu.getIntegerValue()));
}
lu = lu.getNextLexicalUnit();
} while (lu != null && isIdentOrNumber(lu));
result.append(new StringValue(CSSPrimitiveValue.CSS_STRING,
sb.toString()));
} else {
String id = sb.toString();
String s = id.toLowerCase().intern();
Value v = (Value)values.get(s);
result.append((v != null)
? v
: new StringValue
(CSSPrimitiveValue.CSS_STRING, id));
}
}
if (lu == null)
return result;
if (lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA)
throw createInvalidLexicalUnitDOMException
(lu.getLexicalUnitType());
lu = lu.getNextLexicalUnit();
if (lu == null)
throw createMalformedLexicalUnitDOMException();
}
}
示例4: buildString
@Override
public String buildString(BuildStringStrategy strategy) {
short type = getLexicalUnitType();
String text = simpleAsString();
if (text == null) {
switch (type) {
case LexicalUnit.SAC_URI:
text = "url(" + getStringValue() + ")";
break;
case LexicalUnit.SAC_RGBCOLOR:
int[] rgb = getRgb();
if (rgb != null) {
text = ColorUtil.rgbToColorString(rgb);
break;
}
// else fall through to the function branch
case LexicalUnit.SAC_COUNTER_FUNCTION:
case LexicalUnit.SAC_COUNTERS_FUNCTION:
case LexicalUnit.SAC_RECT_FUNCTION:
case LexicalUnit.SAC_FUNCTION:
if (ColorUtil.isColor(this)) {
text = ColorUtil.rgbToColorString(ColorUtil
.colorToRgb(this));
break;
} else if (ColorUtil.isRgba(this) || ColorUtil.isHsla(this)) {
float alpha = params.get(params.size() - 1)
.getContainedValue().getFloatValue();
rgb = ColorUtil.colorToRgb(this);
if (alpha == 0.0f && rgb[0] == 0 && rgb[1] == 0
&& rgb[2] == 0) {
text = "transparent";
break;
} else if (alpha == 1.0f) {
text = ColorUtil.rgbToColorString(ColorUtil
.colorToRgb(this));
break;
} else if (params.size() == 2 || ColorUtil.isHsla(this)) {
String alphaText = alpha == 0.0f ? "0"
: CSS_FLOAT_FORMAT.format(alpha);
text = "rgba(" + rgb[0] + ", " + rgb[1] + ", " + rgb[2]
+ ", " + alphaText + ")";
break;
}
}
text = fname + "(" + params.buildString(strategy) + ")";
break;
case LexicalUnit.SAC_IDENT:
text = getStringValue();
break;
case LexicalUnit.SAC_STRING_VALUE:
// @@SEEME. not exact
text = "\"" + getStringValue() + "\"";
break;
case LexicalUnit.SAC_ATTR:
text = "attr(" + getStringValue() + ")";
break;
case LexicalUnit.SAC_UNICODERANGE:
text = "@@TODO";
break;
case LexicalUnit.SAC_SUB_EXPRESSION:
text = strategy.build(getParameterList());
break;
default:
text = "@unknown";
break;
}
}
return text;
}