当前位置: 首页>>代码示例>>Java>>正文


Java XMLUtil.toAttributeValue方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ElementJavadoc.java

示例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
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:GandalfPersistenceManager.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:BasicInfoPanel.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:BreadCrumbsNodeImpl.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:Task.java

示例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
                });
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:RemotePlatformProvider.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ElementCompletionItem.java

示例8: escapeAttrValue

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private String escapeAttrValue(String attrValue) {
    try {
        return XMLUtil.toAttributeValue(attrValue);
    } catch (CharConversionException e) {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:JavaElementRefFinder.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:UIUtilities.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Utils.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ChangeTypeFix.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:HtmlCompletionItem.java

示例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("&apos;", "'"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:OutputTab.java

示例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>&nbsp;</html>"); //NOI18N

        if (LOG) {
            log("  set name to " + name);
        }
        //#88204 apostophes are escaped in xm but not html
        io.getIOContainer().setTitle(t, name.replace("&apos;", "'"));
    }
    if (toRemove != null) {
        components.removeAll(toRemove);
    }
    nameUpdater = null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:Controller.java


注:本文中的org.openide.xml.XMLUtil.toAttributeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。