private void inheritDo(Style style, HashSet<String> set) { String parentName = style.getParentName(); String currentName = style.getSelector(); if (parentName == null) { // System.out.println("style [" + currentName + "] no parent."); return; // No parent. } else if (set.contains(currentName)) { // System.out.println("style [" + currentName + "] has been set."); return; // Has been set } else { checkInheritanceHierarchy(style); Style parent = getStyle(parentName); // System.out.println("inheriting style [" + currentName + "] from style [" + parentName + // "]."); if (parent == null) { throw new BuildException( "Invalid CSS code: the style [" + currentName + "] extends the non-existing style [" + parentName + "]."); } inheritDo(parent, set); style.setParent(parent); set.add(currentName); } }
/** * Sets the parents of the styles. This method is automatically called when the sourcecode will be * retrieved. * * @throws BuildException when invalid inheritances are found. * @see #isInherited() * @see #getSourceCode() */ public void oldInherit() { // create default-style when not explicitly defined: if (this.stylesByName.get("default") == null) { addCssBlock(DEFAULT_STYLE); } Style[] allStyles = getAllStyles(); for (int i = 0; i < allStyles.length; i++) { Style style = allStyles[i]; // System.out.println("inheriting style [" + style.getSelector() + "]."); checkInheritanceHierarchy(style); String parentName = style.getParentName(); if (parentName != null) { Style parent = getStyle(parentName); if (parent == null) { throw new BuildException( "Invalid CSS code: the style [" + style.getSelector() + "] extends the non-existing style [" + parentName + "]."); } style.setParent(parent); } } this.isInitialised = true; }