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

📄 customizationcommandlinebase.java

📁 对xml很好的java处理引擎,编译中绑定xml
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                int argcnt = 1;                while (!clas.getName().equals("java.lang.Object")) {                    try {                        method = clas.getDeclaredMethod(mname + "Text",                            STRING_UNMARSHALLER_PARAMETER_ARRAY);                        argcnt = 2;                        break;                    } catch (NoSuchMethodException e) {                        try {                            method = clas.getDeclaredMethod(mname,                                STRING_PARAMETER_ARRAY);                            break;                        } catch (NoSuchMethodException e1) {                            clas = clas.getSuperclass();                        }                    }                }                if (method == null) {                    clas = obj.getClass();                    while (!clas.getName().equals("java.lang.Object")) {                        try {                            Field field = clas.getDeclaredField(fname);                            try {                                field.setAccessible(true);                            } catch (SecurityException e) { /* deliberately empty */ }                            String type = field.getType().getName();                            if ("java.lang.String".equals(type)) {                                field.set(obj, value);                                fail = false;                            } else if ("boolean".equals(type) ||                                "java.lang.Boolean".equals(type)) {                                Boolean bval = null;                                if ("true".equals(value) || "1".equals(value)) {                                    bval = Boolean.TRUE;                                } else if ("false".equals(value) ||                                    "0".equals(value)) {                                    bval = Boolean.FALSE;                                }                                if (bval == null) {                                    throw new IllegalArgumentException("Unknown value '" + value + "' for boolean parameter " + key);                                }                                field.set(obj, bval);                                fail = false;                            } else if ("[Ljava.lang.String;".equals(type)) {                                try {                                    field.set(obj,                                        org.jibx.runtime.Utility.deserializeTokenList(value));                                    fail = false;                                } catch (JiBXException e) {                                    throw new IllegalArgumentException("Error processing list value + '" + value +'\'');                                }                            } else {                                throw new IllegalArgumentException("Cannot handle field of type " + type);                            }                            break;                        } catch (NoSuchFieldException e) {                            clas = clas.getSuperclass();                        }                    }                } else {                    try {                        method.setAccessible(true);                    } catch (SecurityException e) { /* deliberately empty */ }                    Object[] args = new Object[argcnt];                    args[0] = value;                    method.invoke(obj, args);                    fail = false;                }            } catch (IllegalAccessException e) {                t = e;            } catch (SecurityException e) {                t = e;            } catch (IllegalArgumentException e) {                t = e;            } catch (InvocationTargetException e) {                t = e;            } finally {                if (t != null) {                    t.printStackTrace();                    System.exit(1);                }            }            if (fail) {                missmap.put(key, value);            }        }        return missmap;    }        /**     * Set a key=value definition in a map. This is a command line processing     * assist method that prints an error message directly if the expected     * format is not found.     *     * @param def     * @param map     * @return <code>true</code> if successful, <code>false</code> if error     */    public static boolean putKeyValue(String def, Map map) {        int split = def.indexOf('=');        if (split >= 0) {            String key = def.substring(0, split);            if (map.containsKey(key)) {                System.err.println("Repeated key item: '" + def + '\'');                return false;            } else {                map.put(key, def.substring(split+1));                return true;            }        } else {            System.err.println("Missing '=' in expected key=value item: '" +                def + '\'');            return false;        }    }    /**     * Check extension parameter. This method may be overridden by subclasses     * to process parameters beyond those known to this base class.     *     * @param alist argument list     * @return <code>true</code> if parameter processed, <code>false</code> if     * unknown     */    protected boolean checkParameter(ArgList alist) {        return false;    }        /**     * Print any extension details. This method may be overridden by subclasses     * to print extension parameter values for verbose output.     */    protected void verboseDetails() {}        /**     * Load the customizations file. This method must load the specified     * customizations file, or create a default customizations instance, of the     * appropriate type.     *     * @param path customizations file path, <code>null</code> if none     * @param loc class locator     * @throws JiBXException     * @throws IOException     */    protected abstract void loadCustomizations(String path, IClassLocator loc)        throws JiBXException, IOException;        /**     * Apply map of override values to customizations read from file or     * created as default.     *     * @param overmap override key-value map     * @return map for key/values not recognized     */    protected abstract Map applyOverrides(Map overmap);        /**     * Merge two arrays of strings, returning an ordered array containing all     * the strings from both provided arrays.     *     * @param base     * @param adds     * @return ordered merged     */    protected String[] mergeUsageLines(String[] base, String[] adds) {        if (adds.length == 0) {            return base;        } else {            String fulls[] = new String[base.length + adds.length];            System.arraycopy(base, 0, fulls, 0, base.length);            System.arraycopy(adds, 0, fulls, base.length, adds.length);            Arrays.sort(fulls);            return fulls;        }    }        /**     * Print usage information.      */    public abstract void printUsage();        /**     * Wrapper class for command line argument list.     */    protected static class ArgList    {        private int m_offset;        private final String[] m_args;        private boolean m_valid;                /**         * Constructor.         *          * @param args         */        protected ArgList(String[] args) {            m_offset = -1;            m_args = args;            m_valid = true;        }                /**         * Check if another argument value is present.         *         * @return <code>true</code> if argument present, <code>false</code> if         * all processed         */        public boolean hasNext() {            return m_args.length - m_offset > 1;        }                /**         * Get current argument value.         *         * @return argument, or <code>null</code> if none         */        public String current() {            return (m_offset >= 0 && m_offset < m_args.length) ?                m_args[m_offset] : null;        }                /**         * Get next argument value. If this is called with no argument value         * available it sets the argument list invalid.         *         * @return argument, or <code>null</code> if none         */        public String next() {            if (++m_offset < m_args.length) {                return m_args[m_offset];            } else {                m_valid = false;                return null;            }        }                /**         * Set valid state.         *         * @param valid         */        public void setValid(boolean valid) {            m_valid = valid;        }                /**         * Check if argument list valid.         *         * @return <code>true</code> if valid, <code>false</code> if not         */        public boolean isValid() {            return m_valid;        }    }}

⌨️ 快捷键说明

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