net.sf.fikin.classmarshaling.util
Class NamePrefixedClassSelector

java.lang.Object
  extended by net.sf.fikin.classmarshaling.util.NamePrefixedClassSelector
All Implemented Interfaces:
ClassSelector

public class NamePrefixedClassSelector
extends java.lang.Object
implements ClassSelector

Select classes based on list of prefixes.

If the class name is one of those prefixes it will be reported for serialization.
In all other cases it will report it not.

Example: in the following example will all classes which belong to "mypkg" class hierarchy and the class "mycls" will be selected, all other classes not:

      Selector selector = new NamePrefixedClassSelector();
      selector.setPrefixes( { "mypkg", "mycls" } );
      MarshaledObject mo = new MarshaledObject( myObj, selector );
      // not serialize the "mo" instead of "myObj"
 
created on Aug 2, 2005

Since:
Version:
$Revision: 1.1 $
Author:
fiykov

Constructor Summary
NamePrefixedClassSelector()
          instantiate the object with empty list of prefixes
NamePrefixedClassSelector(java.util.Collection prefixes)
          instantiate the object with given list of prefixes
NamePrefixedClassSelector(java.lang.String[] prefixes)
          instantiate the object with given list of prefixes
 
Method Summary
 boolean isClassToBeMarshaled(java.lang.Class cl)
          check if the class name is part of the list of class prefixes.
 void setPrefixes(java.util.Collection prefixes)
          set the list of prefixes
 void setPrefixes(java.lang.String[] prefixes)
          set the list of prefixes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamePrefixedClassSelector

public NamePrefixedClassSelector()
instantiate the object with empty list of prefixes


NamePrefixedClassSelector

public NamePrefixedClassSelector(java.lang.String[] prefixes)
instantiate the object with given list of prefixes

Parameters:
prefixes - to use

NamePrefixedClassSelector

public NamePrefixedClassSelector(java.util.Collection prefixes)
instantiate the object with given list of prefixes

Parameters:
prefixes - to use
Method Detail

setPrefixes

public void setPrefixes(java.util.Collection prefixes)
set the list of prefixes

Parameters:
prefixes - to use

setPrefixes

public void setPrefixes(java.lang.String[] prefixes)
set the list of prefixes

Parameters:
prefixes - to use

isClassToBeMarshaled

public boolean isClassToBeMarshaled(java.lang.Class cl)
check if the class name is part of the list of class prefixes.
if yes, it will return true.
all other cases it will return false.

Specified by:
isClassToBeMarshaled in interface ClassSelector
Parameters:
cl - is the class to check
Returns:
true in case its name is part of some of the assigned prefixes. otherwise false.


Copyright © 2007 Nikolay Fiykov. All Rights Reserved.