1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
756 throw new BadCommandLineException(
757 Messages.format(Messages.NOT_A_FILE_NOR_URL,name));
758 }
759 if(src instanceof URL) {
760 target.add(absolutize(new InputSource(Util.escapeSpace(((URL)src).toExternalForm()))));
761 } else {
762 File fsrc = (File)src;
763 if(fsrc.isDirectory()) {
764 addRecursive(fsrc,suffix,target);
765 } else {
766 target.add(absolutize(fileToInputSource(fsrc)));
767 }
768 }
769 }
770
771 /**
772 * Adds a new catalog file.
773 */
774 public void addCatalog(File catalogFile) throws IOException {
775 if(entityResolver==null) {
776 CatalogManager.getStaticManager().setIgnoreMissingProperties(true);
777 entityResolver = new CatalogResolver(true);
778 }
779 ((CatalogResolver)entityResolver).getCatalog().parseCatalog(catalogFile.getPath());
780 }
781
782 /**
783 * Parses arguments and fill fields of this object.
784 *
785 * @exception BadCommandLineException
786 * thrown when there's a problem in the command-line arguments
787 */
788 public void parseArguments( String[] args ) throws BadCommandLineException {
789
790 for (int i = 0; i < args.length; i++) {
791 if(args[i].length()==0)
792 throw new BadCommandLineException();
793 if (args[i].charAt(0) == '-') {
794 int j = parseArgument(args,i);
795 if(j==0)
796 throw new BadCommandLineException(
|
1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
756 throw new BadCommandLineException(
757 Messages.format(Messages.NOT_A_FILE_NOR_URL,name));
758 }
759 if(src instanceof URL) {
760 target.add(absolutize(new InputSource(Util.escapeSpace(((URL)src).toExternalForm()))));
761 } else {
762 File fsrc = (File)src;
763 if(fsrc.isDirectory()) {
764 addRecursive(fsrc,suffix,target);
765 } else {
766 target.add(absolutize(fileToInputSource(fsrc)));
767 }
768 }
769 }
770
771 /**
772 * Adds a new catalog file.
773 */
774 public void addCatalog(File catalogFile) throws IOException {
775 if(entityResolver==null) {
776 final CatalogManager staticManager = CatalogManager.getStaticManager();
777 // hack to force initialization so catalog manager system properties take effect
778 staticManager.getVerbosity();
779 staticManager.setIgnoreMissingProperties(true);
780 entityResolver = new CatalogResolver(true);
781 }
782 ((CatalogResolver)entityResolver).getCatalog().parseCatalog(catalogFile.getPath());
783 }
784
785 /**
786 * Parses arguments and fill fields of this object.
787 *
788 * @exception BadCommandLineException
789 * thrown when there's a problem in the command-line arguments
790 */
791 public void parseArguments( String[] args ) throws BadCommandLineException {
792
793 for (int i = 0; i < args.length; i++) {
794 if(args[i].length()==0)
795 throw new BadCommandLineException();
796 if (args[i].charAt(0) == '-') {
797 int j = parseArgument(args,i);
798 if(j==0)
799 throw new BadCommandLineException(
|