public List<ResourceName> queryMDS(PackageName packageName) { MDSInstance mdsInstance; List<ResourceName> resources = new ArrayList<ResourceName>(); try { mdsInstance = storeInitializer.getMDSInstance(); packageName = (packageName == null) ? PackageName.createPackageName("/") : packageName; NameCondition condition = ConditionFactory.createNameCondition(packageName.getAbsoluteName(), "%"); ResourceQuery query = QueryFactory.createResourceQuery(mdsInstance, condition); Iterator<QueryResult> contents = query.execute(); if (contents == null) { return resources; } while (contents.hasNext()) { QueryResult result = contents.next(); if (result.getResultType() == QueryResult.ResultType.PACKAGE_RESULT) { PackageResult pack = (PackageResult) result; resources.add(pack.getPackageName()); } else { DocumentResult doc = (DocumentResult) result; resources.add(doc.getDocumentName()); } } return resources; } catch (MDSAccessException e) { throw new IllegalArgumentException("Could not connect to MDS, check login data", e); } catch (InvalidReferenceException e) { throw new IllegalArgumentException("Could not find/read " + packageName, e); } catch (InvalidReferenceTypeException e) { throw new IllegalArgumentException("No correct type!", e); } }
/** * lookup a PackageName object based on it's name, If one does not exist, create a new one and * return it. * * @param pn the package name * @return a PackageName object that has a matching name */ public static synchronized PackageName lookupOrCreatePackageByName(String pn) { PackageName returned = lookupPackageName(pn); if (returned == null) { PackageName newName = new PackageName(); newName.setName(pn); singleton.saveObject(newName); return newName; } return returned; }
public static QualifiedName of(char[][] compoundTypeName) { switch (compoundTypeName.length) { case 0: return new QualifiedName(PackageName.nullValue(), new String(compoundTypeName[0])); default: int packageLength = compoundTypeName.length - 1; char[][] packageName = new char[compoundTypeName.length - 1][]; System.arraycopy(compoundTypeName, 0, packageName, 0, packageLength); return PackageName.of(packageName).toQualifiedName(compoundTypeName[packageLength]); } }
private static String[] compileModuleName(PackageName packname, ModuleName modname) { return Name.compileElements(packname.getElements(), modname.getLastElement()); }
NameEnvironmentAnswer findType() { return packageName.findType(simpleName); }
public QualifiedName(PackageName packageName, String simpleName) { this.packageName = packageName; this.simpleName = simpleName; name = packageName.name() + "." + simpleName; }