本文整理汇总了Java中com.intellij.openapi.util.JDOMUtil.writeElement方法的典型用法代码示例。如果您正苦于以下问题:Java JDOMUtil.writeElement方法的具体用法?Java JDOMUtil.writeElement怎么用?Java JDOMUtil.writeElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.JDOMUtil
的用法示例。
在下文中一共展示了JDOMUtil.writeElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputFieldsText
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private static String getInputFieldsText(Map<String, String> parameters) {
Element element = new Element(RemoteTemplatesFactory.TEMPLATE);
for (Map.Entry<String, String> entry : parameters.entrySet()) {
Element field = new Element(ArchivedProjectTemplate.INPUT_FIELD);
field.setText(entry.getValue());
field.setAttribute(RemoteTemplatesFactory.INPUT_DEFAULT, entry.getKey());
element.addContent(field);
}
return JDOMUtil.writeElement(element);
}
示例2: deserializeState
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
@Nullable
public static <T> T deserializeState(@Nullable Element stateElement, Class <T> stateClass, @Nullable T mergeInto) {
if (stateElement == null) {
return mergeInto;
}
else if (stateClass == Element.class) {
return (T)stateElement;
}
else if (JDOMExternalizable.class.isAssignableFrom(stateClass)) {
if (mergeInto != null) {
String elementText = JDOMUtil.writeElement(stateElement, "\n");
LOG.error("State is " + stateClass.getName() + ", merge into is " + mergeInto.toString() + ", state element text is " + elementText);
}
T t = ReflectionUtil.newInstance(stateClass);
try {
((JDOMExternalizable)t).readExternal(stateElement);
return t;
}
catch (InvalidDataException e) {
throw new RuntimeException(e);
}
}
else if (mergeInto == null) {
return XmlSerializer.deserialize(stateElement, stateClass);
}
else {
XmlSerializer.deserializeInto(mergeInto, stateElement);
return mergeInto;
}
}
示例3: writeOutput
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private synchronized void writeOutput(@NotNull final CommonProblemDescriptor[] descriptions, @NotNull RefEntity refElement) {
final Element parentNode = new Element(InspectionsBundle.message("inspection.problems"));
exportResults(descriptions, refElement, parentNode);
final List list = parentNode.getChildren();
@NonNls final String ext = ".xml";
final String fileName = ourOutputPath + File.separator + myToolWrapper.getShortName() + ext;
final PathMacroManager pathMacroManager = PathMacroManager.getInstance(getContext().getProject());
PrintWriter printWriter = null;
try {
new File(ourOutputPath).mkdirs();
final File file = new File(fileName);
final CharArrayWriter writer = new CharArrayWriter();
if (!file.exists()) {
writer.append("<").append(InspectionsBundle.message("inspection.problems")).append(" " + GlobalInspectionContextBase.LOCAL_TOOL_ATTRIBUTE + "=\"")
.append(Boolean.toString(myToolWrapper instanceof LocalInspectionToolWrapper)).append("\">\n");
}
for (Object o : list) {
final Element element = (Element)o;
pathMacroManager.collapsePaths(element);
JDOMUtil.writeElement(element, writer, "\n");
}
printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName, true), CharsetToolkit.UTF8_CHARSET)));
printWriter.append("\n");
printWriter.append(writer.toString());
}
catch (IOException e) {
LOG.error(e);
}
finally {
if (printWriter != null) {
printWriter.close();
}
}
}
示例4: serialize
import com.intellij.openapi.util.JDOMUtil; //导入方法依赖的package包/类
private static String serialize(InspectionProfileImpl profile) throws WriteExternalException {
Element element = new Element("profile");
profile.writeExternal(element);
return JDOMUtil.writeElement(element);
}