/** * Returns the location URL. * @return the location URL */ @Override @JsxFunction public String toString() { if (window_ != null) { return getHref(); } return ""; }
/** * Returns the location URL. * @return the location URL */ @Override @JsxFunction public String toString() { if (window_ != null) { return getHref(); } return ""; }
/** * {@inheritDoc} */ @Override public Object getDefaultValue(final Class<?> hint) { if (getPrototype() != null && (hint == null || String.class.equals(hint))) { return getHref(); } return super.getDefaultValue(hint); }
/** * {@inheritDoc} */ @Override public Object getDefaultValue(final Class<?> hint) { if (getPrototype() != null && (hint == null || String.class.equals(hint))) { return getHref(); } return super.getDefaultValue(hint); }
private Map<String, Object> convertLocationToMap(Location location) { Map<String, Object> map = Maps.newHashMap(); map.put("href", location.getHref()); map.put("protocol", location.getProtocol()); map.put("host", location.getHost()); map.put("hostname", location.getHostname()); map.put("port", location.getPort()); map.put("pathname", location.getPathname()); map.put("search", location.getSearch()); map.put("hash", location.getHash()); map.put("href", location.getHref()); return map; }
/** * Sets the hash portion of the location URL (the portion following the '#'). * * @param hash the new hash portion of the location URL * @see <a href="http://msdn.microsoft.com/en-us/library/ms533775.aspx">MSDN Documentation</a> */ @JsxSetter public void setHash(final String hash) { // IMPORTANT: This method must not call setUrl(), because // we must not hit the server just to change the hash! setHash(getHref(), hash); }
/** * Sets the hash portion of the location URL (the portion following the '#'). * * @param hash the new hash portion of the location URL * @see <a href="http://msdn.microsoft.com/en-us/library/ms533775.aspx">MSDN Documentation</a> */ @JsxSetter public void setHash(final String hash) { // IMPORTANT: This method must not call setUrl(), because // we must not hit the server just to change the hash! setHash(getHref(), hash); }
/** * Sets the hash portion of the location URL (the portion following the '#'). * * @param oldURL the old URL * @param hash the new hash portion of the location URL */ public void setHash(final String oldURL, String hash) { // IMPORTANT: This method must not call setUrl(), because // we must not hit the server just to change the hash! if (hash != null && !hash.isEmpty() && hash.charAt(0) == '#') { hash = hash.substring(1); } final boolean hasChanged = hash != null && !hash.equals(hash_); hash_ = hash; final String newURL = getHref(); if (hasChanged) { final Window w = getWindow(); final Event event; if (getBrowserVersion().hasFeature(EVENT_TYPE_HASHCHANGEEVENT)) { event = new HashChangeEvent(w, Event.TYPE_HASH_CHANGE, oldURL, newURL); } else { event = new Event(w, Event.TYPE_HASH_CHANGE); event.initEvent(Event.TYPE_HASH_CHANGE, false, false); } w.executeEventLocally(event); } }
/** * Sets the hash portion of the location URL (the portion following the '#'). * * @param oldURL the old URL * @param hash the new hash portion of the location URL */ public void setHash(final String oldURL, String hash) { // IMPORTANT: This method must not call setUrl(), because // we must not hit the server just to change the hash! if (hash != null && !hash.isEmpty() && hash.charAt(0) == '#') { hash = hash.substring(1); } final boolean hasChanged = hash != null && !hash.equals(hash_); hash_ = hash; final String newURL = getHref(); if (hasChanged) { final Window w = getWindow(); final Event event; if (getBrowserVersion().hasFeature(EVENT_TYPE_HASHCHANGEEVENT)) { event = new HashChangeEvent(w, Event.TYPE_HASH_CHANGE, oldURL, newURL); } else { event = new Event(w, Event.TYPE_HASH_CHANGE); event.initEvent(Event.TYPE_HASH_CHANGE, false, false); } w.executeEventLocally(event); } }
/** * Returns the hash portion of the location URL (the portion following the '#'). * @return the hash portion of the location URL * @see <a href="http://msdn.microsoft.com/en-us/library/ms533775.aspx">MSDN Documentation</a> */ @JsxGetter public String getHash() { final boolean decodeHash = getBrowserVersion().hasFeature(JS_LOCATION_HASH_IS_DECODED); String hash = hash_; if (hash_ != null && (decodeHash || hash_.equals(getUrl().getRef()))) { hash = decodeHash(hash); } if (StringUtils.isEmpty(hash)) { if (getBrowserVersion().hasFeature(JS_LOCATION_HASH_RETURNS_HASH_FOR_EMPTY_DEFINED) && getHref().endsWith("#")) { return "#"; } } else if (getBrowserVersion().hasFeature(JS_LOCATION_HASH_HASH_IS_ENCODED)) { return "#" + UrlUtils.encodeHash(hash); } else { return "#" + hash; } return ""; }
/** * Returns the hash portion of the location URL (the portion following the '#'). * @return the hash portion of the location URL * @see <a href="http://msdn.microsoft.com/en-us/library/ms533775.aspx">MSDN Documentation</a> */ @JsxGetter public String getHash() { final boolean decodeHash = getBrowserVersion().hasFeature(JS_LOCATION_HASH_IS_DECODED); String hash = hash_; if (hash_ != null && (decodeHash || hash_.equals(getUrl().getRef()))) { hash = decodeHash(hash); } if (StringUtils.isEmpty(hash)) { if (getBrowserVersion().hasFeature(JS_LOCATION_HASH_RETURNS_HASH_FOR_EMPTY_DEFINED) && getHref().endsWith("#")) { return "#"; } } else if (getBrowserVersion().hasFeature(JS_LOCATION_HASH_HASH_IS_ENCODED)) { return "#" + UrlUtils.encodeHash(hash); } else { return "#" + hash; } return ""; }
/** * Returns the value of the {@code href} property. * @return the value of the {@code href} property */ @JsxGetter public String getHref() { final String href = getDomNodeOrDie().getAttributeDirect("href"); if (ATTRIBUTE_NOT_DEFINED == href) { if (getBrowserVersion().hasFeature(HTMLBASE_HREF_DEFAULT_EMPTY)) { return href; } return getWindow().getLocation().getHref(); } return href; }
/** * Returns the value of the {@code href} property. * @return the value of the {@code href} property */ @JsxGetter public String getHref() { final String href = getDomNodeOrDie().getAttributeDirect("href"); if (ATTRIBUTE_NOT_DEFINED == href) { if (getBrowserVersion().hasFeature(HTMLBASE_HREF_DEFAULT_EMPTY)) { return href; } return getWindow().getLocation().getHref(); } return href; }