]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/ToolChainConfigVector.java
3 The file is used to define Tool Chain Configuration Vector
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.
15 package org
.tianocore
.frameworkwizard
.common
.Identifications
;
17 import java
.io
.BufferedReader
;
18 import java
.io
.BufferedWriter
;
19 import java
.io
.FileNotFoundException
;
20 import java
.io
.FileReader
;
21 import java
.io
.FileWriter
;
22 import java
.io
.IOException
;
23 import java
.util
.Vector
;
25 public class ToolChainConfigVector
{
27 private Vector
<ToolChainConfigId
> vToolChainConfigs
= new Vector
<ToolChainConfigId
>();
29 public int findToolChainConfigs(ToolChainConfigId sfi
) {
30 for (int index
= 0; index
< vToolChainConfigs
.size(); index
++) {
31 if (vToolChainConfigs
.elementAt(index
).equals(sfi
)) {
38 public int findToolChainConfigs(String name
) {
39 for (int index
= 0; index
< vToolChainConfigs
.size(); index
++) {
40 if (vToolChainConfigs
.elementAt(index
).getName().equals(name
)) {
47 public ToolChainConfigId
getToolChainConfigs(int index
) {
49 return vToolChainConfigs
.elementAt(index
);
55 public Vector
<String
> toStringVector(int index
) {
56 Vector
<String
> v
= new Vector
<String
>();
57 v
.addElement(getToolChainConfigs(index
).getName());
58 v
.addElement(getToolChainConfigs(index
).getValue());
62 public void addToolChainConfigs(ToolChainConfigId arg0
) {
63 vToolChainConfigs
.addElement(arg0
);
66 public void updateToolChainConfigs(ToolChainConfigId arg0
, int arg1
) {
67 vToolChainConfigs
.setElementAt(arg0
, arg1
);
70 public void removeToolChainConfigs(ToolChainConfigId arg0
) {
71 int index
= findToolChainConfigs(arg0
);
73 vToolChainConfigs
.removeElementAt(index
);
77 public void removeToolChainConfigs(int index
) {
78 if (index
> -1 && index
< this.size()) {
79 vToolChainConfigs
.removeElementAt(index
);
83 public void removeAll() {
84 vToolChainConfigs
= new Vector
<ToolChainConfigId
>();
87 public Vector
<String
> getToolChainConfigsName() {
88 Vector
<String
> v
= new Vector
<String
>();
89 for (int index
= 0; index
< this.vToolChainConfigs
.size(); index
++) {
90 v
.addElement(vToolChainConfigs
.get(index
).getName());
95 public Vector
<String
> getToolChainConfigsValue() {
96 Vector
<String
> v
= new Vector
<String
>();
97 for (int index
= 0; index
< this.vToolChainConfigs
.size(); index
++) {
98 v
.addElement(vToolChainConfigs
.get(index
).getValue());
104 return this.vToolChainConfigs
.size();
107 public void saveFile(String file
) throws IOException
{
109 FileWriter fw
= new FileWriter(file
);
110 BufferedWriter bw
= new BufferedWriter(fw
);
111 for (int index
= 0; index
< size(); index
++) {
112 String line
= this.getToolChainConfigs(index
).getName() + " " + ToolChainConfigId
.EQUALS
+ " "
113 + this.getToolChainConfigs(index
).getValue();
127 @throws FileNotFoundException
130 public void parseFile(String file
) throws IOException
{
131 FileReader fr
= new FileReader(file
);
132 BufferedReader br
= new BufferedReader(fr
);
133 String line
= br
.readLine();
134 while (line
!= null) {
136 line
= br
.readLine();
141 Parse the input string and add name, value to vector
146 private void parseLine(String line
) {
149 if (line
.indexOf(ToolChainConfigId
.COMMENTS
) != 0 && line
.indexOf(ToolChainConfigId
.EQUALS
) > -1) {
150 name
= line
.substring(0, line
.indexOf(ToolChainConfigId
.EQUALS
)).trim();
151 value
= line
.substring(line
.indexOf(ToolChainConfigId
.EQUALS
) + 1).trim();
152 this.addToolChainConfigs(new ToolChainConfigId(name
, value
));