]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/ToolChainConfigVector.java
1. Restructure some folders and files
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / Identifications / ToolChainConfigVector.java
1 /** @file
2
3 The file is used to define Tool Chain Configuration Vector
4
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
10
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.
13
14 **/
15 package org.tianocore.frameworkwizard.common.Identifications;
16
17 import java.io.BufferedReader;
18 import java.io.FileNotFoundException;
19 import java.io.FileReader;
20 import java.io.IOException;
21 import java.util.Vector;
22
23 public class ToolChainConfigVector {
24
25 private Vector<ToolChainConfigId> vToolChainConfigs = new Vector<ToolChainConfigId>();
26
27 public int findToolChainConfigs(ToolChainConfigId sfi) {
28 for (int index = 0; index < vToolChainConfigs.size(); index++) {
29 if (vToolChainConfigs.elementAt(index).equals(sfi)) {
30 return index;
31 }
32 }
33 return -1;
34 }
35
36 public int findToolChainConfigs(String name) {
37 for (int index = 0; index < vToolChainConfigs.size(); index++) {
38 if (vToolChainConfigs.elementAt(index).getName().equals(name)) {
39 return index;
40 }
41 }
42 return -1;
43 }
44
45 public ToolChainConfigId getToolChainConfigs(int index) {
46 if (index > -1) {
47 return vToolChainConfigs.elementAt(index);
48 } else {
49 return null;
50 }
51 }
52
53 public Vector<String> toStringVector(int index) {
54 Vector<String> v = new Vector<String>();
55 v.addElement(getToolChainConfigs(index).getName());
56 v.addElement(getToolChainConfigs(index).getValue());
57 return v;
58 }
59
60 public void addToolChainConfigs(ToolChainConfigId arg0) {
61 vToolChainConfigs.addElement(arg0);
62 }
63
64 public void updateToolChainConfigs(ToolChainConfigId arg0, int arg1) {
65 vToolChainConfigs.setElementAt(arg0, arg1);
66 }
67
68 public void removeToolChainConfigs(ToolChainConfigId arg0) {
69 int index = findToolChainConfigs(arg0);
70 if (index > -1) {
71 vToolChainConfigs.removeElementAt(index);
72 }
73 }
74
75 public void removeToolChainConfigs(int index) {
76 if (index > -1 && index < this.size()) {
77 vToolChainConfigs.removeElementAt(index);
78 }
79 }
80
81 public void removeAll() {
82 vToolChainConfigs = new Vector<ToolChainConfigId>();
83 }
84
85 public Vector<String> getToolChainConfigsName() {
86 Vector<String> v = new Vector<String>();
87 for (int index = 0; index < this.vToolChainConfigs.size(); index++) {
88 v.addElement(vToolChainConfigs.get(index).getName());
89 }
90 return v;
91 }
92
93 public Vector<String> getToolChainConfigsValue() {
94 Vector<String> v = new Vector<String>();
95 for (int index = 0; index < this.vToolChainConfigs.size(); index++) {
96 v.addElement(vToolChainConfigs.get(index).getValue());
97 }
98 return v;
99 }
100
101 public int size() {
102 return this.vToolChainConfigs.size();
103 }
104
105 /**
106
107 @param file
108 @throws IOException
109 @throws FileNotFoundException
110
111 **/
112 public void parseFile(String file) throws IOException {
113 FileReader fr = new FileReader(file);
114 BufferedReader br = new BufferedReader(fr);
115 String line = br.readLine();
116 while (line != null) {
117 parseLine(line);
118 line = br.readLine();
119 }
120 }
121
122 /**
123 Parse the input string and add name, value to vector
124
125 @param line
126
127 **/
128 private void parseLine(String line) {
129 String name = "";
130 String value = "";
131 if (line.indexOf(ToolChainConfigId.COMMENTS) != 0 && line.indexOf(ToolChainConfigId.EQUALS) > -1) {
132 name = line.substring(0, line.indexOf(ToolChainConfigId.EQUALS)).trim();
133 value = line.substring(line.indexOf(ToolChainConfigId.EQUALS) + 1).trim();
134 this.addToolChainConfigs(new ToolChainConfigId(name, value));
135 }
136 }
137 }