@Test public void testMustAttributresDiffer() { int less = comparator.compare( cn, sn ); assertTrue( less < 0 ); int greater = comparator.compare( sn, cn ); assertTrue( greater > 0 ); assertEquals( 0, less + greater ); }
public int compare( Object o1, Object o2 ) { IAttribute attribute1 = null; IValue value1 = null; if ( o1 instanceof IAttribute ) { attribute1 = ( IAttribute ) o1; } else if ( o1 instanceof IValue ) { value1 = ( IValue ) o1; attribute1 = value1.getAttribute(); } IAttribute attribute2 = null; IValue value2 = null; if ( o2 instanceof IAttribute ) { attribute2 = ( IAttribute ) o2; } else if ( o2 instanceof IValue ) { value2 = ( IValue ) o2; attribute2 = value2.getAttribute(); } if ( value1 != null && value2 != null ) { if ( getSortByOrDefault() == BrowserCoreConstants.SORT_BY_ATTRIBUTE_DESCRIPTION ) { if ( value1.getAttribute() != value2.getAttribute() ) { return this.compareAttributes( value1.getAttribute(), value2.getAttribute() ); } else { return this.compareValues( value1, value2 ); } } else if ( getSortByOrDefault() == BrowserCoreConstants.SORT_BY_VALUE ) { return this.compareValues( value1, value2 ); } else { return this.equal(); } } else if ( attribute1 != null && attribute2 != null ) { return this.compareAttributes( attribute1, attribute2 ); } else { throw new ClassCastException( "Can only compare two values or two attributes" ); } }
AttributeComparator implements Comparator<Object> { public int compare( Object o1, Object o2 ) { IAttribute attribute1 = null; IValue value1 = null; if ( o1 instanceof IAttribute ) { attribute1 = ( IAttribute ) o1; } else if ( o1 instanceof IValue ) { value1 = ( IValue ) o1; attribute1 = value1.getAttribute(); } IAttribute attribute2 = null; IValue value2 = null; if ( o2 instanceof IAttribute ) { attribute2 = ( IAttribute ) o2; } else if ( o2 instanceof IValue ) { value2 = ( IValue ) o2; attribute2 = value2.getAttribute(); } if ( value1 != null && value2 != null ) { if ( getSortByOrDefault() == BrowserCoreConstants.SORT_BY_ATTRIBUTE_DESCRIPTION ) { if ( value1.getAttribute() != value2.getAttribute() ) { return this.compareAttributes( value1.getAttribute(), value2.getAttribute() ); } else { return this.compareValues( value1, value2 ); } } else if ( getSortByOrDefault() == BrowserCoreConstants.SORT_BY_VALUE ) { return this.compareValues( value1, value2 ); } else { return this.equal(); } } else if ( attribute1 != null && attribute2 != null ) { return this.compareAttributes( attribute1, attribute2 ); } else { throw new ClassCastException( "Can only compare two values or two attributes" ); } } }
AttributeComparator implements Comparator<Object> { public int compare( Object o1, Object o2 ) { IAttribute attribute1 = null; IValue value1 = null; if ( o1 instanceof IAttribute ) { attribute1 = ( IAttribute ) o1; } else if ( o1 instanceof IValue ) { value1 = ( IValue ) o1; attribute1 = value1.getAttribute(); } IAttribute attribute2 = null; IValue value2 = null; if ( o2 instanceof IAttribute ) { attribute2 = ( IAttribute ) o2; } else if ( o2 instanceof IValue ) { value2 = ( IValue ) o2; attribute2 = value2.getAttribute(); } if ( value1 != null && value2 != null ) { if ( getSortByOrDefault() == BrowserCoreConstants.SORT_BY_ATTRIBUTE_DESCRIPTION ) { if ( value1.getAttribute() != value2.getAttribute() ) { return this.compareAttributes( value1.getAttribute(), value2.getAttribute() ); } else { return this.compareValues( value1, value2 ); } } else if ( getSortByOrDefault() == BrowserCoreConstants.SORT_BY_VALUE ) { return this.compareValues( value1, value2 ); } else { return this.equal(); } } else if ( attribute1 != null && attribute2 != null ) { return this.compareAttributes( attribute1, attribute2 ); } else { throw new ClassCastException( "Can only compare two values or two attributes" ); } } AttributeComparator();  AttributeComparator( int sortBy, int defaultSortBy, int sortOrder, int defaultSortOrder, boolean objectClassAndMustAttributesFirst,
        boolean operationalAttributesLast ); }
AttributeComparator implements Comparator<Object> { public int compare( Object o1, Object o2 ) { IAttribute attribute1 = null; IValue value1 = null; if ( o1 instanceof IAttribute ) { attribute1 = ( IAttribute ) o1; } else if ( o1 instanceof IValue ) { value1 = ( IValue ) o1; attribute1 = value1.getAttribute(); } IAttribute attribute2 = null; IValue value2 = null; if ( o2 instanceof IAttribute ) { attribute2 = ( IAttribute ) o2; } else if ( o2 instanceof IValue ) { value2 = ( IValue ) o2; attribute2 = value2.getAttribute(); } if ( value1 != null && value2 != null ) { if ( getSortByOrDefault() == BrowserCoreConstants.SORT_BY_ATTRIBUTE_DESCRIPTION ) { if ( value1.getAttribute() != value2.getAttribute() ) { return this.compareAttributes( value1.getAttribute(), value2.getAttribute() ); } else { return this.compareValues( value1, value2 ); } } else if ( getSortByOrDefault() == BrowserCoreConstants.SORT_BY_VALUE ) { return this.compareValues( value1, value2 ); } else { return this.equal(); } } else if ( attribute1 != null && attribute2 != null ) { return this.compareAttributes( attribute1, attribute2 ); } else { throw new ClassCastException( "Can only compare two values or two attributes" ); } } AttributeComparator();  AttributeComparator( int sortBy, int defaultSortBy, int sortOrder, int defaultSortOrder, boolean objectClassAndMustAttributesFirst,
        boolean operationalAttributesLast ); int compare( Object o1, Object o2 ); static List<IValue> toSortedValues( IEntry entry ); }
AttributeComparator implements Comparator<Object> { public int compare( Object o1, Object o2 ) { IAttribute attribute1 = null; IValue value1 = null; if ( o1 instanceof IAttribute ) { attribute1 = ( IAttribute ) o1; } else if ( o1 instanceof IValue ) { value1 = ( IValue ) o1; attribute1 = value1.getAttribute(); } IAttribute attribute2 = null; IValue value2 = null; if ( o2 instanceof IAttribute ) { attribute2 = ( IAttribute ) o2; } else if ( o2 instanceof IValue ) { value2 = ( IValue ) o2; attribute2 = value2.getAttribute(); } if ( value1 != null && value2 != null ) { if ( getSortByOrDefault() == BrowserCoreConstants.SORT_BY_ATTRIBUTE_DESCRIPTION ) { if ( value1.getAttribute() != value2.getAttribute() ) { return this.compareAttributes( value1.getAttribute(), value2.getAttribute() ); } else { return this.compareValues( value1, value2 ); } } else if ( getSortByOrDefault() == BrowserCoreConstants.SORT_BY_VALUE ) { return this.compareValues( value1, value2 ); } else { return this.equal(); } } else if ( attribute1 != null && attribute2 != null ) { return this.compareAttributes( attribute1, attribute2 ); } else { throw new ClassCastException( "Can only compare two values or two attributes" ); } } AttributeComparator();  AttributeComparator( int sortBy, int defaultSortBy, int sortOrder, int defaultSortOrder, boolean objectClassAndMustAttributesFirst,
        boolean operationalAttributesLast ); int compare( Object o1, Object o2 ); static List<IValue> toSortedValues( IEntry entry );  }