List of usage examples for java.net URL equals
public boolean equals(Object obj)
If the given object is not a URL then this method immediately returns false .
Two URL objects are equal if they have the same protocol, reference equivalent hosts, have the same port number on the host, and the same file and fragment of the file.
Two hosts are considered equivalent if both host names can be resolved into the same IP addresses; else if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null.
Since hosts comparison requires name resolution, this operation is a blocking operation.
From source file:net.solarnetwork.node.setup.obr.OBRPluginService.java
/** * Call when an {@link OBRRepository} is no longer available. * //from ww w .j a v a2 s . co m * @param repository * the repository */ public void onUnbind(OBRRepository repository) { if (repository == null || repository.getURL() == null || repositoryAdmin == null) { return; } for (Repository repo : repositoryAdmin.listRepositories()) { URL repoURL = repo.getURL(); if (repoURL != null && repoURL.equals(repository.getURL())) { repositoryAdmin.removeRepository(repoURL); repoStatusMap.remove(repoURL); return; } } }
From source file:org.squidy.designer.zoom.impl.SourceCodeShape.java
/** * @param sourceCodeURL// ww w . ja v a 2s .com * the sourceCodeURL to set */ public final void setSourceCodeURL(URL sourceCodeURL) { URL oldSourceCodeURL = this.sourceCodeURL; this.sourceCodeURL = sourceCodeURL; // Do re-initialize codePane if a new source code URL has been set and // only if // codePane has been initialized after zooming in. if (!oldSourceCodeURL.equals(sourceCodeURL)) { if (codePane != null) { try { FileInputStream fis = new FileInputStream(sourceCodeURL.getPath()); codePane.read(fis, null); } catch (FileNotFoundException e) { nodeShape.publishFailure(e); } catch (IOException e) { nodeShape.publishFailure(e); } // Reset calculations -> used in paint method. sourceName = null; className = null; } } }
From source file:org.java.plugin.standard.ShadingPathResolver.java
private URL deepCheck(final URL source, final String uid) throws Exception { String url = metaData.getProperty("source:" + uid, null); //$NON-NLS-1$ if (url == null) { if (log.isDebugEnabled()) { log.debug("URL not found in meta-data, UID=" + uid); //$NON-NLS-1$ }/*from w w w.j a v a 2 s . c om*/ remove(uid); return null; } if (log.isDebugEnabled()) { log.debug("URL found in meta-data, UID=" //$NON-NLS-1$ + uid + ", source=" + source //$NON-NLS-1$ + ", storedURL=" + url); //$NON-NLS-1$ } URL storedSource = ShadingUtil.buildURL(shadowFolderUrl, url); if (!storedSource.equals(source)) { if (log.isDebugEnabled()) { log.debug("inconsistent URL found in meta-data, UID=" //$NON-NLS-1$ + uid + ", source=" + source //$NON-NLS-1$ + ", storedSource=" + storedSource); //$NON-NLS-1$ } remove(uid); return null; } String modified = metaData.getProperty("modified:" + uid, null); //$NON-NLS-1$ if (modified == null) { if (log.isDebugEnabled()) { log.debug("modification info not found in meta-data, UID=" //$NON-NLS-1$ + uid); } remove(uid); return null; } if (!ShadingUtil.getLastModified(source).equals(dtf.parse(modified))) { if (log.isDebugEnabled()) { log.debug("source modification detected, UID=" + uid //$NON-NLS-1$ + ", source=" + source); //$NON-NLS-1$ } remove(uid); return null; } String fileStr = metaData.getProperty("file:" + uid, null); //$NON-NLS-1$ if (fileStr == null) { if (log.isDebugEnabled()) { log.debug("file info not found in meta-data, UID=" + uid); //$NON-NLS-1$ } remove(uid); return null; } File file = new File(shadowFolder, fileStr); if (!file.exists()) { if (log.isDebugEnabled()) { log.debug("shadow file not found, UID=" + uid //$NON-NLS-1$ + ", source=" + source //$NON-NLS-1$ + ", file=" + file); //$NON-NLS-1$ } remove(uid); return null; } File sourceFile = IoUtil.url2file(source); if ((sourceFile != null) && sourceFile.isDirectory()) { IoUtil.synchronizeFolders(sourceFile, file, fileFilter); if (log.isDebugEnabled()) { log.debug("folders synchronized, UID=" + uid //$NON-NLS-1$ + ", srcFile=" + sourceFile //$NON-NLS-1$ + ", destFile=" + file); //$NON-NLS-1$ } } else { if (log.isDebugEnabled()) { log.debug("source " + source + " (file is " + sourceFile //$NON-NLS-1$ //$NON-NLS-2$ + ") is not local folder, " //$NON-NLS-1$ + "skipping synchronization, UID=" + uid); //$NON-NLS-1$ } } return IoUtil.file2url(file); }
From source file:core.Inject.java
public void injectExpression() { bar = new commandline.ProgressBar(); int i = 0;/*from w w w . j av a 2s .c o m*/ String[] _InStyle_vectors = new String[_expression_payloads.length * 2]; int size = _InStyle_vectors.length; String[] head = { "color", "width", "-", "x", "xss" }; Debug.print( "INFO: Reflection context: style attribute - you should switch IE in compatibility mode in order to proceed..."); Debug.print("Press Y and Enter once switched or N and Enter to quit."); String input = Debug.readLine(); if (input != null && (input.equals("N") || input.equals("n"))) { Starter.getDriver().quit(); HaltHandler.quit_nok(); } // <div style="color: UNTRUSTED_DATA;"> for (String current : _expression_payloads) { _InStyle_vectors[i] = Starter.randomColor() + ";" + head[(int) (Math.random() * head.length)] + ":" + current + ";"; i++; } // <div style="background:url(UNTRUSTED_DATA);"> for (String current : _expression_payloads) { _InStyle_vectors[i] = "http://foo.com/boh);" + head[(int) (Math.random() * head.length)] + ":" + current + "/*"; i++; } i = 0; for (String current : _InStyle_vectors) { bar.update(i, size); i++; String current_url = Starter.getDriver().getCurrentUrl(); Starter.inject(current); URL tmp = null; try { tmp = new URL(Starter.getDriver().getCurrentUrl()); } catch (MalformedURLException e) { Debug.printError("ERROR: unable to select the current URL"); HaltHandler.quit_nok(); } if (tmp.getPath().endsWith("/0") && !tmp.equals(current_url)) { log(current); } } }
From source file:Main.java
/** * Creates a relative url by stripping the common parts of the the url. * * @param url the to be stripped url//from w w w .j a v a2 s .co m * @param baseURL the base url, to which the <code>url</code> is relative * to. * @return the relative url, or the url unchanged, if there is no relation * beween both URLs. */ public String createRelativeURL(final URL url, final URL baseURL) { if (url == null) { throw new NullPointerException("content url must not be null."); } if (baseURL == null) { throw new NullPointerException("baseURL must not be null."); } if (isFileStyleProtocol(url) && isSameService(url, baseURL)) { // If the URL contains a query, ignore that URL; do not // attemp to modify it... final List urlName = parseName(getPath(url)); final List baseName = parseName(getPath(baseURL)); final String query = getQuery(url); if (!isPath(baseURL)) { baseName.remove(baseName.size() - 1); } // if both urls are identical, then return the plain file name... if (url.equals(baseURL)) { return (String) urlName.get(urlName.size() - 1); } int commonIndex = startsWithUntil(urlName, baseName); if (commonIndex == 0) { return url.toExternalForm(); } if (commonIndex == urlName.size()) { // correct the base index if there is some weird mapping // detected, // fi. the file url is fully included in the base url: // // base: /file/test/funnybase // file: /file/test // // this could be a valid configuration whereever virtual // mappings are allowed. commonIndex -= 1; } final ArrayList retval = new ArrayList(); if (baseName.size() >= urlName.size()) { final int levels = baseName.size() - commonIndex; for (int i = 0; i < levels; i++) { retval.add(".."); } } retval.addAll(urlName.subList(commonIndex, urlName.size())); return formatName(retval, query); } return url.toExternalForm(); }
From source file:tr.com.serkanozal.jcommon.util.ClasspathUtil.java
private static Set<URL> findClasspathUrls() { Set<URL> urls = new HashSet<URL>(); try {/* w w w . j av a2 s . c om*/ String[] classpathProperties = System.getProperty("java.class.path").split(File.pathSeparator); for (String classpathProperty : classpathProperties) { urls.add(new File(classpathProperty).toURI().toURL()); } } catch (MalformedURLException e) { logger.error("Error occured while getting classpath from system property \"java.class.path\"", e); } String surefireProperty = System.getProperty("surefire.test.class.path"); if (StringUtils.isNotEmpty(surefireProperty)) { try { String[] surefireClasspathProperties = surefireProperty.split(File.pathSeparator); for (String surefireClasspathProperty : surefireClasspathProperties) { urls.add(new File(surefireClasspathProperty).toURI().toURL()); } } catch (MalformedURLException e) { logger.error( "Error occured while getting classpath from system property \"surefire.test.class.path\"", e); } } // Start with Current Thread's loader ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader(); ClassLoader loader = ctxLoader; while (loader != null) { urls.addAll(findClasspathsByLoader(loader)); loader = loader.getParent(); } // Also start with this classes's loader, in some environment this can // be different than the current thread's one ClassLoader appLoader = ClasspathUtil.class.getClassLoader(); loader = appLoader; while (loader != null) { urls.addAll(findClasspathsByLoader(loader)); loader = loader.getParent(); } ClassLoader sysLoader = ClassLoader.getSystemClassLoader(); loader = sysLoader; while (loader != null) { urls.addAll(findClasspathsByLoader(loader)); loader = loader.getParent(); } Map<URL, URL> replaceURLs = new HashMap<URL, URL>(); Set<URL> derivedUrls = new HashSet<URL>(); for (URL url : urls) { if (url.getProtocol().startsWith("vfs")) { try { URLConnection conn = url.openConnection(); Object virtualFile = conn.getContent(); if (virtualFile.getClass().getName().equals("org.jboss.vfs.VirtualFile")) { File file = (File) virtualFile.getClass().getMethod("getPhysicalFile").invoke(virtualFile); String fileName = file.getCanonicalPath(); String name = (String) virtualFile.getClass().getMethod("getName").invoke(virtualFile); name = name.trim().toLowerCase(); if ((name.endsWith("jar") || name.endsWith("zip") && fileName.endsWith("/contents"))) { fileName = fileName.replace("contents", name); } URL repURL = new URL("file:/" + fileName); replaceURLs.put(url, repURL); } } catch (Exception e) { // We don't expect to trapped here e.printStackTrace(); } } try { if (url.toExternalForm().endsWith("WEB-INF/classes")) { derivedUrls.add(new URL(url.toExternalForm().replace("WEB-INF/classes", "WEB-INF/lib"))); } else if (url.toExternalForm().endsWith("WEB-INF/classes/")) { derivedUrls.add(new URL(url.toExternalForm().replace("WEB-INF/classes/", "WEB-INF/lib/"))); } } catch (Exception e) { e.printStackTrace(); } } urls.removeAll(replaceURLs.keySet()); urls.addAll(replaceURLs.values()); urls.addAll(derivedUrls); replaceURLs.clear(); //Check contained urls for (URL url : urls) { for (URL rootUrl : urls) { if (url.equals(rootUrl)) { continue; } if (url.toExternalForm().startsWith(rootUrl.toExternalForm())) { if (replaceURLs.get(url) != null) { URL settledUrl = replaceURLs.get(url); if (settledUrl.toExternalForm().startsWith(rootUrl.toExternalForm())) { replaceURLs.put(url, rootUrl); } } else { replaceURLs.put(url, rootUrl); } } } } urls.removeAll(replaceURLs.keySet()); return urls; }
From source file:com.trk.aboutme.facebook.widget.GraphObjectAdapter.java
private void downloadProfilePicture(final String profileId, URL pictureURL, final ImageView imageView) { if (pictureURL == null) { return;/*from w w w. jav a 2 s. c o m*/ } // If we don't have an imageView, we are pre-fetching this image to store in-memory because we // think the user might scroll to its corresponding list row. If we do have an imageView, we // only want to queue a download if the view's tag isn't already set to the URL (which would mean // it's already got the correct picture). boolean prefetching = imageView == null; if (prefetching || !pictureURL.equals(imageView.getTag())) { if (!prefetching) { // Setting the tag to the profile ID indicates that we're currently downloading the // picture for this profile; we'll set it to the actual picture URL when complete. imageView.setTag(profileId); imageView.setImageResource(getDefaultPicture()); } ImageRequest.Builder builder = new ImageRequest.Builder(context.getApplicationContext(), pictureURL) .setCallerTag(this).setCallback(new ImageRequest.Callback() { @Override public void onCompleted(ImageResponse response) { processImageResponse(response, profileId, imageView); } }); ImageRequest newRequest = builder.build(); pendingRequests.put(profileId, newRequest); ImageDownloader.downloadAsync(newRequest); } }
From source file:org.apache.openejb.config.DeploymentLoader.java
/** * Modifies the map passed in with all the alt dd URLs found * * @param map Map/*from w ww . j ava 2s .c o m*/ * @param log boolean * @return the same map instance updated with alt dds */ public static Map<String, URL> altDDSources(final Map<String, URL> map, final boolean log) { if (ALTDD == null || ALTDD.length() <= 0) { return map; } final List<String> list = new ArrayList<String>(Arrays.asList(ALTDD.split(","))); Collections.reverse(list); final Map<String, URL> alts = new HashMap<String, URL>(); for (String prefix : list) { prefix = prefix.trim(); if (!prefix.matches(".*[.-]$")) { prefix += "."; } for (final Map.Entry<String, URL> entry : new HashMap<String, URL>(map).entrySet()) { String key = entry.getKey(); final URL value = entry.getValue(); if (key.startsWith(prefix)) { key = key.substring(prefix.length()); alts.put(key, value); } } } for (final Map.Entry<String, URL> alt : alts.entrySet()) { final String key = alt.getKey(); final URL value = alt.getValue(); // don't add and log if the same key/value is already in the map if (value.equals(map.get(key))) { continue; } if (log) { logger.info("AltDD " + key + " -> " + value.toExternalForm()); } map.put(key, value); } return map; }
From source file:org.apache.openjpa.meta.AbstractCFMetaDataFactory.java
/** * Parse persistent type names./*from w ww . j av a 2s . com*/ */ protected Set<String> parsePersistentTypeNames(ClassLoader loader) throws IOException { ClassArgParser cparser = newClassArgParser(); String[] clss; Set<String> names = new HashSet<String>(); if (files != null) { File file; for (Iterator itr = files.iterator(); itr.hasNext();) { file = (File) itr.next(); if ((AccessController.doPrivileged(J2DoPrivHelper.isDirectoryAction(file))).booleanValue()) { if (log.isTraceEnabled()) log.trace(_loc.get("scanning-directory", file)); scan(new FileMetaDataIterator(file, newMetaDataFilter()), cparser, names, true, file); } else if (file.getName().endsWith(".jar")) { if (log.isTraceEnabled()) log.trace(_loc.get("scanning-jar", file)); try { ZipFile zFile = AccessController.doPrivileged(J2DoPrivHelper.newZipFileAction(file)); scan(new ZipFileMetaDataIterator(zFile, newMetaDataFilter()), cparser, names, true, file); } catch (PrivilegedActionException pae) { throw (IOException) pae.getException(); } } else { if (log.isTraceEnabled()) log.trace(_loc.get("scanning-file", file)); clss = cparser.parseTypeNames(new FileMetaDataIterator(file)); List<String> newNames = Arrays.asList(clss); if (log.isTraceEnabled()) log.trace(_loc.get("scan-found-names", newNames, file)); names.addAll(newNames); File f = AccessController.doPrivileged(J2DoPrivHelper.getAbsoluteFileAction(file)); try { mapPersistentTypeNames(AccessController.doPrivileged(J2DoPrivHelper.toURLAction(f)), clss); } catch (PrivilegedActionException pae) { throw (FileNotFoundException) pae.getException(); } } } } URL url; if (urls != null) { for (Iterator itr = urls.iterator(); itr.hasNext();) { url = (URL) itr.next(); if ("file".equals(url.getProtocol())) { File file = AccessController .doPrivileged(J2DoPrivHelper.getAbsoluteFileAction(new File(url.getFile()))); if (files != null && files.contains(file)) { continue; } else if ((AccessController.doPrivileged(J2DoPrivHelper.isDirectoryAction(file))) .booleanValue()) { if (log.isTraceEnabled()) log.trace(_loc.get("scanning-directory", file)); scan(new FileMetaDataIterator(file, newMetaDataFilter()), cparser, names, true, file); continue; } } if ("vfs".equals(url.getProtocol())) { if (log.isTraceEnabled()) { log.trace(_loc.get("scanning-vfs-url", url)); } final URLConnection conn = url.openConnection(); final Object vfsContent = conn.getContent(); final URL finalUrl = url; File file = AccessController.doPrivileged(new PrivilegedAction<File>() { @SuppressWarnings({ "rawtypes", "unchecked" }) public File run() { try { Class virtualFileClass = Class.forName("org.jboss.vfs.VirtualFile"); Method getPhysicalFile = virtualFileClass.getDeclaredMethod("getPhysicalFile"); return (File) getPhysicalFile.invoke(vfsContent); } catch (Exception e) { log.error(_loc.get("while-scanning-vfs-url", finalUrl), e); } return null; } }); if (file != null) scan(new FileMetaDataIterator(file, newMetaDataFilter()), cparser, names, true, file); continue; } if ("jar".equals(url.getProtocol())) { if (url.getPath().endsWith("!/")) { if (log.isTraceEnabled()) log.trace(_loc.get("scanning-jar-url", url)); scan(new ZipFileMetaDataIterator(url, newMetaDataFilter()), cparser, names, true, url); } else { if (log.isTraceEnabled()) log.trace(_loc.get("scanning-jar-url", url)); scan(new JarFileURLMetaDataIterator(url, newMetaDataFilter()), cparser, names, true, url); } } else if (url.getPath().endsWith(".jar")) { if (log.isTraceEnabled()) log.trace(_loc.get("scanning-jar-at-url", url)); try { InputStream is = (InputStream) AccessController .doPrivileged(J2DoPrivHelper.openStreamAction(url)); scan(new ZipStreamMetaDataIterator(new ZipInputStream(is), newMetaDataFilter()), cparser, names, true, url); } catch (PrivilegedActionException pae) { throw (IOException) pae.getException(); } } else { // Open an InputStream from the URL and sniff for a zip header. If it is, then this is // a URL with a jar-formated InputStream, as per the JPA specification. Otherwise, fall back // to URLMetaDataIterator. BufferedInputStream is = null; try { is = new BufferedInputStream( (InputStream) AccessController.doPrivileged(J2DoPrivHelper.openStreamAction(url))); } catch (PrivilegedActionException pae) { throw (IOException) pae.getException(); } // Check for zip header magic 0x50 0x4b 0x03 0x04 is.mark(0); boolean zipHeaderMatch = is.read() == 0x50 && is.read() == 0x4b && is.read() == 0x03 && is.read() == 0x04; is.reset(); if (zipHeaderMatch) { // The URL provides a Jar-formatted InputStream, consume it with ZipStreamMetaDataIterator if (log.isTraceEnabled()) log.trace(_loc.get("scanning-jar-at-url", url)); scan(new ZipStreamMetaDataIterator(new ZipInputStream(is), newMetaDataFilter()), cparser, names, true, url); } else { // Fall back to URLMetaDataIterator if (log.isTraceEnabled()) log.trace(_loc.get("scanning-url", url)); clss = cparser.parseTypeNames(new URLMetaDataIterator(url)); List<String> newNames = Arrays.asList(clss); if (log.isTraceEnabled()) log.trace(_loc.get("scan-found-names", newNames, url)); names.addAll(newNames); mapPersistentTypeNames(url, clss); } } } } if (rsrcs != null) { String rsrc; MetaDataIterator mitr; for (Iterator itr = rsrcs.iterator(); itr.hasNext();) { rsrc = (String) itr.next(); if (rsrc.endsWith(".jar")) { url = AccessController.doPrivileged(J2DoPrivHelper.getResourceAction(loader, rsrc)); if (url != null) { if (log.isTraceEnabled()) log.trace(_loc.get("scanning-jar-stream-url", url)); try { InputStream is = (InputStream) AccessController .doPrivileged(J2DoPrivHelper.openStreamAction(url)); scan(new ZipStreamMetaDataIterator(new ZipInputStream(is), newMetaDataFilter()), cparser, names, true, url); } catch (PrivilegedActionException pae) { throw (IOException) pae.getException(); } } } else { if (log.isTraceEnabled()) log.trace(_loc.get("scanning-resource", rsrc)); mitr = new ResourceMetaDataIterator(rsrc, loader); OpenJPAConfiguration conf = repos.getConfiguration(); Map peMap = null; if (conf instanceof OpenJPAConfigurationImpl) peMap = ((OpenJPAConfigurationImpl) conf).getPersistenceEnvironment(); URL puUrl = peMap == null ? null : (URL) peMap.get(PERSISTENCE_UNIT_ROOT_URL); List<String> mappingFileNames = peMap == null ? null : (List<String>) peMap.get(MAPPING_FILE_NAMES); List<URL> jars = peMap == null ? null : (List<URL>) peMap.get(JAR_FILE_URLS); String puUrlString = puUrl == null ? null : puUrl.toString(); if (log.isTraceEnabled()) log.trace(_loc.get("pu-root-url", puUrlString)); URL puORMUrl = null; try { if (puUrlString != null) { String puORMUrlStr = puUrlString + (puUrlString.endsWith("/") ? "" : "/") + rsrc; puORMUrl = AccessController.doPrivileged(J2DoPrivHelper.createURL(puORMUrlStr)); } } catch (PrivilegedActionException e) { throw new IOException("Error generating puORMUrlStr.", e.getCause()); } List<URL> urls = new ArrayList<URL>(3); while (mitr.hasNext()) { url = (URL) mitr.next(); String urlString = url.toString(); if (log.isTraceEnabled()) log.trace(_loc.get("resource-url", urlString)); if (peMap != null) { //OPENJPA-2102: decode the URL to remove such things a spaces (' ') encoded as '%20' if (puUrlString != null && decode(urlString).indexOf(decode(puUrlString)) != -1) { urls.add(url); } else if (puORMUrl != null && puORMUrl.equals(url)) { // Check URL equality to support encapsulating URL protocols urls.add(url); } if (mappingFileNames != null && mappingFileNames.size() != 0) { for (String mappingFileName : mappingFileNames) { if (log.isTraceEnabled()) log.trace(_loc.get("mapping-file-name", mappingFileName)); if (urlString.indexOf(mappingFileName) != -1) urls.add(url); } } if (jars != null && jars.size() != 0) { for (URL jarUrl : jars) { if (log.isTraceEnabled()) log.trace(_loc.get("jar-file-url", jarUrl)); if (urlString.indexOf(jarUrl.toString()) != -1) urls.add(url); } } } else { urls.add(url); } } mitr.close(); for (Object obj : urls) { url = (URL) obj; clss = cparser.parseTypeNames(new URLMetaDataIterator(url)); List<String> newNames = Arrays.asList(clss); if (log.isTraceEnabled()) log.trace(_loc.get("scan-found-names", newNames, rsrc)); names.addAll(newNames); mapPersistentTypeNames(url, clss); } } } } if (cpath != null) { String[] dirs = (String[]) cpath.toArray(new String[cpath.size()]); scan(new ClasspathMetaDataIterator(dirs, newMetaDataFilter()), cparser, names, true, dirs); } if (types != null) names.addAll(types); if (log.isTraceEnabled()) log.trace(_loc.get("parse-found-names", names)); return names; }
From source file:org.fit.cssbox.scriptbox.dom.Html5DocumentImpl.java
/** * Constructs new instance of the HTML Document according to Html5 specification. * //from w w w . j ava 2 s. com * @param browsingContext Associated browsing context to which belongs this instance of the Document. * @param address Address of the Document. * @param sandboxingFlagSet Sandboxing flag set associated with the document. * @param referrer Referrer address. * @param createWindow Window of which instance is re-used for this Document. * @param contentType Content-Type of which is this Document. * @param parser Associated parser, which will parse, or parsed, or is parsing this Document. * * @see <a href="http://www.w3.org/html/wg/drafts/html/master/dom.html#document">HTML5 document</a> * @see <a href="http://www.w3.org/html/wg/drafts/html/master/dom.html#the-document%27s-address">The document's address</a> * @see <a href="http://www.w3.org/html/wg/drafts/html/master/dom.html#the-document%27s-referrer">The document's referrer</a> * @see <a href="http://www.w3.org/html/wg/drafts/html/master/browsers.html#sandboxing-flag-set">A sandboxing flag set </a> * @see <a href="http://www.w3.org/html/wg/drafts/html/master/syntax.html#html-parser">HTML parser</a> * @see <a href="http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#concept-document-content-type">Content type</a> */ protected Html5DocumentImpl(BrowsingContext browsingContext, URL address, Set<SandboxingFlag> sandboxingFlagSet, String referrer, boolean createWindow, String contentType, Html5DocumentParser parser) { listeners = new HashSet<Html5DocumentEventListener>(); _salvageableFlag = true; _firedUnloadFlag = false; _pageShowingFlag = false; _ignoreDestructiveWritesCounter = 0; _browsingContext = browsingContext; _address = address; _referrer = referrer; _contentType = contentType; _documentReadiness = (parser == null) ? DocumentReadyState.COMPLETE : DocumentReadyState.LOADING; _activeSandboxingFlagSet = new HashSet<SandboxingFlag>(); _parser = parser; if (sandboxingFlagSet != null) { _activeSandboxingFlagSet.addAll(sandboxingFlagSet); } DocumentOrigin documentOrigin = null; DocumentOrigin effectiveScriptOrigin = null; if (_activeSandboxingFlagSet.contains(SandboxingFlag.ORIGIN_BROWSING_CONTEXT_FLAG)) { documentOrigin = DocumentOrigin.createUnique(this); effectiveScriptOrigin = DocumentOrigin.create(this, documentOrigin); } else if (address != null && (SERVER_BASED_SCHEMES.contains(address.getProtocol()) || address.getProtocol().equals(JAVASCRIPT_SCHEME_NAME))) { UrlOrigin addressOrigin = new UrlOrigin(address); documentOrigin = DocumentOrigin.create(this, addressOrigin); effectiveScriptOrigin = DocumentOrigin.create(this, documentOrigin); } else if (address != null && address.getProtocol().equals(DATA_SCHEME_NAME)) { // TODO: If a Document was generated from a data: URL found in another Document or in a script } else if (address != null && address.equals(DEFAULT_URL)) { Html5DocumentImpl creatorDocument = browsingContext.getCreatorDocument(); if (creatorDocument != null) { OriginContainer<?> originContainer = creatorDocument.getOriginContainer(); documentOrigin = DocumentOrigin.create(this, originContainer.getOrigin()); effectiveScriptOrigin = DocumentOrigin.create(this, originContainer.getEffectiveScriptOrigin()); } else { documentOrigin = DocumentOrigin.createUnique(this); effectiveScriptOrigin = DocumentOrigin.create(this, documentOrigin); } } /* * TODO: * else if a Document is an iframe srcdoc document * else if a Document was obtained in some other manner */ _originContainer = new OriginContainer<DocumentOrigin>(documentOrigin, effectiveScriptOrigin); if (_browsingContext != null) { if (createWindow) { _window = new Window(this); } _history = new History(this); _location = new Location(this); } addEventListener(MutationEventImpl.DOM_NODE_INSERTED, documentEventListener); addEventListener(MutationEventImpl.DOM_ATTR_MODIFIED, documentEventListener); }