BEA Systems, Inc.

com.beasys.commerce.axiom.document.loader
Class MetaParser

java.lang.Object
  |
  +--com.beasys.commerce.axiom.document.loader.MetaParser

public class MetaParser
extends java.lang.Object
implements LoaderFilter

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".

This requires the OROMatcher1.1 class library (which provides regular expression support). This library is bundled with WebLogic Server.


Field Summary
static java.lang.String attrPatStr
          The Perl5 regular exprssion to find a name="value" pair.
static java.lang.String metaTagPatStr
          The Perl5 regular expression string for finding META tags.
static java.lang.String patStr
          The Perl5 regular expression string to search for.
static java.lang.String titlePatStr
          The Perl5 regular expression string for finding TITLE tags.
 
Constructor Summary
MetaParser()
           
 
Method Summary
static java.util.Properties load(java.io.BufferedReader reader, java.util.Properties p)
          Load the META tag name/value pairs from the input stream into p.
static java.util.Properties load(java.io.File f, java.util.Properties p)
          Load the META tag name/value pairs from f into p.
static java.util.Properties load(java.io.File f, java.util.Properties p, java.lang.String enc)
          Load the META tag name/value pairs from f into p.
 void loadProperties(java.io.File f, java.util.Properties p, BulkLoader loader)
          Load the file-specific properties for the specified file into the properties, running under the given BulkLoader.
static void main(java.lang.String[] args)
          Little test program which grags the META tags from the first argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attrPatStr

public static final java.lang.String attrPatStr
The Perl5 regular exprssion to find a name="value" pair.

metaTagPatStr

public static final java.lang.String metaTagPatStr
The Perl5 regular expression string for finding META tags.

titlePatStr

public static final java.lang.String titlePatStr
The Perl5 regular expression string for finding TITLE tags.

patStr

public static final java.lang.String patStr
The Perl5 regular expression string to search for.
Constructor Detail

MetaParser

public MetaParser()
Method Detail

loadProperties

public void loadProperties(java.io.File f,
                           java.util.Properties p,
                           BulkLoader loader)
Description copied from interface: LoaderFilter
Load the file-specific properties for the specified file into the properties, running under the given BulkLoader.

If the filter doesn't support the given file type or if there is an error, it should do nothing. This can use the error(), warning(), and debug() methods on the specified loader. Filters can also use GlobHelper and MimeTypeHelper to determine if they should do something with the file.

Specified by:
loadProperties in interface LoaderFilter

load

public static java.util.Properties load(java.io.File f,
                                        java.util.Properties p)
                                 throws java.io.IOException
Load the META tag name/value pairs from f into p.
Parameters:
f - the file.
p - the properties object (null to create new).
Returns:
the META tag name/values (p if p was not null).
Throws:
java.io.IOException - thrown on an error reading the file.

load

public static java.util.Properties load(java.io.File f,
                                        java.util.Properties p,
                                        java.lang.String enc)
                                 throws java.io.IOException
Load the META tag name/value pairs from f into p.

The file is assumed to be encoded in the specified encoding.

Parameters:
f - the file.
p - the properties object (null to create new).
enc - the file encoding name (null for default).
Returns:
the META tag name/values (p if p was not null).
Throws:
java.io.IOException - thrown on an error reading the file.

load

public static java.util.Properties load(java.io.BufferedReader reader,
                                        java.util.Properties p)
                                 throws java.io.IOException
Load the META tag name/value pairs from the input stream into p.

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.

Parameters:
reader - the input reader.
p - the properties object (null to create new).
Returns:
the META tag name/values (p if p was not null).
Throws:
java.io.IOException - thrown on an error reading the file.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Little test program which grags the META tags from the first argument.

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved