WOX2
@ 15
WOX2 / trunk / Java / tests / ClaimPortal / CompositeIdentifier.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
package ClaimPortal; /** * Version: 1.0 * Author: Carlos R. Jaimez Gonzalez * Author: Simon M. Lucas * Site: http://woxserializer.sourceforge.net/ * * Version: 1.5 * Author: Steven M Lewis * * Version: 2.0 * Author: George Smith * SVN: http://svn.xp-dev.com/svn/WOX2/ * Note: XML form for vs 2 is more compact and therefor incompatible with vs 1 */ public abstract class CompositeIdentifier<TY extends Enum> { private static final String SEP = "|"; // | has a meaning in Regex private TY m_Type; private String m_Value; protected CompositeIdentifier( String pToString, TY pTypeUnspecified ) { int index = pToString.indexOf( SEP ); String zTypeName = pToString.substring( 0, index ); m_Value = pToString.substring( index + 1 ).trim(); //noinspection unchecked m_Type = (TY) Enum.valueOf( pTypeUnspecified.getClass(), zTypeName ); } protected CompositeIdentifier( TY pTypeUnspecified, TY pType, String pValue ) { if ( null == (m_Type = pType) ) { throw new NullPointerException( "No Type!" ); } // setValue( pTypeUnspecified, pValue ); // } // // private void setValue( TY pTypeUnspecified, String pValue ) // { if ( pTypeUnspecified == null ) { throw new NullPointerException( "No Unspecified Type!" ); } if ( pTypeUnspecified == m_Type ) { if ( pValue != null ) { pValue = pValue.trim(); if ( pValue.length() != 0 ) { throw new IllegalArgumentException( "Unspecified indicated, but value was: " + pValue ); } pValue = null; } } else { if ( pValue == null ) { throw new IllegalArgumentException( "Unspecified NOT indicated, but value null" ); } pValue = pValue.trim(); if ( pValue.length() == 0 ) { throw new IllegalArgumentException( "Unspecified NOT indicated, but value empty" ); } } m_Value = pValue; } public TY getType() { return m_Type; } public String getValue() { return m_Value; } @Override public String toString() { return getType().toString() + SEP + getValue(); } } |