2668N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2668N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2668N/A * This code is free software; you can redistribute it and/or modify it 2668N/A * under the terms of the GNU General Public License version 2 only, as 2668N/A * published by the Free Software Foundation. Oracle designates this 2668N/A * particular file as subject to the "Classpath" exception as provided 2668N/A * by Oracle in the LICENSE file that accompanied this code. 2668N/A * This code is distributed in the hope that it will be useful, but WITHOUT 2668N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2668N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2668N/A * version 2 for more details (a copy is included in the LICENSE file that 2668N/A * You should have received a copy of the GNU General Public License version 2668N/A * 2 along with this work; if not, write to the Free Software Foundation, 2668N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2668N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2668N/A * or visit www.oracle.com if you need additional information or have any 2668N/Apackage xmlkit;
// -*- mode: java; indent-tabs-mode: nil -*- 2668N/A // Convert options string into optLines dictionary. 2668N/A * Remove a set of command-line options from args, 2668N/A * storing them in the properties map in a canonicalized form. 2668N/A //System.out.println(args+" // "+properties); 2668N/A // State machine for parsing a command line. 2668N/A // One trip through this loop per argument. 2668N/A // Multiple trips per option only if several options per argument. 2668N/A // No more arguments at all. 2668N/A // One time through this loop for each matching arg prefix. 2668N/A // Match some prefix of the argument to a key in optmap. 2668N/A // Decide on a smaller prefix to search for. 2668N/A // pfxmap.lastKey is no shorter than any prefix in optmap. 2668N/A // (Note: We could cut opt down to its common prefix with 2668N/A // pfxmap.lastKey, but that wouldn't save many cycles.) 2668N/A // Execute the option processing specs for this opt. 2668N/A // If no actions are taken, then look for a shorter prefix. 2668N/A // Deal with '+'/'*' prefixes (spec conditions). 2668N/A // + means we want an non-empty val suffix. 2668N/A // * means we accept empty or non-empty 2668N/A // No condition prefix means we require an exact 2668N/A // match, as indicated by an empty val suffix. 2668N/A case '.':
// terminate the option sequence 2668N/A case '?':
// abort the option sequence 2668N/A case '@':
// change the effective opt name 2668N/A case '>':
// shift remaining arg val to next arg 2668N/A case '!':
// negation option 2668N/A case '$':
// normal "boolean" option 2668N/A // If there is a given spec token, store it. 2668N/A // Increment any previous value as a numeral. 2668N/A case '=':
// "string" option 2668N/A case '&':
// "collection" option 2668N/A // Append new val to old with embedded delim. 2668N/A // The specs should have done something, but did not. 2668N/A // Remove anything pushed during these specs. 2668N/A // We cannot try a shorter matching option. 2668N/A // If we come here, there was no matching option. 2668N/A // So, push back the argument, and return to caller. 2668N/A // Report number of arguments consumed. 2668N/A // Report any unconsumed partial argument. 2668N/A //System.out.println(args+" // "+properties+" -> "+resultString);