Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSE
Release 3.0

org.eclipse.rse.services.clientserver
Class NamePatternMatcher


java.lang.Object
  extended by 
org.eclipse.rse.services.clientserver.NamePatternMatcher
All Implemented Interfaces:
IMatcher

public class NamePatternMatcher
extends Object
implements IMatcher

This class offers generic name pattern matching.

This supports one wildcard character ('*") anywhere in the name, or one at the beginning and end of the name.

  1. ABC
  2. *
  3. ABC*
  4. *ABC
  5. AB*C
  6. *ABC*

This pattern matching class also optionally supports additional advanced patterns beyond the stricter PDM style. These allow for two '*'s anywhere in the name.

  1. AB*C*
  2. *A*C
  3. A*B*C

Quoted names are supported.

All matching is case-sensitive!

Instantiate this class for a given generic name, and then call matches(String input) for each input name to see if it matches the pattern.

To enable the advanced patterns, pass true to the constructor.


Field Summary
static int ALL
          Example: *
static char QUOTE
          Example: Quoted name delimiter: "
static int SCALAR
          Example: ABC
static char WILDCARD
          Wildcard character: *
static int WILDCARD_END
          Example: ABC*
static int WILDCARD_MIDDLE
          Example: A*C
static int WILDCARD_MIDDLE_END
           
static int WILDCARD_MIDDLE_MIDDLE
          Example: A*C*F
static int WILDCARD_START
          Example: *ABC
static int WILDCARD_START_END
          Example: *ABC*
static int WILDCARD_START_MIDDLE
          Example: *A*F
 
Constructor Summary
NamePatternMatcher ( String genericName)
          Constructor for traditional-style only patterns, which allows for one asterisk anywhere in the name,or one asterisk each at the beginning or end of the name.
NamePatternMatcher ( String genericName, boolean advanced, boolean caseSensitive)
          Constructor for traditional-style patterns PLUS advanced patterns ABC*DEF* and A*C*F.
 
Method Summary
 int getPatternType ()
          What type of pattern is it?
 boolean isGeneric ()
          Was generic name given in the constructor a valid generic name (one or 2 '*'s)?
 boolean isQuoted ()
          Was quoted name given in the constructor a quoted name like "abcDEF"?
 boolean isValid ()
          Was generic name given in the constructor a valid scalar or generic name?
 boolean matches ( String input)
          Test if a host name matches the pattern of this generic name.
  String toString ()
          For writing this object out.
static boolean verifyPattern ( String genericName, boolean advanced)
          Static method to test if a given pattern is a valid generic name
 void writeInfo ( PrintWriter stream)
          For debugging/testing purposes.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WILDCARD

public static final char WILDCARD
Wildcard character: *

See Also:
Constant Field Values

QUOTE

public static final char QUOTE
Example: Quoted name delimiter: "

See Also:
Constant Field Values

SCALAR

public static final int SCALAR
Example: ABC

See Also:
Constant Field Values

ALL

public static final int ALL
Example: *

See Also:
Constant Field Values

WILDCARD_END

public static final int WILDCARD_END
Example: ABC*

See Also:
Constant Field Values

WILDCARD_START

public static final int WILDCARD_START
Example: *ABC

See Also:
Constant Field Values

WILDCARD_MIDDLE

public static final int WILDCARD_MIDDLE
Example: A*C

See Also:
Constant Field Values

WILDCARD_START_END

public static final int WILDCARD_START_END
Example: *ABC*

See Also:
Constant Field Values

WILDCARD_MIDDLE_END

public static final int WILDCARD_MIDDLE_END
See Also:
Constant Field Values

WILDCARD_START_MIDDLE

public static final int WILDCARD_START_MIDDLE
Example: *A*F

See Also:
Constant Field Values

WILDCARD_MIDDLE_MIDDLE

public static final int WILDCARD_MIDDLE_MIDDLE
Example: A*C*F

See Also:
Constant Field Values
Constructor Detail

NamePatternMatcher

public NamePatternMatcher(
String genericName)
Constructor for traditional-style only patterns, which allows for one asterisk anywhere in the name,or one asterisk each at the beginning or end of the name.

If you don't know for sure the input is generic or valid, after constructing call:

  • isValid() to determine if given generic name was valid.
  • isGeneric() to determine if given generic name had a wildcard.
  • If curious, you can also subsequently call:

  • getPatternType() to determine which type of pattern the generic name follows.
  • Once constructed for a valid name, you can call

  • matches(String) for each name to see if it matches this generic name pattern.

    Quoted names are supported.

    All matching is case-sensitive!

    Parameters:
    genericName - generic name to do pattern matching for (ie, ABC*DEF)

  • NamePatternMatcher

    public NamePatternMatcher(
    String genericName,
                              boolean advanced,
                              boolean caseSensitive)
    Constructor for traditional-style patterns PLUS advanced patterns ABC*DEF* and A*C*F.

    If you don't know for sure the input is generic or valid, after constructing call:

  • isValid() to determine if given generic name was valid.
  • isGeneric() to determine if given generic name had a wildcard.
  • If curious, you can also subsequently call:

  • getPatternType() to determine which type of pattern the generic name follows.
  • Once constructed for a valid name, you can call

  • matches(String) for each name to see if it matches this generic name pattern.

    Quoted names are supported.

    Parameters:
    genericName - generic name to do pattern matching for (ie, ABC*DEF)
    advanced - true if you want to support the advanced patterns.
    caseSensitive - true if the names are case-sensitive, false if case insensitive
  • Method Detail

    matches

    public boolean matches(
    String input)
    Test if a host name matches the pattern of this generic name.

    Specified by:
    matches in interface IMatcher
    Parameters:
    input - Scalar name like ABCDEF
    Returns:
    true if given name matches this generic name pattern.

    isValid

    public boolean isValid()
    Was generic name given in the constructor a valid scalar or generic name?

    Returns:
    true if name contained 0, 1 or 2 wildcards.

    isGeneric

    public boolean isGeneric()
    Was generic name given in the constructor a valid generic name (one or 2 '*'s)?


    isQuoted

    public boolean isQuoted()
    Was quoted name given in the constructor a quoted name like "abcDEF"?


    getPatternType

    public int getPatternType()
    What type of pattern is it? One of: SCALAR, ALL, WILDCARD_END, WILDCARD_START, WILDCARD_MIDDLE, WILDCARD_START_END, or WILDCARD_MIDDLE_END


    toString

    public 
    String toString()
    For writing this object out. Writes out the original generic name specified in the constructor.

    Overrides:
    toString in class Object

    writeInfo

    public void writeInfo(
    PrintWriter stream)
    For debugging/testing purposes. Writes out information about this generic name to the given stream file.


    verifyPattern

    public static boolean verifyPattern(
    String genericName,
                                        boolean advanced)
    Static method to test if a given pattern is a valid generic name

    Parameters:
    genericName - pattern to test
    advanced - true if advanced pattern allowed: ABC*DEF* and A*C*F

    RSE
    Release 3.0

    Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

     
     
      Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire