@Override public PageReference replaceParent(EntityReference oldParent, EntityReference newParent) { if (newParent == oldParent) { return this; } return new PageReference(this, oldParent, newParent); }
@Override public PageReference resolve(String pageReferenceRepresentation, Object... parameters) { return new PageReference( this.entityReferenceResolver.resolve(pageReferenceRepresentation, EntityType.PAGE, parameters)); } }
@Override public PageReference resolve(EntityReference pageReferenceRepresentation, Object... parameters) { if (pageReferenceRepresentation instanceof PageReference) { return (PageReference) pageReferenceRepresentation; } return new PageReference( this.entityReferenceResolver.resolve(pageReferenceRepresentation, EntityType.PAGE, parameters)); } }
@Override public PageReference resolve(String documentReferenceRepresentation, Object... parameters) { return new PageReference( this.entityReferenceResolver.resolve(documentReferenceRepresentation, EntityType.PAGE, parameters)); } }
@Override public PageReference resolve(EntityReference documentReferenceRepresentation, Object... parameters) { return new PageReference( this.entityReferenceResolver.resolve(documentReferenceRepresentation, EntityType.PAGE, parameters)); } }
/** * Create a page reference based on a page name and a parent page reference. * * @param wikiName the name of the wiki * @param pageNames the pages names */ public PageReference(String wikiName, List<String> pageNames) { this(pageNames.get(pageNames.size() - 1), pageNames.size() > 1 ? new PageReference(wikiName, pageNames.subList(0, pageNames.size() - 1)) : new WikiReference(wikiName)); }
@Override public PageReference replaceParent(EntityReference newParent) { if (newParent == getParent()) { return this; } return new PageReference(this, newParent); }
/** * Create a page reference based on a page name and a parent page reference. * * @param wikiName the name of the wiki * @param pageNames the pages names * @param locale the {@link Locale} of the entity. */ public PageReference(String wikiName, List<String> pageNames, Locale locale) { this( pageNames.get(pageNames.size() - 1), pageNames.size() > 1 ? new PageReference(wikiName, pageNames.subList(0, pageNames.size() - 1)) : new WikiReference(wikiName), locale); }
@Override public PageReference get() { if (this.cachedReference == null) { EntityReference reference = this.provider.getDefaultReference(EntityType.PAGE); // Add wiki reference = reference.appendParent(this.wikiReferenceProvider.get()); this.cachedReference = this.factory.getReference(new PageReference(reference)); } return this.cachedReference; } }
/** * @param stringRepresentation the document reference specified as a String (using the "wiki:space/page" format and * with special characters escaped where required) * @param hint the hint of the Resolver to use in case any part of the reference is missing (no wiki specified, no * space or no page) * @param parameters extra parameters to pass to the resolver; you can use these parameters to resolve a document * reference relative to another entity reference * @return the typed Document Reference object or null if no Resolver with the passed hint could be found */ public PageReference resolvePage(String stringRepresentation, String hint, Object... parameters) { try { EntityReferenceResolver<String> resolver = this.componentManager.getInstance(EntityReferenceResolver.TYPE_STRING, hint); return new PageReference(resolver.resolve(stringRepresentation, EntityType.PAGE, parameters)); } catch (ComponentLookupException e) { return null; } }
/** * {@inheritDoc} Overridden in order to verify the validity of the passed parent. * * @exception IllegalArgumentException if the passed parent is not a valid attachment reference parent (ie an * attachment reference) */ @Override protected void setParent(EntityReference parent) { if (parent instanceof PageReference) { super.setParent(parent); return; } if (parent == null || parent.getType() != EntityType.PAGE) { throw new IllegalArgumentException("Invalid parent reference [" + parent + "] in an attachment reference"); } super.setParent(new PageReference(parent)); }
/** * {@inheritDoc} * <p> * Overridden to ensure that the parent of a property is always an object. * </p> * * @see org.xwiki.model.reference.EntityReference#setParent(org.xwiki.model.reference.EntityReference) */ @Override protected void setParent(EntityReference parent) { if (parent instanceof PageReference) { super.setParent(parent); return; } if (parent == null || parent.getType() != EntityType.PAGE) { throw new IllegalArgumentException( "Invalid parent reference [" + parent + "] in a class property reference"); } super.setParent(new PageReference(parent)); }
/** * {@inheritDoc} * <p> * Overridden to ensure that the parent of an object is always a page. * </p> * * @see org.xwiki.model.reference.EntityReference#setParent(org.xwiki.model.reference.EntityReference) */ @Override protected void setParent(EntityReference parent) { if (parent instanceof PageReference) { super.setParent(parent); return; } if (parent == null || parent.getType() != EntityType.PAGE) { throw new IllegalArgumentException("Invalid parent reference [" + parent + "] in an object reference"); } super.setParent(new PageReference(parent)); }
return new PageReference(reolvedReference, locale);
/** * {@inheritDoc} * <p> * Overridden in order to verify the validity of the passed parent. * </p> * * @see org.xwiki.model.reference.EntityReference#setParent(EntityReference) * @exception IllegalArgumentException if the passed parent is not a valid page reference parent (ie either a page * reference or a wiki reference) */ @Override protected void setParent(EntityReference parent) { if (parent instanceof PageReference || parent instanceof WikiReference) { super.setParent(parent); return; } if (parent == null || (parent.getType() != EntityType.PAGE && parent.getType() != EntityType.WIKI)) { throw new IllegalArgumentException("Invalid parent reference [" + parent + "] in a page reference"); } if (parent.getType() == EntityType.PAGE) { super.setParent(new PageReference(parent)); } else { super.setParent(new WikiReference(parent)); } }