public LafProperties(InputStream input) throws LafException { try { document = DomUtil.parseXML(input); helper = new DomHelper(document); } catch (IOException e) { throw new LafException(e); } catch (SAXException e) { throw new LafException(e); } catch (ParserConfigurationException e) { throw new LafException(e); } }
public void installColors(UIDefaults defaults) throws LafException, XPathExpressionException { NodeList complist = helper.xpathAsNodeList(ROOT + "/color/child::*"); int complength = complist.getLength(); for (int i = 0; i < complength; ++i) { Element element = (Element) complist.item(i); String tagName = element.getTagName(); NodeList childlist = DomUtil.getChildElements(element); Color value = parseColor(ROOT + "/color/" + tagName); defaults.put(tagName, new ColorUIResource(value)); } }
public void installComponents(UIDefaults defaults, Map<String, Object> defaultValues) throws LafException, XPathExpressionException { NodeList complist = helper.xpathAsNodeList(ROOT + "/component/child::*"); int complength = complist.getLength(); for (int i = 0; i < complength; ++i) { Element element = (Element) complist.item(i); String tagName = element.getTagName(); for (String defaultKey : defaultValues.keySet()) UIManager.put(tagName + "." + defaultKey, defaultValues.get(defaultKey)); NodeList childlist = DomUtil.getChildElements(element); int childlength = childlist.getLength(); for (int j = 0; j < childlength; ++j) { Element childElement = (Element) childlist.item(j); String childName = childElement.getTagName(); Object value = getImpl(ROOT + "/component/" + tagName + "/" + childName); defaults.put(tagName + "." + childName, value); } } }
private void checkUpdate() throws IOException, SAXException, ParserConfigurationException, XPathExpressionException { String url; try { url = Registry.getProperty("updater.url"); } catch (Exception e) { throw new IOException(e.getMessage()); // i hate leaking "exception" } HttpClient client = new HttpClient(); Map<String, Object> params = new HashMap<String, Object>(); params.put("version", Build.getVersion()); params.put("release", "" + Build.getRelease()); if (PreferencesManager.getVersionIndependentPreferences() .getBoolean("updater.include.usageData", true)) { params.put("uuid", Application.getUUID()); params.put("platform.arch", Platform.getArch()); params.put("platform.os", Platform.getOS().getCanonicalName()); params.put("platform.os.version", Platform.getOS().getVersion()); params.put("locale.country", LanguageBundle.getCurrentLocale().getCountry()); params.put("locale.language", LanguageBundle.getCurrentLocale().getLanguage()); } List<NameValuePair> nvp = new ArrayList<NameValuePair>(); for (String key : params.keySet()) nvp.add(new NameValuePair(key, "" + params.get(key))); GetMethod request = new GetMethod(url); request.setQueryString(nvp.toArray(new NameValuePair[nvp.size()])); LogFactory.getLog(getClass()).info(String.format("Checking for updates: %s", request.getURI())); client.executeMethod(request); String response = request.getResponseBodyAsString(); Document doc = DomUtil.parseXMLString(response); availableRelease = XPathHelper.xpathAsDouble(doc, "/korsakow/release"); availableVersion = XPathHelper.xpathAsString(doc, "/korsakow/version"); message = XPathHelper.xpathAsString(doc, "/korsakow/message"); }
public void append(Node parent, Long id, String type, String scope, String time) { append(parent, id); DomUtil.appendTextNode(getDocument(), parent, "type", type); DomUtil.appendTextNode(getDocument(), parent, "scope", scope); DomUtil.appendTextNode(getDocument(), parent, "time", time); }