Package org.swixml

Examples of org.swixml.ConverterLibrary


    Border border = null;
    StringTokenizer st = new StringTokenizer(attr.getValue(), "(,)"); // border type + parameters
    int n = st.countTokens() - 1; // number of parameter to create a border
    String borderType = st.nextToken().trim();
    Method method = null;
    ConverterLibrary cvtlib = ConverterLibrary.getInstance();
    //
    // Special case for single parameter construction, give priority to String Type
    //
    if (n == 0) {
      try {
        method = BorderFactory.class.getMethod("create" + borderType);

      } catch (NoSuchMethodException e) {
        // intent. empty
      }
      if (method == null) { // try with empty string
        n = 1;
        st = new StringTokenizer(" ", "(,)");
      }
    }
    if (n == 1) {
      try {
        method = BorderFactory.class.getMethod("create" + borderType, new Class[]{String.class});
      } catch (NoSuchMethodException e) {
        //  no need to do anything here.
      }
    }
    for (int i = 0; method == null && i < METHODS.length; i++) {
      if (METHODS[i].getParameterTypes().length == n && METHODS[i].getName().endsWith(borderType)) {
        method = METHODS[i];

        for (int j = 0; j < method.getParameterTypes().length; j++) {
          if (String.class.equals(method.getParameterTypes()[j])) {
            continue;
          }
          if (null == cvtlib.getConverter(method.getParameterTypes()[j])) {
            method = null;
            break;
          }
        }
      }
    }
    try {
      Object[] args = new Object[n];
      for (int i = 0; i < n; i++) { // fill argument array
        Converter converter = cvtlib.getConverter(method.getParameterTypes()[i]);
        Attribute attrib = new Attribute(String.class.equals(converter.convertsTo()) ? "title" : "NA", st.nextToken().trim());
        if (converter != null) {
          args[i] = converter.convert(method.getParameterTypes()[i], attrib, localizer);
        } else {
          args[i] = attrib.getValue();
View Full Code Here


    Border border = null;
    List<String> params = parse(attr.getValue()); // border type + parameters
    int n = params.size() - 1; // number of parameter to create a border
    String borderType = params.remove(0).trim();
    Method method = null;
    ConverterLibrary cvtlib = ConverterLibrary.getInstance();
    //
    // Special case for single parameter construction, give priority to String Type
    //
    if (n == 0) {
      try {
        method = BorderFactory.class.getMethod("create" + borderType);

      } catch (NoSuchMethodException e) {
        // intent. empty
      }
      if (method == null) { // try with empty string
        n = 1;
        params.add(" ");
      }
    }
    if (n == 1) {
      try {
        method = BorderFactory.class.getMethod("create" + borderType, new Class[]{String.class});
      } catch (NoSuchMethodException e) {
        //  no need to do anything here.
      }
    }
    for (int i = 0; method == null && i < METHODS.length; i++) {
      if (METHODS[i].getParameterTypes().length == n && METHODS[i].getName().endsWith(borderType)) {
        method = METHODS[i];

        for (int j = 0; j < method.getParameterTypes().length; j++) {
          if (String.class.equals(method.getParameterTypes()[j])) {
            continue;
          }
          if (null == cvtlib.getConverter(method.getParameterTypes()[j])) {
            method = null;
            break;
          }
        }
      }
    }
    try {
      Object[] args = new Object[n];
      for (int i = 0; i < n; i++) { // fill argument array
        Converter converter = cvtlib.getConverter(method.getParameterTypes()[i]);
        Attribute attrib =
          new Attribute(String.class.equals(converter.convertsTo()) ? "title" : "NA", params.remove(0).trim());
        if (converter != null) {
          args[i] = converter.convert(method.getParameterTypes()[i], attrib, localizer);
        } else {
View Full Code Here

TOP

Related Classes of org.swixml.ConverterLibrary

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.