本文整理汇总了Java中org.openide.xml.XMLUtil.toAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:Java XMLUtil.toAttributeValue方法的具体用法?Java XMLUtil.toAttributeValue怎么用?Java XMLUtil.toAttributeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.xml.XMLUtil
的用法示例。
在下文中一共展示了XMLUtil.toAttributeValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFieldHeader
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private StringBuilder getFieldHeader(VariableElement fdoc) {
StringBuilder sb = new StringBuilder();
sb.append("<pre>"); //NOI18N
fdoc.getAnnotationMirrors().forEach((annotationDesc) -> {
appendAnnotation(sb, annotationDesc, true);
});
fdoc.getModifiers().forEach((modifier) -> {
sb.append(modifier).append(' '); //NOI18N
});
appendType(sb, fdoc.asType(), false, false, false);
sb.append(" <b>").append(fdoc.getSimpleName()).append("</b>"); //NOI18N
String val = null;
try {
val = XMLUtil.toAttributeValue(fdoc.getConstantValue().toString());
} catch (Exception ex) {}
if (val != null && val.length() > 0)
sb.append(" = ").append(val); //NOI18N
sb.append("</pre>"); //NOI18N
return sb;
}
示例2: encodePrimitiveValue
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/** Encodes specified value into a String. Supported types are: <UL>
* <LI> Class
* <LI> String
* <LI> Integer, Short, Byte, Long, Float, Double, Boolean, Character </UL>
*
* @param value value to encode.
* @return String containing encoded value or null if specified object is not of supported type
*/
public static String encodePrimitiveValue(Object value) {
if (value instanceof Integer || value instanceof Short
|| value instanceof Byte || value instanceof Long
|| value instanceof Float || value instanceof Double
|| value instanceof Boolean || value instanceof Character)
return value.toString();
if (value instanceof String) {
try {
XMLUtil.toAttributeValue((String)value);
return (String) value;
} catch (CharConversionException ex) {
// can't be stored in XML document, needs to be encoded as bytes
return null;
}
}
if (value instanceof Class)
return ((Class)value).getName();
if (value == null)
return "null"; // NOI18N
return null; // is not a primitive type
}
示例3: checkCoord
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
@Messages("ERR_Coord_breaks_pom=Error: Group Id or Artifact Id would invalidate Maven POM xml file.")
private boolean checkCoord(JTextField field) {
String coord = field.getText();
boolean result = false;
try {
String escaped = XMLUtil.toAttributeValue(coord);
result = escaped.length() == coord.length() && coord.indexOf(">") == -1
&& coord.indexOf(" ") == -1;
} catch (CharConversionException ex) {
// ignore this one
}
if (result) {
result = !containsMultiByte(coord);
} else {
category.setErrorMessage(ERR_Coord_breaks_pom());
}
if (result) {
category.setErrorMessage(null);
}
return result;
}
示例4: escape
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
static String escape(String s) {
if (s != null) {
//unescape unicode sequences first (would be better if Pretty would not print them, but that might be more difficult):
Matcher matcher = UNICODE_SEQUENCE.matcher(s);
if (matcher.find()) {
StringBuilder result = new StringBuilder();
int lastReplaceEnd = 0;
do {
result.append(s.substring(lastReplaceEnd, matcher.start()));
int ch = Integer.parseInt(matcher.group(1), 16);
result.append((char) ch);
lastReplaceEnd = matcher.end();
} while (matcher.find());
result.append(s.substring(lastReplaceEnd));
s = result.toString();
}
try {
return XMLUtil.toAttributeValue(s);
} catch (CharConversionException ex) {
}
}
return null;
}
示例5: perform
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
@Override
public void perform() {
if (!terminal().isVisibleInContainer()) {
return ;
}
String newTitle = terminal().getTitle();
if (terminal().isConnected() && newTitle != null) {
String escaped;
try {
escaped = XMLUtil.toAttributeValue(newTitle);
} catch (CharConversionException ex) {
escaped = newTitle;
}
newTitle = "<html><b>" + escaped + "</b></html>"; // NOI18N
}
container().setTitle(terminal(), newTitle);
}
示例6: writeProperties
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private static void writeProperties(
@NonNull final Map<String,String> props,
@NonNull final Element element,
@NonNull final Document doc) throws IOException {
final Collection<String> sortedProps = new TreeSet<>(props.keySet());
for (String name : sortedProps) {
final String val = props.get(name);
try {
XMLUtil.toAttributeValue(name);
XMLUtil.toAttributeValue(val);
final Element propElement = doc.createElement(ELM_PROPERTY);
propElement.setAttribute(ATTR_NAME,name);
propElement.setAttribute(ATTR_VALUE,val);
element.appendChild(propElement);
} catch (CharConversionException e) {
LOG.log(
Level.WARNING,
"Cannot store property: {0} value: {1}", //NOI18N
new Object[] {
name,
val
});
}
}
}
示例7: escape
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private static String escape(String s) {
if (s != null) {
try {
return XMLUtil.toAttributeValue(s);
} catch (Exception ex) {}
}
return s;
}
示例8: escapeAttrValue
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private String escapeAttrValue(String attrValue) {
try {
return XMLUtil.toAttributeValue(attrValue);
} catch (CharConversionException e) {
return null;
}
}
示例9: escape
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
static String escape(String s) {
if (s != null) {
try {
return XMLUtil.toAttributeValue(s);
} catch (CharConversionException ex) {
}
}
return null;
}
示例10: escape
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
@CheckForNull
public static String escape(@NonNull final String s) {
if (s != null) {
try {
return XMLUtil.toAttributeValue(s);
} catch (CharConversionException ex) {
}
}
return null;
}
示例11: escape
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
static String escape(String s) {
if (s != null) {
try {
return XMLUtil.toAttributeValue(s);
} catch (Exception ex) {}
}
return s;
}
示例12: escape
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private static String escape(String s) {
if (s != null) {
try {
return XMLUtil.toAttributeValue(s);
} catch (Exception ex) {
}
}
return s;
}
示例13: disableHtmlName
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private void disableHtmlName() {
Controller.getDefault().removeFromUpdater(this);
String escaped;
try {
escaped = XMLUtil.toAttributeValue(io.getName() + " ");
} catch (CharConversionException e) {
escaped = io.getName() + " ";
}
//#88204 apostophes are escaped in xm but not html
io.getIOContainer().setTitle(this, escaped.replace("'", "'"));
}
示例14: run
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
public void run() {
List<OutputTab> toRemove = null;
for (OutputTab t : components) {
NbIO io = t.getIO();
if (!ioToTab.containsKey(io)) {
if (toRemove == null) {
toRemove = new LinkedList<OutputTab>();
}
toRemove.add(t);
continue;
}
if (LOG) {
log ("Update name for " + io.getName() + " stream " +
"closed is " + io.isStreamClosed());
}
String escaped;
try {
escaped = XMLUtil.toAttributeValue(io.getName());
} catch (CharConversionException e) {
escaped = io.getName();
}
String name = io.isStreamClosed() ? io.getName() + " " : //NOI18N
(DONT_USE_HTML ? io.getName() + " * " : "<html><b>" + escaped + " </b> </html>"); //NOI18N
if (LOG) {
log(" set name to " + name);
}
//#88204 apostophes are escaped in xm but not html
io.getIOContainer().setTitle(t, name.replace("'", "'"));
}
if (toRemove != null) {
components.removeAll(toRemove);
}
nameUpdater = null;
}