⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 builderimpl.java

📁 xbrlapi的源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				newElement.setAttribute(attrs.getQName(i), attrs.getValue(i));				namespaces.put(Constants.XMLNamespace,"");			} else if (! attrs.getURI(i).equals("")) {				newElement.setAttributeNS(attrs.getURI(i), attrs.getQName(i),attrs.getValue(i));				namespaces.put(attrs.getURI(i),"");			}		}				for (int i = 0; i < attrs.getLength(); i++) {						if (! attrs.getURI(i).equals(""))				;			else if (namespaces.containsKey(attrs.getValue(i)))				;			else if (!(attrs.getQName(i).equals("xmlns") || attrs.getQName(i).startsWith("xmlns:")))				newElement.setAttribute(attrs.getQName(i),attrs.getValue(i));			else				newElement.setAttribute(attrs.getQName(i),attrs.getValue(i));		}		return newElement;	}				/**	 * Insert a new element without attributes.	 * @param namespaceURI The namespace of the element found by the SAX parser.	 * @param lName The local name of the element found by the SAX parser.	 * @param qName The QName of the element found by the SAX parser.	 * @throws XBRLException if the node cannot be appended.	 */	public void appendElement(			String namespaceURI, 			String lName, 			String qName) throws XBRLException		{		appendElement(namespaceURI,lName,qName,null);	}			/**	 * Update the insertion point for new content when reaching 	 * the end of an element.	 * TODO try to make endElement this a private method.	 * @param namespaceURI The namespace URI of the element that is ending.	 * @param lName The local name of the element that is ending.	 * @param qName The QName of the element that is ending.	 * @throws XBRLException if the current insertion point is not an 	 * element node or if the new (parent) insertion point is not an element node.	 */	public void endElement(			String namespaceURI,			String lName,			String qName			) throws XBRLException {				// Make sure that the insertion point is stepping up from an element node (to an element or document node)		if (getInsertionPoint().getNodeType() != Node.ELEMENT_NODE)			throw new XBRLException("The fragment insertion point is pointing to the wrong kind of node: " + getInsertionPoint().getNodeType() + ".");				Node parentNode = getInsertionPoint().getParentNode();		if (parentNode != null) {			if (parentNode.getNodeType() != Element.ELEMENT_NODE) {				throw new XBRLException("The fragment builder insertion point is trying to move to a non-element node.");			}			setInsertionPoint((Element) parentNode);		}			}		/**	 * Append a notation declaration.	 */	public void appendNotationDecl(			String name, 			String publicId, 			String systemId			) throws XBRLException {	    StringBuffer b = new StringBuffer("<!NOTATION ");	    b.append(name);	    if (publicId != null)	      b.append(" PUBLIC \"").append(publicId).append('"');	    if (systemId != null)	      b.append(" SYSTEM \"").append(systemId).append('"');	    b.append('>');		// TODO How do I add a notation node to the DOM when fragment building	}		/**	 * Append an unparsed entity declaration.	 */	public void appendUnparsedEntityDecl(			String name, 			String publicId,			String systemId, 			String notationName) 	throws XBRLException {	    StringBuffer b = new StringBuffer("<!ENTITY ");	    b.append(name);	    if (publicId != null)	      b.append(" PUBLIC \"").append(publicId).append('"');	    if (systemId != null)	      b.append(" SYSTEM \"").append(systemId).append('"');	    b.append(" NDATA \"").append(notationName).append('"');	    b.append('>');	    		// TODO How to add an unparsed Entity Declaration to a DOM.	    throw new XBRLException("Not yet implemented.");	}	/**	 * Append an element DTD declaration.	 */	public void appendElementDecl(			String name, 			String model			) throws XBRLException {		// TODO How to add an element DTD declaration to a DOM	    throw new XBRLException("Not yet implemented.");	}			/**	 * Append an internal entity DTD declaration.	 */	public void appendInternalEntityDecl(			String name, 			String value			) throws XBRLException {		// TODO How to add an internal entity declaration	    throw new XBRLException("Not yet implemented.");	}	/**	 * Append an external entity DTD declarations.	 */	public void appendExternalEntityDecl(			String name, 			String publicId, 			String systemId			) throws XBRLException {		// TODO Determine how to add an external entity declaration	    throw new XBRLException("Not yet implemented.");	}	/**	 * Append an attribute DTD declaration	 */	public void appendAttributeDecl(			String eName, 			String aName, 			String type,			String valueDefault, 			String value			) throws XBRLException {		// TODO How to add an attribute DTD declaration	    throw new XBRLException("Not yet implemented.");	}    //===========================================================    // Metadata construction methods    //===========================================================			/**	 * Set a metadata attribute.	 * @param name The name of the attribute.	 * @param value The value of the attribute.	 **/	public void setMetaAttribute(String name, String value) {		getMetadata().setAttribute(name,value);			}		/**	 * Get a metadata attribute.	 * @param name The name of the attribute.	 * @return the string value of the metadata attribute or 	 * null if it is not specified.	 **/	public String getMetaAttribute(String name) {		String value = getMetadata().getAttribute(name); 		if (value == "") {			return null;		}		return value;	}	/**	 * Remove a metadata attribute.	 * @param name The name of the attribute.	 **/	public void removeMetaAttribute(String name) {		getMetadata().removeAttribute(name);			}	    /**     * Appends a child element to the root metadata element.     * @param eName Name of the element to be added (no namespaces are used).     * @param attributes A hashmap from attribute name keys to attribute values.     * @throws XBRLException if the metadata element cannot be appended.     */    public void appendMetadataElement(String eName, HashMap<String,String> attributes) throws XBRLException {		Element child = getDOM().createElementNS(Constants.XBRLAPINamespace,Constants.XBRLAPIPrefix + ":" + eName);		Iterator<String> attributeNames = attributes.keySet().iterator();		while (attributeNames.hasNext()) {			String aName = attributeNames.next();			String aValue = attributes.get(aName);			if (aName != null) {				if (aValue == null) throw new XBRLException("A metadata element is being added but attribute, " + aName + ", has a null value.");				child.setAttribute(aName,aValue); 			} else throw new XBRLException("A metadata element is being added with an attribute with a null name.");		}		getMetadata().appendChild(child); 	    }        /**     * Removes a child element from the metadata root element by      * specifying the name of the child and the value of the element's      * text content and/or the value of a named attribute.  All specified      * information must match for the deletion to succeed.     * @param eName Name of the element to be added (no namespaces are used).     * @param attributes A hashmap from attribute name keys to attribute values.     * @throws XBRLException if the metadata element cannot be removed.     */    public void removeMetadataElement(String eName, HashMap<String,String> attributes) throws XBRLException {		NodeList children = getMetadata().getElementsByTagNameNS(Constants.XBRLAPINamespace,eName);		for (int i=0; i<children.getLength(); i++) {			boolean match = true;			Element child = (Element) children.item(i);			Iterator<String> attributeNames = attributes.keySet().iterator();			while (attributeNames.hasNext()) {				String aName = attributeNames.next();				String aValue = attributes.get(aName);				if (aName != null) {					if (aValue == null) throw new XBRLException("A metadata element is being checked but attribute, " + aName + ", has a null value.");					if (! child.getAttribute(aName).equals(aValue)) {						match = false;					}				} else throw new XBRLException("A metadata element is being checked against an attribute with a null name.");			}						if (match) {				getMetadata().removeChild(child);				break;			}		}    	    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -