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

A utility which can pull META tags from an HTML file.

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.
 
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.
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
equals, 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.
Constructor Detail

MetaParser

public MetaParser()
Method Detail

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