]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Sort.java
1. Provide "Find" function for Ppi/Protocol/Guid/Pcd/LibraryClass.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / Sort.java
index 88fe64e4d93cf2853a5cd75a14e9203a0136ddd3..65a345ab5b515d7ecc3b72d55b0f6dc771e3591d 100644 (file)
@@ -18,8 +18,18 @@ package org.tianocore.frameworkwizard.common;
 import java.util.Vector;\r
 \r
 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.Guids.GuidsIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.Guids.GuidsVector;\r
+import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassVector;\r
+import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdCodedIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdCodedVector;\r
 import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdIdentification;\r
 import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdVector;\r
+import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisVector;\r
+import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsVector;\r
 import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
 import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
 \r
@@ -212,6 +222,135 @@ public class Sort {
         }\r
     }\r
 \r
+    /**\r
+     Sort all ppi entries\r
+     \r
+     @param v\r
+     @param mode\r
+     \r
+     **/\r
+    public static void sortPpis(PpisVector v, int mode) {\r
+        if (v != null) {\r
+            //\r
+            // sort by name\r
+            //\r
+            for (int indexI = 0; indexI < v.size(); indexI++) {\r
+                for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) {\r
+                    if ((v.getPpis(indexJ).getName().compareTo(v.getPpis(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING)\r
+                        || (v.getPpis(indexI).getName().compareTo(v.getPpis(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) {\r
+                        PpisIdentification temp = v.getPpis(indexI);\r
+                        v.setPpis(v.getPpis(indexJ), indexI);\r
+                        v.setPpis(temp, indexJ);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     Sort all protocol entries\r
+     \r
+     @param v\r
+     @param mode\r
+     \r
+     **/\r
+    public static void sortProtocols(ProtocolsVector v, int mode) {\r
+        if (v != null) {\r
+            //\r
+            // sort by name\r
+            //\r
+            for (int indexI = 0; indexI < v.size(); indexI++) {\r
+                for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) {\r
+                    if ((v.getProtocols(indexJ).getName().compareTo(v.getProtocols(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING)\r
+                        || (v.getProtocols(indexI).getName().compareTo(v.getProtocols(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) {\r
+                        ProtocolsIdentification temp = v.getProtocols(indexI);\r
+                        v.setProtocols(v.getProtocols(indexJ), indexI);\r
+                        v.setProtocols(temp, indexJ);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     Sort all guid entries\r
+     \r
+     @param v\r
+     @param mode\r
+     \r
+     **/\r
+    public static void sortGuids(GuidsVector v, int mode) {\r
+        if (v != null) {\r
+            //\r
+            // sort by name\r
+            //\r
+            for (int indexI = 0; indexI < v.size(); indexI++) {\r
+                for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) {\r
+                    if ((v.getGuids(indexJ).getName().compareTo(v.getGuids(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING)\r
+                        || (v.getGuids(indexI).getName().compareTo(v.getGuids(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) {\r
+                        GuidsIdentification temp = v.getGuids(indexI);\r
+                        v.setGuids(v.getGuids(indexJ), indexI);\r
+                        v.setGuids(temp, indexJ);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     Sort all pcd coded entries\r
+     \r
+     @param v\r
+     @param mode\r
+     \r
+     **/\r
+    public static void sortPcdCodeds(PcdCodedVector v, int mode) {\r
+        if (v != null) {\r
+            //\r
+            // sort by name\r
+            //\r
+            for (int indexI = 0; indexI < v.size(); indexI++) {\r
+                for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) {\r
+                    if ((v.getPcdCoded(indexJ).getName().compareTo(v.getPcdCoded(indexI).getName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING)\r
+                        || (v.getPcdCoded(indexI).getName().compareTo(v.getPcdCoded(indexJ).getName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) {\r
+                        PcdCodedIdentification temp = v.getPcdCoded(indexI);\r
+                        v.setPcdCoded(v.getPcdCoded(indexJ), indexI);\r
+                        v.setPcdCoded(temp, indexJ);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     Sort all pcd coded entries\r
+     \r
+     @param v\r
+     @param mode\r
+     \r
+     **/\r
+    public static void sortLibraryClass(LibraryClassVector v, int mode) {\r
+        if (v != null) {\r
+            //\r
+            // sort by name\r
+            //\r
+            for (int indexI = 0; indexI < v.size(); indexI++) {\r
+                for (int indexJ = indexI + 1; indexJ < v.size(); indexJ++) {\r
+                    if ((v.getLibraryClass(indexJ).getLibraryClassName().compareTo(\r
+                                                                                   v.getLibraryClass(indexI)\r
+                                                                                    .getLibraryClassName()) < 0 && mode == DataType.SORT_TYPE_ASCENDING)\r
+                        || (v.getLibraryClass(indexI).getLibraryClassName().compareTo(\r
+                                                                                      v.getLibraryClass(indexJ)\r
+                                                                                       .getLibraryClassName()) < 0 && mode == DataType.SORT_TYPE_DESCENDING)) {\r
+                        LibraryClassIdentification temp = v.getLibraryClass(indexI);\r
+                        v.setLibraryClass(v.getLibraryClass(indexJ), indexI);\r
+                        v.setLibraryClass(temp, indexJ);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
     /**\r
      Sort all objects of a vector based on the object's "toString"\r
      \r