summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaeyoung Son <taeyoung2.son@samsung.com>2014-08-18 17:14:54 +0900
committerTaeyoung Son <taeyoung2.son@samsung.com>2014-08-18 18:00:05 +0900
commit25b50b43e2c0566ab6523394690aa934668ae994 (patch)
tree052f51b4ff9a519b91f69f8575aa70eaf4f18aec
parentb18a85553193f32ddb708f7687ecfa94d22acd29 (diff)
downloadcommon-eplugin-25b50b43e2c0566ab6523394690aa934668ae994.tar.gz
common-eplugin-25b50b43e2c0566ab6523394690aa934668ae994.tar.bz2
common-eplugin-25b50b43e2c0566ab6523394690aa934668ae994.zip
UTIL: Added contains method
Added non eclipse dependency method Change-Id: I521052c29a263beb616570425b2c65a0c36bda2c Signed-off-by: Taeyoung Son <taeyoung2.son@samsung.com>
-rw-r--r--org.tizen.common/src/org/tizen/common/ui/page/properties/PackageConfigUtil.java69
1 files changed, 39 insertions, 30 deletions
diff --git a/org.tizen.common/src/org/tizen/common/ui/page/properties/PackageConfigUtil.java b/org.tizen.common/src/org/tizen/common/ui/page/properties/PackageConfigUtil.java
index 06107443e..f1cc7b488 100644
--- a/org.tizen.common/src/org/tizen/common/ui/page/properties/PackageConfigUtil.java
+++ b/org.tizen.common/src/org/tizen/common/ui/page/properties/PackageConfigUtil.java
@@ -28,11 +28,13 @@ package org.tizen.common.ui.page.properties;
import java.util.List;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.tizen.common.core.application.PackageResourceInfo;
import org.tizen.common.core.application.TizenPackageInfoStore;
+import org.tizen.common.util.FilenameUtil;
/**
* This class is utilities for {@link PackageConfiguration}.
@@ -95,18 +97,14 @@ public class PackageConfigUtil {
if ( parentSegments.length > childSegments.length ) {
return false;
- }
- else if ( parentSegments.length == childSegments.length ) {
+ } else if ( parentSegments.length == childSegments.length ) {
if ( !child.isSupportedType(parent.getType()) ) {
return false;
}
- }
- else {
- if ( parent.getType() != IResource.FOLDER ) {
+ } else if ( parent.getType() != IResource.FOLDER ) {
return false;
- }
}
-
+
for ( int i = 0 ; i < childSegments.length ; i++ ) {
if ( i >= parentSegments.length ) {
break;
@@ -116,7 +114,7 @@ public class PackageConfigUtil {
return false;
}
}
-
+
return true;
}
@@ -124,33 +122,44 @@ public class PackageConfigUtil {
* Checks whether the given {@code child} contains the given {@code parent}.
*/
public static boolean contains(PackageResourceInfo parent, IResource child) {
- String[] childSegments = child.getFullPath().segments();
- String[] parentSegments = new Path(child.getProject().getName() + "/" + parent.getName()).segments();
-
- if ( parentSegments.length > childSegments.length ) {
- return false;
- }
- else if ( parentSegments.length == childSegments.length ) {
- if ( !parent.isSupportedType(child.getType()) ) {
+ return contains(parent, child.getFullPath().toString(), child.getType(), child.getProject());
+ }
+
+ /**
+ * Checks whether the given {@code child} contains the given {@code parent}.
+ */
+ public static boolean contains(PackageResourceInfo parent, String childResourcePath, int childResourceType, IProject project) {
+ switch(parent.getElementType()) {
+ case PackageResourceInfo.REGEX:
+ if (childResourcePath.matches(parent.getName())) {
+ return true;
+ } else {
return false;
}
- }
- else {
- if ( !parent.isSupportedType(IResource.FOLDER) ) {
+ default:
+ String[] childSegments = FilenameUtil.getCanonicalFragments(childResourcePath);
+ String[] parentSegments = new Path(project.getName() + "/" + parent.getName()).segments();
+
+ if ( parentSegments.length > childSegments.length ) {
return false;
- }
- }
-
- for ( int i = 0 ; i < childSegments.length ; i++ ) {
- if ( i >= parentSegments.length ) {
- break;
- }
-
- if ( !parentSegments[i].equals(childSegments[i]) ) {
+ } else if ( parentSegments.length == childSegments.length ) {
+ if ( !parent.isSupportedType(childResourceType) ) {
+ return false;
+ }
+ } else if ( !parent.isSupportedType(IResource.FOLDER) ) {
return false;
}
+
+ for ( int i = 0 ; i < childSegments.length ; i++ ) {
+ if ( i >= parentSegments.length ) {
+ break;
+ }
+
+ if ( !parentSegments[i].equals(childSegments[i]) ) {
+ return false;
+ }
+ }
+ return true;
}
-
- return true;
}
}