1 50 51 package org.openlaszlo.iv.flash.context; 52 53 import java.util.*; 54 55 63 64 public abstract class GraphContext extends Context 65 { 66 public abstract List getValueList( String path ); 67 68 public abstract String getValue( String path ); 69 70 protected List getValueListFromParent( String path ) 71 { 72 Context parent = getParent(); 73 74 77 while ( parent != null ) 78 { 79 80 if ( parent instanceof GraphContext ) 81 { 82 return ( ( GraphContext ) parent ).getValueList( path ); 83 } 84 else 85 { 86 parent = parent.getParent(); 87 } 88 } 89 90 92 return null; 93 } 94 95 103 104 public static List sortValueList( List list, 105 final String sortby, 106 final boolean ascending ) 107 { 108 110 ArrayList newList = new ArrayList( list ); 111 112 114 Collections.sort( newList, new java.util.Comparator () 115 { 116 public int compare( Object o1, Object o2 ) 117 { 118 String val1 = ( ( GraphContext ) o1 ).getValue( sortby ); 119 String val2 = ( ( GraphContext ) o2 ).getValue( sortby ); 120 121 if( ascending ) 122 { 123 return val1.compareTo( val2 ); 124 } 125 else 126 { 127 return val2.compareTo( val1 ); 128 } 129 } 130 } 131 ); 132 133 return newList; 134 } 135 136 } 137 | Popular Tags |