added class fields to outline
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / util / PHPFileUtil.java
index 1f8c8fe..dd4a36f 100644 (file)
@@ -19,6 +19,10 @@ public class PHPFileUtil {
   public final static char[] SUFFIX_PHP4 = ".PHP4".toCharArray(); //$NON-NLS-1$
   public final static char[] SUFFIX_inc = ".inc".toCharArray(); //$NON-NLS-1$
   public final static char[] SUFFIX_INC = ".INC".toCharArray(); //$NON-NLS-1$
+  public final static char[] SUFFIX_html = ".html".toCharArray(); //$NON-NLS-1$
+  public final static char[] SUFFIX_HTML = ".HTML".toCharArray(); //$NON-NLS-1$
+  public final static char[] SUFFIX_tpl = ".tpl".toCharArray(); //$NON-NLS-1$
+  public final static char[] SUFFIX_TPL = ".TPL".toCharArray(); //$NON-NLS-1$
 
   public  static boolean isPHPFile(IFile file) {
     String extension = file.getFileExtension();
@@ -113,4 +117,49 @@ public class PHPFileUtil {
     }
     return true;
   }
+  
+  /**
+   * Returns true iff str.toLowerCase().endsWith(".html")
+   * implementation is not creating extra strings.
+   */
+  public final static boolean isHTML_FileName(String name) {
+    int nameLength = name == null ? 0 : name.length();
+    int suffixLength = SUFFIX_HTML.length;
+    if (nameLength < suffixLength)
+      return false;
+
+    for (int i = 0, offset = nameLength - suffixLength; i < suffixLength; i++) {
+      char c = name.charAt(offset + i);
+      if (c != SUFFIX_html[i] && c != SUFFIX_HTML[i])
+        return false;
+    }
+    return true;
+  }
+  /**
+   * Returns true iff str.toLowerCase().endsWith(".tpl")
+   * implementation is not creating extra strings.
+   */
+  public final static boolean isTPL_FileName(String name) {
+    int nameLength = name == null ? 0 : name.length();
+    int suffixLength = SUFFIX_TPL.length;
+    if (nameLength < suffixLength)
+      return false;
+
+    for (int i = 0, offset = nameLength - suffixLength; i < suffixLength; i++) {
+      char c = name.charAt(offset + i);
+      if (c != SUFFIX_tpl[i] && c != SUFFIX_TPL[i])
+        return false;
+    }
+    return true;
+  }
+  
+  /**
+        * Returns true iff str.toLowerCase().endsWith(".java")
+        * implementation is not creating extra strings.
+        */
+       public final static boolean isValidPHPUnitName(String name) {
+               return PHPFileUtil.isPHPFileName(name) ||
+                      PHPFileUtil.isHTML_FileName(name) ||
+                          PHPFileUtil.isTPL_FileName(name);
+       }
 }