⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlconfigurator.java

📁 本人历尽千辛万苦找的clustream中的jar包
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        attrs_class = null;
        return;
    }

    if (local.equals(CLASSMETHOD)) {
        Class method_class = null;
        Method method = null;
        Object return_object = null;
        try {
            method_class = Class.forName(attrs_class);
        } catch (ClassNotFoundException cnfe) {
            logCAT.error(
                "endElement() - CLASSMETHOD Branch - Class.forName("
                    + attrs_class
                    + ") caught ClassNotFoundException");
        }

        if (argument_list.size() == 0) {
            try {
                method = method_class.getMethod(attrs_method, null);
            } catch (NoSuchMethodException nsme) {
                logCAT.error(
                    "endElement() - CLASSMETHOD Branch - getConstructor(Class[]) caught NoSuchMethodFoundException");
            }
        } else {
            int nargs = argclass_list.size();
            Class[] ca = new Class[nargs];
            try {
                for (int i = 0; i < nargs; i++)
                    ca[i] = (Class) argclass_list.get(i);
                method = method_class.getMethod(attrs_method, ca);
            } catch (NoSuchMethodException nsme) {
                logCAT.error(
                    "endElement() - CLASSMETHOD Branch - getConstructor(Class[]) caught NoSuchMethodFoundException");
            }
        }

        try {
            return_object = method.invoke(null, argument_list.toArray());
        } catch (IllegalAccessException iae) {
            logCAT.error(
                "endElement() - CLASSMETHOD Branch - method.invoke() caught IllegalAccessException");
        } catch (java.lang.reflect.InvocationTargetException ite) {
            logCAT.error(
                "endElement() - CLASSMETHOD Branch - method.invoke() caught InvocationTargetException") ;
        }

        if (return_object != null)
            treemap.put(stack.peek(), return_object);
        stack.pop();
        argument_list = null;
        argclass_list = null;
        context = N_CTX;
        attrs_class = null;
        attrs_method = null;
        return;
    }

    if (local.equals(INSTANCEMETHOD)) {
        Class method_class = null;
        Object instance = treemap.get(attrs_reference);
        Object return_object = null;
        // instance is obtained by key (reference)
        Method method = null;

        if (instance == null) {
            logCAT.error(
                "endElement() - INSTANCEMETHOD Branch - No reference found in table with key: "
                    + attrs_reference);
        }

        method_class = instance.getClass();

        if (argument_list.size() == 0) {
            try {
                method = method_class.getMethod(attrs_method, null);
            } catch (NoSuchMethodException nsme) {
                logCAT.error(
                    "endElement() - INSTANCEMETHOD Branch - getConstructor(Class[]) caught NoSuchMethodFoundException");
            }
        } else {
            int nargs = argclass_list.size();
            Class[] ca = new Class[nargs];
            try {
                for (int i = 0; i < nargs; i++)
                    ca[i] = (Class) argclass_list.get(i);
                method = method_class.getMethod(attrs_method, ca);
            } catch (NoSuchMethodException nsme) {
                logCAT.error(
                    "endElement() - INSTANCEMETHOD Branch - getConstructor(Class[]) caught NoSuchMethodFoundException");
            }
        }

        try {
            return_object = method.invoke(instance, argument_list.toArray());
        } catch (IllegalAccessException iae) {
            logCAT.error(
                "endElement() - INSTANCEMETHOD Branch - method.invoke() caught IllegalAccessException");
        } catch (java.lang.reflect.InvocationTargetException ite) {
            logCAT.error(
                "endElement() - INSTANCEMETHOD Branch - method.invoke() caught InvocationTargetException");
        }

        if (return_object != null)
            treemap.put(stack.peek(), return_object);
        stack.pop();
        argument_list = null;
        argclass_list = null;
        context = N_CTX;
        attrs_reference = null;
        attrs_method = null;
        return;
    }
    	logCAT.debug(local + data_element_typename + strGlobalChar);
        if (local.equals(STRING) && data_element_typename.equals(STRING)) {
            arg_object = strGlobalChar;
            arg_class = STRING_CLASS;
        }
	else if (local.equals(BOOLEAN) && data_element_typename.equals(BOOLEAN)) {
            arg_object = new Boolean(strGlobalChar);
            arg_class = BOOLEAN_CLASS;
        }
	else if (local.equals(INTEGER) && data_element_typename.equals(INTEGER)) {
            arg_object = new Integer(strGlobalChar);
            arg_class = INTEGER_CLASS;
        }
	else if (local.equals(BYTE) && data_element_typename.equals(BYTE)) {
            arg_object = new Byte(strGlobalChar);
            arg_class = BYTE_CLASS;
        }
	else if (local.equals(SHORT) && data_element_typename.equals(SHORT)) {
            arg_object = new Short(strGlobalChar);
            arg_class = SHORT_CLASS;
        }
	else if (local.equals(LONG) && data_element_typename.equals(LONG)) {
            arg_object = new Long(strGlobalChar);
            arg_class = LONG_CLASS;
        }
	else if (local.equals(FLOAT) && data_element_typename.equals(FLOAT)) {
            arg_object = new Float(strGlobalChar);
            arg_class = FLOAT_CLASS;
        }
	else if (local.equals(DOUBLE) && data_element_typename.equals(DOUBLE)) {
            arg_object = new Double(strGlobalChar);
            arg_class = DOUBLE_CLASS;
        }
	else if (local.equals(REFERENCE) && data_element_typename.equals(REFERENCE)) {
            // get object reference from the TreeMap
            arg_object = treemap.get(strGlobalChar);
            if (arg_object == null)
                logCAT.error(
                    "characters() - Null reference returned for REFERENCE (" + strGlobalChar+ ")");
            arg_class = arg_object.getClass();
        }

    if (local.equals(REFERENCE)
        | local.equals(BOOLEAN)
        | local.equals(BYTE)
        | local.equals(SHORT)
        | local.equals(INTEGER)
        | local.equals(LONG)
        | local.equals(FLOAT)
        | local.equals(DOUBLE)
        | local.equals(STRING)) {

        switch (context) {
            case P_CTX : // Nothing done while in a "Parameter context" - Do it later, at Parameter close 
                break;
            case O_CTX :
            case C_CTX :
            case I_CTX :
                argument_list.add(arg_object);
                argclass_list.add(arg_class);
                break;
            default :
                logCAT.error(
                    "endElement() detected an internal parsing error: invalid context");
                break;
        	}
            return;
    	}
	data_element_typename = null;		// clear reference to current element name
}
public void error(SAXParseException ex) {

    logCAT.error("[Error] " + getLocationString(ex) + ": " + ex.getMessage());
}
public void fatalError(SAXParseException ex) throws SAXException {

    logCAT.fatal("[Fatal Error] " + getLocationString(ex) + ": " + ex.getMessage());
    throw ex;
}
public static float floatValue(String key) {
    if (initialized) {
        Object obj = treemap.get(key);
        if (obj == null) {
            logCAT.error("floatValue() found a null value for key '" + key + "'");
            System.exit(1);
            return 0;
        } else {
            try {
                return ((Float) obj).floatValue();
            } catch (java.lang.ClassCastException e) {
                logCAT.error("floatValue() caught ClassCastException: " + e);
                System.exit(1);
                return 0;
            }
        }
    } else {
        logCAT.error("floatValue() called before initialization");
        System.exit(1);
        return 0;
    }
}
public static synchronized Object setParameter(Object key, Object value)
{
	return treemap.put(key, value);
}

public static Object getClassParameter(Class cl, String pname) {
    if (initialized) {
        String name = cl.getName();
        String key = name + "." + pname;
        return treemap.get(key);
    } else {
        return null;
    }
}
public static Object getClassParameter(Object obj, String pname) {
    if (initialized) {
        String name = obj.getClass().getName();
        String key = name + "." + pname;
        return treemap.get(key);
    } else {
        return null;
    }
}
private String getLocationString(SAXParseException ex) {
    StringBuffer str = new StringBuffer();

    String systemId = ex.getSystemId();
    if (systemId != null) {
        int index = systemId.lastIndexOf('/');
        if (index != -1)
            systemId = systemId.substring(index + 1);
        str.append(systemId);
    }
    str.append(':');
    str.append(ex.getLineNumber());
    str.append(':');
    str.append(ex.getColumnNumber());

    return str.toString();

}
    public static synchronized Object getParameter(String key) {
	    if (initialized) {
		   	return treemap.get(key);
	    } else { 
		    return null;
		}
   }
/*public static synchronized void init(String[] uri_array)
    throws ConfigurationException {
    if (initialized) {
        throw new ConfigurationException("XMLConfigurator - Initialization already completed");
    } else {
        try {
            XMLConfigurator configurator = new XMLConfigurator();
            XMLReader parser = (XMLReader) Class.forName(DEFAULT_PARSER_NAME).newInstance();
            parser.setContentHandler(configurator);
            parser.setErrorHandler(configurator);

            parser.setFeature("http://xml.org/sax/features/validation", setValidation);
            parser.setFeature("http://xml.org/sax/features/namespaces", setNameSpaces);
            parser.setFeature(
                "http://apache.org/xml/features/validation/schema",
                setSchemaSupport);
            parser.setFeature(
                "http://apache.org/xml/features/validation/schema-full-checking",
                setSchemaFullSupport);
            for (int i = 0; i < uri_array.length; i++) {
		logCAT.debug(uri_array[i]);
                parser.parse(uri_array[i]);
//                formatter.applyPattern(bundle.getString("config_file_parsed"));
//                Object[] one_argument = {uri_array[i]};
//				logCAT.info(formatter.format(one_argument));
            }

            initialized = true;

        } catch (org.xml.sax.SAXParseException spe) {
	        logCAT.error("Caught SAXParseException: \n\t"+spe); 
            spe.printStackTrace(System.err);
            System.exit(1);
        } catch (org.xml.sax.SAXException se) {
   	        logCAT.error("Caught SAXException: \n\t"+se); 
            if (se.getException() != null) {
                se.getException().printStackTrace(System.err);
                System.exit(1);
            } else {
                se.printStackTrace(System.err);
                System.exit(1);
            }
        } catch (Exception e) {
   	        logCAT.error("Caught Exception: \n\t"+e); 
            e.printStackTrace(System.err);
            System.exit(1);
        }
    }
}*/
public static synchronized void init(String[] uri_array)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -