use of org.jdom.IllegalNameException in project intellij-community by JetBrains.
the class Maven2ModelConverter method xppToElement.
private static Element xppToElement(Xpp3Dom xpp) throws RemoteException {
Element result;
try {
result = new Element(xpp.getName());
} catch (IllegalNameException e) {
Maven2ServerGlobals.getLogger().info(e);
return null;
}
Xpp3Dom[] children = xpp.getChildren();
if (children == null || children.length == 0) {
result.setText(xpp.getValue());
} else {
for (Xpp3Dom each : children) {
Element child = xppToElement(each);
if (child != null)
result.addContent(child);
}
}
return result;
}
use of org.jdom.IllegalNameException in project che by eclipse.
the class MavenModelUtil method convertXpp.
private static Element convertXpp(Xpp3Dom xpp3Dom) {
Element result;
try {
result = new Element(xpp3Dom.getName());
} catch (IllegalNameException e) {
return null;
}
Xpp3Dom[] children = xpp3Dom.getChildren();
if (children == null || children.length == 0) {
result.setText(xpp3Dom.getValue());
} else {
for (Xpp3Dom child : children) {
Element element = convertXpp(child);
if (element != null) {
result.addContent(element);
}
}
}
return result;
}
use of org.jdom.IllegalNameException in project intellij-community by JetBrains.
the class MavenJDOMUtil method doRead.
@Nullable
private static Element doRead(String text, final ErrorHandler handler) {
final LinkedList<Element> stack = new LinkedList<>();
final Element[] result = { null };
XmlBuilderDriver driver = new XmlBuilderDriver(text);
XmlBuilder builder = new XmlBuilder() {
public void doctype(@Nullable CharSequence publicId, @Nullable CharSequence systemId, int startOffset, int endOffset) {
}
public ProcessingOrder startTag(CharSequence localName, String namespace, int startoffset, int endoffset, int headerEndOffset) {
String name = localName.toString();
if (StringUtil.isEmptyOrSpaces(name))
return ProcessingOrder.TAGS;
Element newElement;
try {
newElement = new Element(name);
} catch (IllegalNameException e) {
newElement = new Element("invalidName");
}
Element parent = stack.isEmpty() ? null : stack.getLast();
if (parent == null) {
result[0] = newElement;
} else {
parent.addContent(newElement);
}
stack.addLast(newElement);
return ProcessingOrder.TAGS_AND_TEXTS;
}
public void endTag(CharSequence localName, String namespace, int startoffset, int endoffset) {
String name = localName.toString();
if (StringUtil.isEmptyOrSpaces(name))
return;
for (Iterator<Element> itr = stack.descendingIterator(); itr.hasNext(); ) {
Element element = itr.next();
if (element.getName().equals(name)) {
while (stack.removeLast() != element) {
}
break;
}
}
}
public void textElement(CharSequence text, CharSequence physical, int startoffset, int endoffset) {
stack.getLast().addContent(JDOMUtil.legalizeText(text.toString()));
}
public void attribute(CharSequence name, CharSequence value, int startoffset, int endoffset) {
}
public void entityRef(CharSequence ref, int startOffset, int endOffset) {
}
public void error(String message, int startOffset, int endOffset) {
if (handler != null)
handler.onSyntaxError();
}
};
driver.build(builder);
return result[0];
}
use of org.jdom.IllegalNameException in project intellij-community by JetBrains.
the class MavenModelConverter method xppToElement.
private static Element xppToElement(Xpp3Dom xpp) throws RemoteException {
Element result;
try {
result = new Element(xpp.getName());
} catch (IllegalNameException e) {
Maven3ServerGlobals.getLogger().info(e);
return null;
}
Xpp3Dom[] children = xpp.getChildren();
if (children == null || children.length == 0) {
result.setText(xpp.getValue());
} else {
for (Xpp3Dom each : children) {
Element child = xppToElement(each);
if (child != null)
result.addContent(child);
}
}
return result;
}
Aggregations