2 File is ParseParameter class which is used to parse the validity of user's input args
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
.tianocore
.context
;
16 public class ParseParameter
{
20 * check the validity of user's input args
21 * @param args -- user's input
22 * @return true or false
24 public static boolean checkParameter(String
[] args
) {
27 HelpInfo
.outputUsageInfo();
30 if( args
[0].charAt(0) != '-' ){
31 HelpInfo
.outputUsageInfo();
34 for(int i
=0; i
<args
.length
; i
++){
35 if( (args
[i
].compareToIgnoreCase("-h") == 0) ||
36 (args
[i
].startsWith("-") && ((args
[i
].charAt(1) != 'a') && (args
[i
].charAt(1) != 'c')
37 && (args
[i
].charAt(1) != 'n') && (args
[i
].charAt(1) != 'p') && (args
[i
].charAt(1) != 't')))){
38 HelpInfo
.outputUsageInfo();
44 standardizeParameter(args
);
49 * standardize user's input args
50 * @param args -- user's input
51 * @return no return value
53 private static void standardizeParameter(String
[] args
) {
55 length
= pstr
.length();
57 StringBuffer InputData
= new StringBuffer();
58 for (int i
= 0; i
< args
.length
; i
++) {
59 InputData
.append(args
[i
]);
60 InputData
.append(" ");
64 while (i
< InputData
.length()) {
65 int j
= InputData
.indexOf("-", i
+ 1);
67 j
= InputData
.length();
69 String argstr
= InputData
.substring(i
, j
);
71 if (argstr
.charAt(1) == 'p') {
72 pstr
+= argstr
.substring(2);
74 } else if (argstr
.charAt(1) == 't') {
75 tstr
+= argstr
.substring(2);
77 } else if (argstr
.charAt(1) == 'a') {
78 astr
+= argstr
.substring(2);
80 } else if (argstr
.charAt(1) == 'c') {
81 cstr
+= argstr
.substring(2);
83 } else if (argstr
.charAt(1) == 'n') {
84 nstr
+= argstr
.substring(2);
92 public static int length
= 0;
93 public static String pstr
= new String("ACTIVE_PLATFORM = ");
94 public static String tstr
= new String("TARGET = ");
95 public static String astr
= new String("TARGET_ARCH = ");
96 public static String cstr
= new String("TOOL_CHAIN_CONF = ");
97 public static String nstr
= new String("TOOL_CHAIN_TAG = ");