use of org.freeplane.n3.nanoxml.StdXMLReader in project intellij-community by JetBrains.
the class XmlPropertiesIndex method parse.
@Nullable
private static MyIXMLBuilderAdapter parse(CharSequence text, boolean stopIfAccepted) {
StdXMLReader reader = new StdXMLReader(CharArrayUtil.readerFromCharSequence(text)) {
@Override
public Reader openStream(String publicID, String systemID) throws IOException {
if (!HTTP_JAVA_SUN_COM_DTD_PROPERTIES_DTD.equals(systemID))
throw new IOException();
return new StringReader(" ");
}
};
MyIXMLBuilderAdapter builder = new MyIXMLBuilderAdapter(stopIfAccepted);
NanoXmlUtil.parse(reader, builder);
return builder;
}
use of org.freeplane.n3.nanoxml.StdXMLReader in project jwt by emweb.
the class XmlMessageParserTest method readXml.
public Result readXml(InputStream stream) throws Exception {
XmlMessageParser xmlParser = new XmlMessageParser();
IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
parser.setBuilder(xmlParser);
parser.setResolver(xmlParser);
IXMLReader reader = new StdXMLReader(stream);
parser.setReader(reader);
parser.parse();
Result result = new Result();
result.map.putAll(xmlParser.getKeyValues());
result.pluralCount = xmlParser.getPluralCount();
result.pluralExpression = xmlParser.getPluralExpression();
return result;
}
use of org.freeplane.n3.nanoxml.StdXMLReader in project freeplane by freeplane.
the class WindowConfigurationStorage method unmarschall.
protected XMLElement unmarschall(final String marshalled, final JDialog dialog) {
if (marshalled != null) {
final IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
final IXMLReader xmlReader = new StdXMLReader(new StringReader(marshalled));
parser.setReader(xmlReader);
try {
final XMLElement storage = (XMLElement) parser.parse();
if (storage != null) {
x = Integer.parseInt(storage.getAttribute("x", "-1"));
y = Integer.parseInt(storage.getAttribute("y", "-1"));
width = Integer.parseInt(storage.getAttribute("width", "-1"));
height = Integer.parseInt(storage.getAttribute("height", "-1"));
UITools.setBounds(dialog, x, y, width, height);
return storage;
}
} catch (final NumberFormatException e) {
LogUtils.severe(e);
} catch (final XMLException e) {
LogUtils.severe(e);
}
}
final Frame rootFrame = JOptionPane.getFrameForComponent(dialog);
final Dimension prefSize = rootFrame.getSize();
prefSize.width = prefSize.width * 3 / 4;
prefSize.height = prefSize.height * 3 / 4;
dialog.setSize(prefSize);
return null;
}
use of org.freeplane.n3.nanoxml.StdXMLReader in project freeplane by freeplane.
the class AddOnsController method registerPlugins.
private void registerPlugins() {
final File addOnsDir = getAddOnsDir();
// in applets the addOnsDir will be null
if (addOnsDir == null)
return;
File[] addonXmlFiles = addOnsDir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".plugin.xml");
}
});
final IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
for (File file : addonXmlFiles) {
BufferedInputStream inputStream = null;
try {
inputStream = new BufferedInputStream(new FileInputStream(file));
final IXMLReader reader = new StdXMLReader(inputStream);
parser.setReader(reader);
registerInstalledAddOn(new AddOnProperties(AddOnType.PLUGIN, (XMLElement) parser.parse()));
} catch (final Exception e) {
LogUtils.warn("error parsing " + file, e);
} finally {
FileUtils.silentlyClose(inputStream);
}
}
}
use of org.freeplane.n3.nanoxml.StdXMLReader in project freeplane by freeplane.
the class ScannerController method loadScanners.
void loadScanners() throws Exception {
final File configXml = new File(pathToFile);
if (!configXml.exists()) {
LogUtils.info(pathToFile + " does not exist yet");
return;
}
try {
final IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
final IXMLReader reader = new StdXMLReader(new BufferedInputStream(new FileInputStream(configXml)));
parser.setReader(reader);
final XMLElement loader = (XMLElement) parser.parse();
final Vector<XMLElement> scannerElements = loader.getChildren();
for (XMLElement elem : scannerElements) {
scanners.add(parseScanner(elem));
}
boolean haveDefault = false;
for (Scanner scanner : scanners) {
if (scanner.isDefault()) {
if (haveDefault)
LogUtils.warn(configXml + ": multiple scanners are marked as default - fix that!");
else
haveDefault = true;
}
}
if (!haveDefault)
LogUtils.warn(configXml + ": no scanner is marked as default - fix that!");
} catch (final IOException e) {
LogUtils.warn("error parsing " + configXml, e);
}
}
Aggregations