All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.asg.generator.meta.MetaLink Maven / Gradle / Ivy

package net.anotheria.asg.generator.meta;

import java.util.List;

/**
 * Representation of an internal link to another document.
 *
 * @author another
 * @version $Id: $Id
 */
public class MetaLink extends MetaProperty{
	
	/**
	 * Type of the link. Currently the only supported link type is single.
	 */
	private String linkType;
	/**
	 * Link target as relative or absolute document name.
	 */
	private String linkTarget;
	
	/**
	 * Properties of target document are used to decorate link in additional to ID
	 */
	private List linkDecoration;
	
	/**
	 * 

Constructor for MetaLink.

* * @param name a {@link java.lang.String} object. */ public MetaLink(String name){ super(name, MetaProperty.Type.STRING); } /** *

Getter for the field linkTarget.

* * @return a {@link java.lang.String} object. */ public String getLinkTarget() { return linkTarget; } /** *

Getter for the field linkType.

* * @return a {@link java.lang.String} object. */ public String getLinkType() { return linkType; } /** *

Setter for the field linkTarget.

* * @param string a {@link java.lang.String} object. */ public void setLinkTarget(String string) { linkTarget = string; } /** *

Setter for the field linkType.

* * @param string a {@link java.lang.String} object. */ public void setLinkType(String string) { linkType = string; } /* (non-Javadoc) * @see net.anotheria.anodoc.generator.meta.MetaProperty#toNameConstant() */ /** {@inheritDoc} */ @Override public String toNameConstant() { return "LINK_"+super.toNameConstant(); } /** {@inheritDoc} */ @Override public boolean isLinked(){ return true; } /** *

getTargetModuleName.

* * @return a {@link java.lang.String} object. */ public String getTargetModuleName(){ int index = getLinkTarget().indexOf('.'); return index == -1 ? null : getLinkTarget().substring(0, index); } /** *

getTargetDocumentName.

* * @return a {@link java.lang.String} object. */ public String getTargetDocumentName(){ return getLinkTarget().substring(getLinkTarget().indexOf('.')+1); } /** *

doesTargetMatch.

* * @param document a {@link net.anotheria.asg.generator.meta.MetaDocument} object. * @return a boolean. */ public boolean doesTargetMatch(MetaDocument document){ return doesTargetMath(document.getParentModule(), document); } /** *

doesTargetMath.

* * @param module a {@link net.anotheria.asg.generator.meta.MetaModule} object. * @param document a {@link net.anotheria.asg.generator.meta.MetaDocument} object. * @return a boolean. */ public boolean doesTargetMath(MetaModule module, MetaDocument document){ return linkTarget != null && linkTarget.equals(module.getName()+"."+document.getName()); } /** *

isRelative.

* * @return a boolean. */ public boolean isRelative(){ return getLinkTarget().indexOf('.') == -1; } /** *

Getter for the field linkDecoration.

* * @return a {@link java.util.List} object. */ public List getLinkDecoration() { return linkDecoration; } /** *

Setter for the field linkDecoration.

* * @param linkDecoration a {@link java.util.List} object. */ public void setLinkDecoration(List linkDecoration) { this.linkDecoration = linkDecoration; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy