001 package railo.runtime.rest.path; 002 003 import java.util.Iterator; 004 005 import railo.runtime.op.Caster; 006 import railo.runtime.type.Array; 007 import railo.runtime.type.Struct; 008 import railo.runtime.type.util.ListUtil; 009 010 public abstract class Path { 011 /** 012 * check if given path part match this path Path part defintion 013 * @param variables fill all key value pairs extracte from path to this Map 014 * @param path path to check 015 * @return true if the given path match, false otherwise 016 */ 017 public abstract boolean match(Struct variables,String path); 018 019 public static Path[] init(String path) { 020 Array arr = ListUtil.listToArrayRemoveEmpty(path,'/'); 021 Path[] rtn=new Path[arr.size()]; 022 Iterator it = arr.valueIterator(); 023 int index=-1; 024 String str; 025 while(it.hasNext()){ 026 index++; 027 str=Caster.toString(it.next(),null); 028 //print.e("str:"+str); 029 if(str.indexOf('{')!=-1) rtn[index]=ExpressionPath.getInstance(str); 030 else rtn[index]=new LiteralPath(str); 031 } 032 return rtn; 033 } 034 }