|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.infoteria.asteria.util.xml.DOMUtil
DOMを扱うためのユーティリティクラスです。
Field Summary | |
static String |
XML_NSURI
|
static String |
XMLNS_NSURI
|
Constructor Summary | |
DOMUtil()
|
Method Summary | |
static Document |
cloneDocument(Document doc)
DocumentをDeepCopyします。 |
abstract Document |
createDocument()
新しいDocumentを作成します |
abstract Document |
createDocument(String namespaceURI,
String qname,
DocumentType doctype)
指定の名前空間とQNameを文書要素として持つDocumentを作成します。 |
abstract DocumentType |
createDocumentType(String qname,
String publicId,
String systemId)
DTDを作成します |
static String |
getAsString(Node node)
getAsString(node, false)と同じです。 |
static String |
getAsString(Node node,
boolean indent)
Nodeを文字列化します。 indentがtrueの場合子ノードがElementのみのElementはインデントされます。 |
static Element |
getChild(Node node,
String name)
getChild(node, name, 0)と同じ |
static Element |
getChild(Node node,
String name,
int index)
nodeの子要素で、NodeNameが nameに等しいもののindex番目を返す。 |
static int |
getChildCount(Node node,
String name)
nodeの子要素で、NodeNameが nameに等しいものの数を返す。 |
static int |
getChildCountNS(Node node,
String namespaceURI,
String localName)
nodeの子要素で、namespaceURIとlocalNameが引数に等しいものの数を返す。 |
static Element |
getChildNS(Node node,
String namespaceURI,
String localName)
getChildNS(node, namespaceURI, localName, 0)と同じ |
static Element |
getChildNS(Node node,
String namespaceURI,
String localName,
int index)
nodeの子要素で、namespaceURIとlocalNameが引数に等しいもののindex番目を返す。 |
static String |
getChildText(Element el)
要素の最初の子テキストの内容を取得する。 |
static String |
getChildTextDeep(Element el)
要素の子孫ノードすべてのテキストを連結して取得する |
abstract String |
getDeclaredEncoding()
parseメソッド実行後に直前にパースしたXMLのXML宣言のエンコーディングを返します |
EntityResolver |
getEntityResolver()
parse時のEntityResolverを返します |
ErrorHandler |
getErrorHandler()
parse時のエラーハンドラを返します |
boolean |
isExpandEntityReferences()
parse時にEntityReferenceを展開するかどうかを返します |
boolean |
isIgnoreComments()
parseメソッドでコメントを無視するかどうかを返します |
boolean |
isIgnoreWhitespace()
parseメソッドで空白文字のみのTextノードを無視するかどうかを返します |
static boolean |
isNamespaceDeclared(Node node,
String prefix,
String nsuri)
指定のNodeの上位で指定のプレフィクスとネームスペースURIで名前空間が宣言されているかどうかを検査します。 |
static boolean |
isQName(Node node,
String namespaceURI,
String localName)
ノードのQNameがnamespaceURIとlocalNameに等しいかチェックします。 |
boolean |
isValidating()
parse時にDTDによるValidationを行うかどうかを返します |
static boolean |
isWhitespace(char c)
文字が空白文字かどうかを判定します。 空白文字は「0x20」「0x09」「0x0a」「0x0d」です。 |
static boolean |
isWhitespace(String s)
文字列がすべて空白文字かどうかを判定します。 |
static DOMUtil |
newInstance()
DOMUtilの新しいインスタンスを取得します。 |
static String |
normalizeString(String s)
文字列から前後の空白文字を取り除き、連続する空白文字は単一の「 」(0x20)に置き換えます。 |
static void |
normalizeWhitespace(Document doc)
Documentから空白文字のみのTextノードを削除します。 |
static void |
normalizeWhitespace(Element el)
要素から空白文字のみのTextノードを削除します。 |
abstract Document |
parse(File file)
ファイルをパースしてDocumentを作成します |
abstract Document |
parse(InputSource is)
InputSourceをパースしてDocumentを作成します |
abstract Document |
parse(InputStream is)
InputStreamをパースしてDocumentを作成します |
abstract Document |
parse(Reader reader)
ReaderをパースしてDocumentを作成します |
abstract Document |
parse(String url)
指定のURL(またはファイル名)に対応するリソースをパースしてDocumentを作成します |
static void |
removeXmlBaseAttribute(Node node)
remove xml:base attributes |
static void |
saveToFile(Node node,
File f,
boolean bIndent)
指定のノードをファイルに保存します。 indentがtrueの場合子ノードがElementのみのElementはインデントされます。 |
static void |
setChildText(Element el,
String value)
要素の最初の子テキストに valueを設定する。 既にテキストノードが存在する場合はそれが更新され、ない場合は追加される。 |
void |
setEntityResolver(EntityResolver resolver)
parse時のEntityResolverを指定します |
void |
setErrorHandler(ErrorHandler handler)
parse時のエラーハンドラを指定します |
void |
setExpandEntityReferences(boolean value)
parse時にEntityReferenceを展開するかどうかを指定します |
void |
setIgnoreComments(boolean value)
parseメソッドでコメントを無視するかどうかを指定します 無視した場合parse結果にはCommentノードは含まれません |
void |
setIgnoreWhitespace(boolean value)
parseメソッドで空白文字のみのTextノードを無視するかどうかを指定します 無視した場合parse結果には空白文字のみのTextノードは含まれません |
void |
setValidating(boolean value)
parse時にDTDによるValidationを行うかどうかを指定します |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String XML_NSURI
public static final String XMLNS_NSURI
Constructor Detail |
public DOMUtil()
Method Detail |
public static DOMUtil newInstance()
public abstract Document createDocument()
public abstract Document createDocument(String namespaceURI, String qname, DocumentType doctype)
namespaceURI
- 名前空間URI。名前空間なしの場合はnullqname
- 文書要素名public abstract Document parse(File file) throws IOException, ProcessorException
public abstract Document parse(String url) throws IOException, ProcessorException
public abstract Document parse(InputStream is) throws IOException, ProcessorException
public abstract Document parse(Reader reader) throws IOException, ProcessorException
public abstract Document parse(InputSource is) throws IOException, ProcessorException
public abstract String getDeclaredEncoding()
public abstract DocumentType createDocumentType(String qname, String publicId, String systemId)
public void setIgnoreComments(boolean value)
public boolean isIgnoreComments()
public void setIgnoreWhitespace(boolean value)
public boolean isIgnoreWhitespace()
public void setValidating(boolean value)
public boolean isValidating()
public void setExpandEntityReferences(boolean value)
public boolean isExpandEntityReferences()
public void setErrorHandler(ErrorHandler handler)
public ErrorHandler getErrorHandler()
public void setEntityResolver(EntityResolver resolver)
public EntityResolver getEntityResolver()
public static int getChildCount(Node node, String name)
node
- 子要素を数える対象のノードname
- カウントする要素のNodeNamepublic static Element getChild(Node node, String name)
public static Element getChild(Node node, String name, int index)
node
- 子要素を取得する対象のノードname
- 取得する要素のNodeNamepublic static int getChildCountNS(Node node, String namespaceURI, String localName)
node
- 子要素を数える対象のノードnamespaceURI
- カウントする要素のNamespaceURIlocalName
- カウントする要素のLocalNamepublic static Element getChildNS(Node node, String namespaceURI, String localName)
public static Element getChildNS(Node node, String namespaceURI, String localName, int index)
node
- 子要素を取得する対象のノードnamespaceURI
- 取得する要素のNamespaceURIlocalName
- 取得する要素のLocalNamepublic static String getChildText(Element el)
element
- テキストを取得する対象の要素public static String getChildTextDeep(Element el)
element
- テキストを取得する対象の要素public static void setChildText(Element el, String value)
element
- テキストを設定する対象の要素value
- 設定するテキストpublic static boolean isQName(Node node, String namespaceURI, String localName)
node
- チェックするノードnamespaceURI
- ネームスペースlocalName
- ローカルネームpublic static boolean isWhitespace(char c)
public static boolean isWhitespace(String s)
public static void normalizeWhitespace(Document doc)
public static void normalizeWhitespace(Element el)
public static String normalizeString(String s)
public static String getAsString(Node node)
public static String getAsString(Node node, boolean indent)
public static boolean isNamespaceDeclared(Node node, String prefix, String nsuri)
public static Document cloneDocument(Document doc)
public static void saveToFile(Node node, File f, boolean bIndent) throws IOException
public static void removeXmlBaseAttribute(Node node)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |