X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=third-party%2Fopenflow-codec%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenflow%2Fcodec%2Fprotocol%2FOFPMatchBeanInfo.java;fp=third-party%2Fopenflow-codec%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenflow%2Fcodec%2Fprotocol%2FOFPMatchBeanInfo.java;h=0000000000000000000000000000000000000000;hb=64fe0fbca1a6c2b77ad25f568d73a7eb64236d16;hp=63f0213ef32d3e97a2affc77e47a20e435adde18;hpb=8b9a3ff2bbc83941254b46b818cbbae5cc1a3a5b;p=openflowjava.git diff --git a/third-party/openflow-codec/src/main/java/org/openflow/codec/protocol/OFPMatchBeanInfo.java b/third-party/openflow-codec/src/main/java/org/openflow/codec/protocol/OFPMatchBeanInfo.java deleted file mode 100644 index 63f0213e..00000000 --- a/third-party/openflow-codec/src/main/java/org/openflow/codec/protocol/OFPMatchBeanInfo.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.openflow.codec.protocol; - -import java.beans.IntrospectionException; -import java.beans.PropertyDescriptor; -import java.beans.SimpleBeanInfo; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.LinkedList; -import java.util.List; - -/** - * Extra info for how to treat OFPMatch as a JavaBean - * - * For some (inane!) reason, using chained setters in OFPMatch breaks a lot of - * the JavaBean defaults. - * - * We don't really use OFPMatch as a java bean, but there are a lot of nice XML - * utils that work for free if OFPMatch follows the java bean paradigm. - * - * @author Rob Sherwood (rob.sherwood@stanford.edu) - * - */ - -public class OFPMatchBeanInfo extends SimpleBeanInfo { - - @Override - public PropertyDescriptor[] getPropertyDescriptors() { - List descs = new LinkedList(); - Field[] fields = OFPMatch.class.getDeclaredFields(); - String name; - for (int i = 0; i < fields.length; i++) { - int mod = fields[i].getModifiers(); - if (Modifier.isFinal(mod) || // don't expose static or final fields - Modifier.isStatic(mod)) - continue; - - name = fields[i].getName(); - Class type = fields[i].getType(); - - try { - descs.add(new PropertyDescriptor(name, name2getter(OFPMatch.class, name), name2setter(OFPMatch.class, - name, type))); - } catch (IntrospectionException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - return descs.toArray(new PropertyDescriptor[0]); - } - - private Method name2setter(Class c, String name, Class type) { - String mName = "set" + toLeadingCaps(name); - Method m = null; - try { - m = c.getMethod(mName, new Class[] { type }); - } catch (SecurityException e) { - - e.printStackTrace(); - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - return m; - } - - private Method name2getter(Class c, String name) { - String mName = "get" + toLeadingCaps(name); - Method m = null; - try { - m = c.getMethod(mName, new Class[] {}); - } catch (SecurityException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - return m; - } - - private String toLeadingCaps(String s) { - char[] array = s.toCharArray(); - array[0] = Character.toUpperCase(array[0]); - return String.valueOf(array, 0, array.length); - } -}