1 22 23 package org.xquark.mediator.decomposer; 24 25 import java.util.*; 26 27 import org.xquark.xquery.metadata.MetaDataImpl; 28 import org.xquark.xquery.parser.Variable; 29 import org.xquark.xquery.parser.XQueryException; 30 import org.xquark.xquery.parser.XQueryExpression; 31 32 public class Utils { 33 private static final String RCSRevision = "$Revision: 1.3 $"; 37 private static final String RCSName = "$Name: $"; 38 39 43 47 56 57 65 static public void fillSources(XQueryExpression arg, MetaDataImpl metadata, boolean force) throws XQueryException { 66 67 if (arg.getSourceNames() != null) { 69 return; 70 } 71 73 MakeStepsListVisitor stepvisitor = new MakeStepsListVisitor(metadata, true); 74 arg.accept(stepvisitor); 75 76 if (force || arg.getSourceNames() == null || arg.getSourceNames().isEmpty()) { 77 78 Set set = stepvisitor.getStepsLists().getRegisteredVariables(); 80 if (set == null) { 81 arg.setSourceNames(null); 82 arg.setUrls(null); 83 return; 84 } 85 Set sources = null; 86 Set urls = null; 87 for (Iterator it = set.iterator(); it.hasNext();) { 88 Variable var = (Variable) it.next(); 89 if (var.getSourceNames() != null && !var.getSourceNames().isEmpty()) { 90 if (sources == null) 91 sources = new HashSet(var.getSourceNames()); 92 else 93 sources.addAll(var.getSourceNames()); 94 } 95 if (var.getUrls() != null && !var.getUrls().isEmpty()) { 96 if (urls == null) 97 urls = new HashSet(var.getUrls()); 98 else 99 urls.addAll(var.getUrls()); 100 } 101 } 102 arg.setSourceNames(sources); 103 arg.setUrls(urls); 104 105 } 128 130 } 133 134 137 public static String makeIndent(int indent) { 138 char[] buf = new char[indent]; 139 for (int i = 0; i < buf.length; i++) 140 buf[i] = '\t'; 141 return new String (buf); 142 } 143 } 144 | Popular Tags |