private List<Directive> parseDirectives(final StringBuilder buffer, final ParserCursor cursor) { List<Directive> elements = new ArrayList<Directive>(); while (!cursor.atEnd()) { Directive element = parseDirective(buffer, cursor); if (!(element.getName().length() == 0 && element.getValue() == null)) { elements.add(element); } } return elements; }
private void handleSpecialDirectives(Directive dir) throws ParserException { if (dir.getName().equalsIgnoreCase("Include")) { List<Statement> stats = include(getParent(), dir.getValue().trim()); _statements.addAll(stats); } else if (dir.getName().equalsIgnoreCase("ServerRoot")) { String serverRoot = dir.getValue().trim(); if (serverRoot != null && serverRoot.startsWith("\"") && serverRoot.endsWith("\"")) { serverRoot = serverRoot.substring(1, serverRoot.length() - 1); } setServerRoot(serverRoot); } }
/** * Adds a URL entry to the archive with the specified permissions. * * @param path the destination path for the installed file. * @param source the URL with the data to be added * @param permissions the permissions flags. * @param directive directive indicating special handling for this file. * @param uname user owner for the given file * @param gname group owner for the given file */ public synchronized void addURL( final String path, final URL source, final int permissions, final Directive directive, final String uname, final String gname, final int dirmode) throws FileNotFoundException { if (files.contains(path)) return; addParents(new File(path), dirmode, uname, gname); files.add(path); logger.log(FINE, "Adding file ''{0}''.", path); CpioHeader header = new CpioHeader(path, source); header.setType(FILE); header.setInode(inode++); if (uname != null) header.setUname(uname); if (gname != null) header.setGname(gname); if (permissions != -1) header.setPermissions(permissions); headers.add(header); sources.put(header, source); if (directive != null) header.setFlags(directive.flag()); }
public Directive peekDirective(DirectiveType type) { Directive directive = peekOrNull(); if (directive == null) { return null; } if (directive.getType().equals(type)) { return directive; } Directive d = null; Object[] elementData = super.toArray(); for (int i = elementData.length - 1; i >= 0; i--) { d = (Directive) elementData[i]; if (d.getType().equals(type)) { return d; } } return null; }
@Override public DirectiveParameter getAngularDirectiveParameter(Object project, Attr attr) { Element element = attr.getOwnerElement(); // check if owner element is a directive? Directive elementDirective = getAngularDirective(project, element); if (elementDirective != null) { return elementDirective.getParameter(attr.getName()); } else { // retrieve directives from other attributes. List<Directive> directives = getAngularDirectives(project, attr.getOwnerElement(), attr); DirectiveParameter parameter = null; for (Directive directive : directives) { parameter = directive.getParameter(attr.getName()); if (parameter != null) { return parameter; } } } return null; }
@Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if ("module".equals(name)) { String moduleName = attributes.getValue("name"); module = new Module(moduleName); } else if ("directive".equals(name)) { String directiveName = attributes.getValue("name"); String url = attributes.getValue("url"); AngularType directiveType = AngularType.get(attributes.getValue("type")); // tags name List<String> tagsName = new ArrayList<String>(); String tags = attributes.getValue("tags"); if (!StringUtils.isEmpty(tags)) { String[] names = tags.split(","); String tagName = null; for (int i = 0; i < names.length; i++) { tagName = names[i].trim(); if (tagName.length() > 0) { tagsName.add(tagName); } } } // restrict String restrict = attributes.getValue("restrict"); // value : required|optional|none DirectiveValue directiveValue = DirectiveValue.get(attributes.getValue("value")); this.directive = new Directive( directiveName, directiveType, url, tagsName, restrict, directiveValue, module, false); } else if ("description".equals(name)) { this.description = new StringBuilder(); } else if ("parameter".equals(name)) { String parameterName = attributes.getValue("name"); boolean optional = StringUtils.asBoolean(attributes.getValue("optional"), false); this.directiveParameter = new DirectiveParameter(parameterName, optional, directive); directive.addParameter(directiveParameter); this.description = new StringBuilder(); } super.startElement(uri, localName, name, attributes); }
/** * Adds a directory entry to the archive with the specified permissions. * * @param path the destination path for the installed file. * @param permissions the permissions flags. * @param directive directive indicating special handling for this directory. * @param uname user owner for the given file * @param gname group owner for the given file * @param addParents whether to add parent directories to the rpm */ public synchronized void addDirectory( final String path, final int permissions, final Directive directive, final String uname, final String gname, boolean addParents) { if (files.contains(path)) return; if (addParents) addParents(new File(path), permissions, uname, gname); files.add(path); logger.log(FINE, "Adding directory ''{0}''.", path); CpioHeader header = new CpioHeader(path); header.setType(DIR); header.setInode(inode++); if (uname != null) header.setUname(uname); if (gname != null) header.setGname(gname); header.setMtime(System.currentTimeMillis()); if (permissions != -1) header.setPermissions(permissions); else header.setPermissions(DEFAULT_DIRECTORY_PERMISSION); headers.add(header); sources.put(header, ""); if (directive != null) header.setFlags(directive.flag()); }
@Override public void visitChildren(AstVisitor<?> visitor) { super.visitChildren(visitor); safelyVisitChild(uri, visitor); }
@Override public void append(Program program) throws AsmError { if (!hasLabel()) throw new AsmError(loc, "Missing label at CSECT"); super.append(program); }
@Override public void visitChildren(ASTVisitor<?> visitor) { super.visitChildren(visitor); safelyVisitChild(name, visitor); }