|
© 2004 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bea.p13n.util.MetaParser
A utility which can pull META tags from an HTML file.
This will also pull the title of an HTML from the <title></title> section anywhere in the document. No matter what the casing of the title tag, it will be put in the metadata properties as "title".
Method Summary | |
static String |
determineEncoding(BufferedReader reader)
Try to determine the encoding from a <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=" > instruction. |
static String |
determineEncoding(File f,
String encoding)
Try to determine the encoding from a <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=" > instruction. |
static Properties |
load(BufferedReader reader,
Properties p)
Load the META tag name/value pairs from the input stream into p. |
static Properties |
load(File f,
Properties p)
Load the META tag name/value pairs from f into p. |
static Properties |
load(File f,
Properties p,
String enc)
Load the META tag name/value pairs from f into p. |
static BufferedReader |
open(File f,
String encoding)
Open a file with the given encoding. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static final String determineEncoding(BufferedReader reader) throws IOException
IOException
- thrown on an error reading the file.public static final String determineEncoding(File f, String encoding) throws IOException
If an encoding is passed in and the files doesn't contain an appropriate META tag, that encoding will be returned.
f
- the input fileencoding
- the encoding to open the file with (null for default).
IOException
- thrown on an error reading the file.public static Properties load(BufferedReader reader, Properties p) throws IOException
This operates on a last-seen-is-returned alogirithm for META tags with the same name. It will also find all meta tags in file, not just those in the head.
reader
- the input reader.p
- the properties object (null to create new).
IOException
- thrown on an error reading the file.public static Properties load(File f, Properties p) throws IOException
f
- the file.p
- the properties object (null to create new).
IOException
- thrown on an error reading the file.public static Properties load(File f, Properties p, String enc) throws IOException
This will look for the encoding name to use by trying to find a <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=" > tag in the HTML (this will use the passed in encoding to find the encoding). If a valid encoding name is found, the file will be opened with that encoding, and the "encoding" property in the Properties will be set. If a valid encoding is not found and an encoding was passed in, that encoding will be used. If an encoding was not passed in, the system default will be used.
f
- the file.p
- the properties object (null to create new).enc
- the file encoding name to try (null for system default).
IOException
- thrown on an error reading the file.public static final BufferedReader open(File f, String encoding) throws IOException
f
- a file object.encoding
- the encoding to use, null for default.
IOException
- if invalid encoding or unable to open file.
|
© 2004 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |