diff options
author | lhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-12-31 16:26:40 +0000 |
---|---|---|
committer | lhauch <lhauch@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-12-31 16:26:40 +0000 |
commit | 808def96aa4589fba9c2d0ea55837754a3b7a4f7 (patch) | |
tree | 0ea221c59abb2474c694e7ab5bd61006be77e47e /Tools/Java/Source/MigrationTools/org/tianocore/migration/Common.java | |
parent | 9216450d1143056a50a5f916984a2d7faf590488 (diff) | |
download | edk2-platforms-808def96aa4589fba9c2d0ea55837754a3b7a4f7.tar.xz |
Retiring the ANT/JAVA build and removing the older EDK II packages that required ANT/JAVA.
Last Ant/Java build was r7166
Developers requiring the Java/Ant packages should checkout the branch from:
https://edk2.tianocore.org/svn/edk2/branches/AntJava
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7168 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Java/Source/MigrationTools/org/tianocore/migration/Common.java')
-rw-r--r-- | Tools/Java/Source/MigrationTools/org/tianocore/migration/Common.java | 255 |
1 files changed, 0 insertions, 255 deletions
diff --git a/Tools/Java/Source/MigrationTools/org/tianocore/migration/Common.java b/Tools/Java/Source/MigrationTools/org/tianocore/migration/Common.java deleted file mode 100644 index 3a6f179df8..0000000000 --- a/Tools/Java/Source/MigrationTools/org/tianocore/migration/Common.java +++ /dev/null @@ -1,255 +0,0 @@ -/** @file
-
- Copyright (c) 2006, Intel Corporation
- All rights reserved. This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
- **/
-package org.tianocore.migration;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public final class Common {
- public static final int BOTH = 0;
-
- public static final int FILE = 1;
-
- public static final int DIR = 2;
-
- public static final String STRSEPARATER = "(.*)\\\\([^\\\\]*)";
-
- public static final Pattern PTNSEPARATER = Pattern
- .compile("(.*)\\\\([^\\\\]*)");
-
- // -------------------------------------regex------------------------------------------//
-
- public static final String replaceAll(String line, Pattern ptn, String des) {
- Matcher mtr = ptn.matcher(line);
-
- if (mtr.find()) {
- return mtr.replaceAll(des);
- }
-
- return line;
- }
-
- public static final boolean find(String line, String regex) {
- Pattern ptn = Pattern.compile(regex);
-
- return ptn.matcher(line).find();
- }
-
- // -------------------------------------regex------------------------------------------//
-
- // -----------------------------------file&string---------------------------------------//
-
- public static final String file2string(String filename) throws Exception {
- BufferedReader rd = new BufferedReader(new FileReader(filename));
- StringBuffer wholefile = new StringBuffer();
- String line;
- while ((line = rd.readLine()) != null) {
- wholefile.append(line + "\n");
- }
- rd.close();
- return wholefile.toString();
- }
-
- public static final void string2file(String content, String filename)
- throws Exception {
- ensureDir(filename);
- PrintWriter outfile = new PrintWriter(new BufferedWriter(
- new FileWriter(filename)));
- outfile.append(content);
- outfile.flush();
- outfile.close();
- }
-
- public static final void fileCopy(String src, String des) throws Exception {
- string2file(file2string(src), des);
- }
-
- // -----------------------------------file&string---------------------------------------//
-
- // --------------------------------------dir--------------------------------------------//
- /*
- * public static final HashSet<String> walkDir(String path, int mode)
- * throws Exception { HashSet<String> pathlist = new HashSet<String>();
- * Common.toDoAll(path, Common.class.getMethod("walkDir", String.class),
- * null, null, mode); return pathlist; }
- */
- public static final void ensureDir(String objFileWhole) {
- File tempdir;
- Matcher mtrseparate = PTNSEPARATER.matcher(objFileWhole);
- if (mtrseparate.find()) {
- tempdir = new File(mtrseparate.group(1));
- if (!tempdir.exists())
- tempdir.mkdirs();
- }
- }
-
- public static final void deleteDir(String objFileWhole) {
- String[] list = new File(objFileWhole).list();
- File temp;
- for (int i = 0; i < list.length; i++) {
- temp = new File(objFileWhole + File.separator + list[i]);
- if (temp.isDirectory()) {
- deleteDir(objFileWhole + File.separator + list[i]);
- } else {
- temp.delete();
- }
- }
- new File(objFileWhole).delete();
- }
-
- public static final String dirCopy_(String src) throws Exception {
- Matcher mtrseparate = Common.PTNSEPARATER.matcher(src);
- if (mtrseparate.find()) {
- dirCopy(src, mtrseparate.group(1) + File.separator + "_"
- + mtrseparate.group(2));
- }
- return mtrseparate.group(1) + File.separator + "_"
- + mtrseparate.group(2);
- }
-
- public static final void dirCopy(String src, String des) throws Exception {
- String[] list = new File(src).list();
- File test;
-
- ensureDir(des);
- for (int i = 0; i < list.length; i++) {
- test = new File(src + File.separator + list[i]);
- if (test.isDirectory()) {
- dirCopy(src + File.separator + list[i], des + File.separator
- + list[i]);
- } else {
- // ensureDir(des + File.separator + list[i]);
- string2file(file2string(src + File.separator + list[i]), des
- + File.separator + list[i]);
- }
- }
- }
-
- public static final void oneLevelDirCopy(String src, String des, String type)
- throws Exception {
- String[] list = new File(src).list();
-
- ensureDir(des);
- for (int i = 0; i < list.length; i++) {
- if (list[i].contains(type)) {
- string2file(file2string(src + File.separator + list[i]), des
- + File.separator + list[i]);
- }
- }
- }
-
- // --------------------------------------dir--------------------------------------------//
-
- // -------------------------------like python
- // walk-----------------------------------------//
-
- public static final void toDoAll(String path, Method md, Object obj,
- Object[] args, int type) throws Exception {
- String[] list = new File(path).list();
- ArrayList<Object> _args = new ArrayList<Object>();
-
- _args.add(path);
- if (args != null) {
- for (int i = 0; i < args.length; i++) {
- _args.add(args[i]);
- }
- }
-
- if (type == DIR || type == BOTH) {
- md.invoke(obj, _args.toArray());
- }
- for (int i = 0; i < list.length; i++) {
- if (new File(path + File.separator + list[i]).isDirectory()) {
- toDoAll(path + File.separator + list[i], md, obj, args, type);
- } else {
- if (type == FILE || type == BOTH) {
- _args.set(0, path + File.separator + list[i]);
- md.invoke(obj, _args.toArray());
- }
- }
- }
- }
-
- public static final void toDoAll(Set<String> set, ForDoAll fda)
- throws Exception {
- Iterator<String> di = set.iterator();
- while (di.hasNext()) {
- fda.run(di.next());
- }
- }
-
- public static final void toDoAll(String path, ForDoAll fda, int type)
- throws Exception { // filter of file type can be done in toDo
- String[] list = new File(path).list();
- File test;
-
- if (type == DIR || type == BOTH) {
- fda.run(path);
- }
- for (int i = 0; i < list.length; i++) {
- test = new File(path + File.separator + list[i]);
- if (test.isDirectory()) {
- if (fda.filter(test)) {
- toDoAll(path + File.separator + list[i], fda, type);
- }
- } else {
- if (type == FILE || type == BOTH) {
- fda.run(path + File.separator + list[i]);
- }
- }
- }
- }
-
- public static interface ForDoAll {
- public void run(String filepath) throws Exception;
-
- public boolean filter(File dir);
- }
-
- public static abstract class Laplace {
- public void transform(String src, String des) throws Exception {
- Common.string2file(operation(Common.file2string(src)), des);
- }
-
- public abstract String operation(String wholeline);
-
- public abstract boolean recognize(String filename);
-
- public abstract String namechange(String oldname);
- }
-
- public static interface Element {
-
- // public int replace = 0;
- // public int type = 1;
-
- public String getReplace(String key);
-
- // public void getType(String key);
- //
- // public void setReplace(int num);
- //
- // public void setType(int num);
-
- }
-}
|