Modyfy Splitter: Additional constructors. Now only k and m are necessary
[splitter-ng] / Splitter-ng-plugin-jerasure / src / jerasureplugin / CodecLiberation.java
index af0746d..45ca704 100644 (file)
@@ -20,6 +20,7 @@ public class CodecLiberation implements SplitterCodec {
                        + "Requirements: k<=w , m=2 , w>=3 and prim";
 
        public final static Map <String, Integer []> codecParameterMinMax;
+       public final static Map <String, Integer> codecParameterDefaults;
 
        private int k,m,w,packetsize;
        
@@ -31,11 +32,17 @@ public class CodecLiberation implements SplitterCodec {
                tmpMap.put("packetsize", new Integer[] {new Integer(1),new Integer(Integer.MAX_VALUE)});
                
                codecParameterMinMax  = Collections.unmodifiableMap(tmpMap);                            
+
+               Map <String, Integer> tmpMap2 = new HashMap<String, Integer>();
+               tmpMap2.put("w", new Integer(7));
+               tmpMap2.put("packetsize", new Integer(32));
+               
+               codecParameterDefaults  = Collections.unmodifiableMap(tmpMap2);                         
        }
        
        
        private static final CodecDescription codecDescription = new CodecDescription(
-       codecID, codecName, codecDescriptionText, codecParameterMinMax);
+       codecID, codecName, codecDescriptionText, codecParameterMinMax, codecParameterDefaults);
        
        private int[] matrix;
        private int[] bitmatrix;
@@ -59,7 +66,7 @@ public class CodecLiberation implements SplitterCodec {
                super();
                
                //Test CodecParameter
-               for (Entry<String, Integer[]> requiredEntry : CodecLiberation.codecParameterMinMax
+               for (Entry<String, Integer[]> requiredEntry : codecParameterMinMax
                                .entrySet()) {
                        if (codecParameter.containsKey(requiredEntry.getKey())) {
                                // Test ob Parameter vorhanden und in den gültigen grenzen
@@ -75,6 +82,8 @@ public class CodecLiberation implements SplitterCodec {
                                                        "unzulässiger Wert für Parameter: "
                                                                        + requiredEntry.getKey() + " > "
                                                                        + requiredEntry.getValue()[1]);
+                       } else if (codecParameterDefaults.containsKey(requiredEntry.getKey())) {
+                               codecParameter.put(requiredEntry.getKey(), codecParameterDefaults.get(requiredEntry.getKey()));
                        } else {
                                throw new IllegalArgumentException("Missing Codec Parameter: "
                                                + requiredEntry.getKey());