public XML createXML(String name) { try { return new XML(name); } catch (Exception e) { e.printStackTrace(); return null; } }
public void setPermissions(String[] names) { // Check permissions from the template // e.g. watch face already has WAKE_LOCK // And don't add them if they're already there XML[] existingPermissionsXml = xml.getChildren("uses-permission"); List<String> existingPermissions = new ArrayList<>(existingPermissionsXml.length); for (XML perm : existingPermissionsXml) { existingPermissions.add(perm.getString("android:name")); } for (String name : names) { if (!existingPermissions.contains(name)) { XML newbie = xml.addChild("uses-permission"); newbie.setString("android:name", name); } } }
public void updateProcessing3() { xml.getChild("application").getChild("activity").setString("android:name", ".MainActivity"); if (xml.getChild("uses-sdk").getInt("android:minSdkVersion") < 17) { xml.getChild("uses-sdk").setInt("android:minSdkVersion", 17); } if (xml.getChild("uses-sdk").getInt("android:targetSdkVersion") < 17) { xml.getChild("uses-sdk").setInt("android:targetSdkVersion", 17); } }
XML[] rows = sheet.getChildren("table:table-row"); int rowRepeat = row.getInt("table:number-rows-repeated", 1); XML[] cells = row.getChildren(); int columnIndex = 0; int cellRepeat = cell.getInt("table:number-columns-repeated", 1); String cellData = ignoreTags ? cell.getString("office:value") : null; int cellKids = cell.getChildCount(); if (cellKids != 0) { XML[] paragraphElements = cell.getChildren("text:p"); if (paragraphElements.length != 1) { for (XML el : paragraphElements) { System.err.println(el.toString()); String textpContent = textp.getContent(); XML[] textpKids = textp.getChildren(); StringBuffer cellBuffer = new StringBuffer(); for (XML kid : textpKids) { String kidName = kid.getName(); if (kidName == null) { odsAppendNotNull(kid, cellBuffer); int spaceCount = kid.getInt("text:c", 1); for (int space = 0; space < spaceCount; space++) {
protected void setManifestPermissions() throws BuildFailedException { try { XML xml = new XML(getManifestFile()); XML[] existingPermissionsXml = xml.getChildren("uses-permission"); List<String> existingPermissions = new ArrayList<>(existingPermissionsXml.length); for (XML perm : existingPermissionsXml) { existingPermissions.add(perm.getString("android:name")); XML newbie = xml.addChild("uses-permission"); newbie.setString("android:name", name); existingPermissions.add(name); XML newbie = xml.addChild("uses-permission"); newbie.setString("android:name", name); existingPermissions.add(name); xml.save(getManifestFile(), ""); } catch (IOException | ParserConfigurationException | SAXException e) { e.printStackTrace();
XML[] bindings = xml.getChildren(); for(XML binding : bindings) { if(!binding.getName().equals("binding")) continue; String name = binding.getContent(); int key = binding.getInt("key"); String modifiers = binding.getString("mod"); String[] mods = modifiers.split("\\|"); // "|" is a REGEX keyword... need to escape it
XML[] styleList = xml.getChild("styles").getChildren(); for(XML style : styleList) { if(!style.getName().equals("style")) continue; String name = style.getContent(); String hex = style.getString("color", "#FF000000").substring(1); boolean bold = style.getString("bold", "false").equals("true") ? true : false; XML[] keywords = xml.getChild("keywords").getChildren(); ArrayList<Keyword> tempSyntax = new ArrayList<>(); if(!keyword.getName().equals("keyword")) continue; String style = keyword.getString("style", ""); String name = keyword.getContent(); boolean function = keyword.getString("function", "false").equals("true"); String reference = keyword.getString("reference", "processing"); boolean noUnderscore = keyword.getString("reference_hint", "").equals("no_underscore"); String parentClass = keyword.getString("class", ""); boolean staticInParentClass = Boolean.valueOf(keyword.getString("static", "false")); String referenceTarget = keyword.getString("reference_target", parentClass.length() > 0 ? parentClass : (name + (function && !noUnderscore ? "_" : "")));
XML kid = getChild(Integer.parseInt(items[offset])); if (offset == items.length-1) { return kid; } else { return kid.getChildRecursive(items, offset+1); int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { XML kid = getChild(i); String kidName = kid.getName(); if (kidName != null && kidName.equals(items[offset])) { if (offset == items.length-1) { return kid; } else { return kid.getChildRecursive(items, offset+1);
protected void odsParse(InputStream input, String worksheet) { try { InputStream contentStream = odsFindContentXML(input); XML xml = new XML(contentStream); xml.getChildren("office:body/office:spreadsheet/table:table"); if (worksheet == null || worksheet.equals(sheet.getString("table:name"))) { odsParseSheet(sheet); found = true;
/** * @webref xml:method * @brief Gets the content of an attribute as a String */ public String getString(String name) { return getString(name, null); }
public Gradient(PShapeSVG parent, XML properties) { super(parent, properties, true); XML elements[] = properties.getChildren(); offset = new float[elements.length]; color = new int[elements.length]; String name = elem.getName(); if (name.equals("stop")) { String offsetAttr = elem.getString("offset"); float div = 1.0f; if (offsetAttr.endsWith("%")) { String style = elem.getString("style"); HashMap<String, String> styles = parseStyleAttributes(style);
public FontGlyph(PShapeSVG parent, XML properties, Font font) { super(parent, properties, true); super.parsePath(); // ?? name = properties.getString("glyph-name"); String u = properties.getString("unicode"); unicode = 0; if (u != null) { if (u.length() == 1) { unicode = u.charAt(0); //System.out.println("unicode for " + name + " is " + u); } else { System.err.println("unicode for " + name + " is more than one char: " + u); } } if (properties.hasAttribute("horiz-adv-x")) { horizAdvX = properties.getInt("horiz-adv-x"); } else { horizAdvX = font.horizAdvX; } }
return getChildrenRecursive(PApplet.split(name, '/'), 0); return new XML[] { getChild(Integer.parseInt(name)) }; int childCount = getChildCount(); XML[] matches = new XML[childCount]; int matchCount = 0; for (int i = 0; i < childCount; i++) { XML kid = getChild(i); String kidName = kid.getName(); if (kidName != null && kidName.equals(name)) { matches[matchCount++] = kid;
XML[] elements = properties.getChildren(); horizAdvX = properties.getInt("horiz-adv-x", 0); String name = elements[i].getName(); XML elem = elements[i]; if (name == null) {
/** * @param prettyVersion */ public void setPrettyVersion(String prettyVersion) { xml.setString("android:versionName", prettyVersion); }
public String[] getPermissions() { XML[] elements = xml.getChildren("uses-permission"); int count = elements.length; String[] names = new String[count]; for (int i = 0; i < count; i ++) { names[i] = elements[i].getString("android:name"); } return names; }
private XML createCameraNode() { XML cameraNode = new XML(CAMERA_XML_NAME); cameraNode.setString(CAMERA_NAME_XML_NAME, cameraName); cameraNode.setString(CAMERA_FORMAT_XML_NAME, cameraFormat); String type = this.cameraType.name(); cameraNode.setString(CAMERA_TYPE_XML_NAME, type); return cameraNode; }