📄 bindinggeneratorcommandline.java
字号:
/*Copyright (c) 2007, Dennis M. SosnoskiAll rights reserved.Redistribution and use in source and binary forms, with or without modification,are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of JiBX nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ONANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/package org.jibx.binding.generator;import java.io.FileInputStream;import java.io.IOException;import java.util.List;import java.util.Map;import org.jibx.binding.model.IClassLocator;import org.jibx.runtime.BindingDirectory;import org.jibx.runtime.IBindingFactory;import org.jibx.runtime.IUnmarshallable;import org.jibx.runtime.IUnmarshallingContext;import org.jibx.runtime.JiBXException;/** * Command line processing specifically for the {@link BindingGenerator} class. */public class BindingGeneratorCommandLineextends CustomizationCommandLineBase{ /** Ordered array of extra usage lines. */ protected static final String[] EXTRA_USAGE_LINES = new String[] { " -a force abstract mappings for specified classes", " -b generated root binding name (default is 'binding.xml')", " -c force concrete mappings for specified classes" }; /** <code>TRUE</code> if abstract mappings forced, <code>FALSE</code> if concrete mappings forced, <code>null</code> if left to class settings. */ private Boolean m_abstract; /** Customizations model root. */ private GlobalCustom m_global; /** Name used for root binding. */ private String m_bindingName = "binding.xml"; /** * Get force abstract mapping setting. * * @return <code>TRUE</code> if abstract mappings forced, <code>FALSE</code> * if concrete mappings forced, <code>null</code> if left to class settings */ public Boolean getAbstract() { return m_abstract; } /** * Get customizations model root. * * @return customizations */ public GlobalCustom getGlobal() { return m_global; } /** * Get binding name. * * @return name */ public String getBindingName() { return m_bindingName; } /* (non-Javadoc) * @see org.jibx.binding.generator.CustomizationCommandLineBase#checkParameter(org.jibx.binding.generator.CustomizationCommandLineBase.ArgList) */ protected boolean checkParameter(ArgList alist) { boolean match = true; String arg = alist.current(); if ("-a".equalsIgnoreCase(arg)) { m_abstract = Boolean.TRUE; } else if ("-b".equalsIgnoreCase(arg)) { m_bindingName = alist.next(); } else if ("-c".equalsIgnoreCase(arg)) { m_abstract = Boolean.FALSE; } else { match = false; } return match; } /* (non-Javadoc) * @see org.jibx.binding.generator.CustomizationCommandLineBase#verboseDetails */ protected void verboseDetails() { System.out.println("Starting from classes:"); List types = getExtraArgs(); for (int i = 0; i < types.size(); i++) { System.out.println(" " + types.get(i)); } } /* (non-Javadoc) * @see org.jibx.binding.generator.CustomizationCommandLineBase#loadCustomizations(String,IClassLocator) */ protected void loadCustomizations(String path, IClassLocator loc) throws JiBXException, IOException { // load or create customization information m_global = new GlobalCustom(loc); if (path != null) { IBindingFactory fact = BindingDirectory.getFactory(GlobalCustom.class); IUnmarshallingContext ictx = fact.createUnmarshallingContext(); FileInputStream is = new FileInputStream(path); ictx.setDocument(is, null); ((IUnmarshallable)m_global).unmarshal(ictx); } } /* (non-Javadoc) * @see org.jibx.binding.generator.CustomizationCommandLineBase#applyOverrides(Map) */ protected Map applyOverrides(Map overmap) { Map unknowns = applyKeyValueMap(overmap, m_global); m_global.fillClasses(); return unknowns; } /* (non-Javadoc) * @see org.jibx.binding.generator.CustomizationCommandLineBase#printUsage() */ public void printUsage() { System.out.println ("\nUsage: java org.jibx.binding.generator.BindingGenerator " + "[options] class1 class2 ...\nwhere options are:"); String[] usages = mergeUsageLines(BASE_USAGE_LINES, EXTRA_USAGE_LINES); for (int i = 0; i < usages.length; i++) { System.out.println(usages[i]); } System.out.println ("The class# files are different classes to be included in " + "the binding (references from\nthese classes will also be " + "included).\n"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -