Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.dev.resource.impl;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.dev.cfg.ResourceLoader;
import com.google.gwt.dev.cfg.ResourceLoaders;
import com.google.gwt.dev.resource.Resource;
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
import com.google.gwt.dev.util.msg.Message0;
import com.google.gwt.dev.util.msg.Message1String;
import com.google.gwt.thirdparty.guava.common.base.Joiner;
import com.google.gwt.thirdparty.guava.common.collect.HashMultimap;
import com.google.gwt.thirdparty.guava.common.collect.MapMaker;
import com.google.gwt.thirdparty.guava.common.collect.Maps;
import com.google.gwt.thirdparty.guava.common.collect.SetMultimap;
import com.google.gwt.thirdparty.guava.common.collect.Sets;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.AccessControlException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
* The normal implementation of {@code ResourceOracle}.
*/
public class ResourceOracleImpl extends AbstractResourceOracle {
private static class Messages {
static final Message1String EXAMINING_PATH_ROOT = new Message1String(TreeLogger.DEBUG,
"Searching for resources within $0");
static final Message1String IGNORING_SHADOWED_RESOURCE =
new Message1String(
TreeLogger.DEBUG,
"Resource '$0' is being shadowed by another resource higher in the classpath having the same name; this one will not be used");
static final Message0 REFRESHING_RESOURCES = new Message0(TreeLogger.TRACE,
"Refreshing resources");
}
/**
* Wrapper object around a resource to change its path when it is rerooted.
*/
private static class RerootedResource extends AbstractResource {
private final String path;
private final AbstractResource resource;
public RerootedResource(AbstractResource resource, PathPrefix pathPrefix) {
this.path = pathPrefix.getRerootedPath(resource.getPath());
this.resource = resource;
}
@Override
public ClassPathEntry getClassPathEntry() {
return resource.getClassPathEntry();
}
@Override
public long getLastModified() {
return resource.getLastModified();
}
@Override
public String getLocation() {
return resource.getLocation();
}
@Override
public String getPath() {
return path;
}
@Override
public String getPathPrefix() {
int fullPathLen = resource.getPath().length();
return resource.getPath().substring(0, fullPathLen - path.length());
}
@Override
public InputStream openContents() throws IOException {
return resource.openContents();
}
@Override
public boolean wasRerooted() {
return true;
}
}
private static class ResourceDescription implements Comparable {
public final PathPrefix pathPrefix;
public final AbstractResource resource;
public ResourceDescription(AbstractResource resource, PathPrefix pathPrefix) {
this.resource =
pathPrefix.shouldReroot() ? new RerootedResource(resource, pathPrefix) : resource;
this.pathPrefix = pathPrefix;
}
public boolean isPreferredOver(ResourceDescription that) {
return this.compareTo(that) > 0;
}
@Override
public int compareTo(ResourceDescription other) {
// Rerooted takes precedence over not rerooted.
if (this.resource.wasRerooted() != other.resource.wasRerooted()) {
return this.resource.wasRerooted() ? 1 : -1;
}
// Compare priorities of the path prefixes, high number == high priority.
return this.pathPrefix.getPriority() - other.pathPrefix.getPriority();
}
@Override
public boolean equals(Object o) {
if (!(o instanceof ResourceDescription)) {
return false;
}
ResourceDescription other = (ResourceDescription) o;
return this.pathPrefix.getPriority() == other.pathPrefix.getPriority()
&& this.resource.wasRerooted() == other.resource.wasRerooted();
}
@Override
public int hashCode() {
return (pathPrefix.getPriority() << 1) + (resource.wasRerooted() ? 1 : 0);
}
@Override
public String toString() {
return "{" + resource + "," + pathPrefix + "}";
}
}
private static final Map> classPathCache =
new MapMaker().weakKeys().makeMap();
/**
* A mapping from resource paths to the name of the library module that
* created the PathPrefix (usually because of a