return new CompositeReader(readers);
} else {
return null;
}
} else {
ScriptResource resource = getResource(resourceId);
if (resource != null) {
List<Module> modules = new ArrayList<Module>(resource.getModules());
Collections.sort(modules, MODULE_COMPARATOR);
ArrayList<Reader> readers = new ArrayList<Reader>(modules.size() * 2);
StringBuilder buffer = new StringBuilder();
//
boolean isModule = FetchMode.ON_LOAD.equals(resource.getFetchMode());
if (resource.isNativeAmd()) {
/* nothing to do for an AMD module */
// buffer.append("/* native AMD module */\n");
} else if (isModule) {
Set<ResourceId> depResourceIds = resource.getDependencies();
int argCount = depResourceIds.size();
JSONArray deps = new JSONArray();
LinkedList<String> params = new LinkedList<String>();
List<String> argNames = new ArrayList<String>(argCount);
List<String> argValues = new ArrayList<String>(argCount);
for (ResourceId id : depResourceIds) {
ScriptResource dep = getResource(id);
if (dep != null) {
Set<DepInfo> depInfos = resource.getDepInfo(id);
for (DepInfo info : depInfos) {
String pluginRS = info.getPluginRS();
String alias = info.getAlias();
if (alias == null) {
alias = dep.getAlias();
}
deps.put(parsePluginRS(dep.getId().toString(), pluginRS));
params.add(encode(params, alias));
argNames.add(parsePluginRS(alias, pluginRS));
}
} else if (RESERVED_MODULE.contains(id.getName())) {
String reserved = id.getName();