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

lucee.runtime.Component Maven / Gradle / Ivy

There is a newer version: 6.2.0.164-RC
Show newest version
/**
 * Copyright (c) 2014, the Railo Company Ltd.
 * Copyright (c) 2015, Lucee Association Switzerland
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library.  If not, see .
 * 
 */
package lucee.runtime;

import java.util.Iterator;
import java.util.Set;

import lucee.commons.lang.types.RefBoolean;
import lucee.runtime.component.Member;
import lucee.runtime.component.Property;
import lucee.runtime.dump.DumpData;
import lucee.runtime.dump.DumpProperties;
import lucee.runtime.exp.PageException;
import lucee.runtime.type.Collection;
import lucee.runtime.type.Objects;
import lucee.runtime.type.Struct;
import lucee.runtime.type.UDF;
import lucee.runtime.type.UDFProperties;
import lucee.runtime.type.scope.Scope;

/**
 * interface for a Component
 */
public interface Component extends Struct, Objects, CIObject {

	/**
	 * Constant for Access Mode Remote
	 */
	public static final int ACCESS_REMOTE = 0;

	/**
	 * Constant for Access Mode Public
	 */
	public static final int ACCESS_PUBLIC = 1;

	/**
	 * Constant for Access Mode Package
	 */
	public static final int ACCESS_PACKAGE = 2;

	/**
	 * Constant for Access Mode Private
	 */
	public static final int ACCESS_PRIVATE = 3;

	public static final int MODIFIER_NONE = Member.MODIFIER_NONE;
	public static final int MODIFIER_FINAL = Member.MODIFIER_FINAL;
	public static final int MODIFIER_ABSTRACT = Member.MODIFIER_ABSTRACT;

	/**
	 * returns java class to the component interface (all UDFs), this class is generated dynamic when
	 * used
	 * 
	 * @param isNew is new
	 * @return Java Class
	 * @throws PageException Page Exception
	 * @deprecated use instead
	 *             getJavaAccessClass(PageContext pc,RefBoolean isNew,boolean writeLog, boolean takeTop, boolean create, boolean supressWSbeforeArg,boolean output)
	 */
	@Deprecated
	public Class getJavaAccessClass(RefBoolean isNew) throws PageException;

	/**
	 * returns java class to the component interface (all UDFs), this class is generated dynamic when
	 * used
	 * 
	 * @param pc page context
	 * @param isNew is new
	 * @param writeLog write log
	 * @param takeTop take top
	 * @param create create
	 * @param supressWSbeforeArg suppress whitesapce before argument
	 * @return Java Class
	 * @throws PageException Page Exception
	 * @deprecated use instead
	 *             getJavaAccessClass(PageContext pc,RefBoolean isNew,boolean writeLog, boolean takeTop, boolean create, boolean supressWSbeforeArg, boolean output, boolean returnValue)
	 */
	@Deprecated
	public Class getJavaAccessClass(PageContext pc, RefBoolean isNew, boolean writeLog, boolean takeTop, boolean create, boolean supressWSbeforeArg) throws PageException;

	public Class getJavaAccessClass(PageContext pc, RefBoolean isNew, boolean writeLog, boolean takeTop, boolean create, boolean supressWSbeforeArg, boolean output,
			boolean returnValue) throws PageException;

	/**
	 * @return Returns the display name.
	 */
	public abstract String getDisplayName();

	/**
	 * @return Returns the Extends.
	 */
	public abstract String getExtends();

	public abstract int getModifier();

	/**
	 * @return Returns the Hint.
	 */
	public abstract String getHint();

	/**
	 * @return Returns the Name.
	 */
	public abstract String getName();

	/**
	 * @return Returns the Name.
	 */
	public abstract String getCallName();

	/**
	 * @return Returns the Name.
	 */
	public abstract String getAbsName();

	/**
	 * @return Returns the output.
	 */
	public abstract boolean getOutput();

	/**
	 * check if Component is instance of this type
	 * 
	 * @param type type to compare as String
	 * @return is instance of this type
	 */
	public abstract boolean instanceOf(String type);

	/**
	 * check if value is a valid access modifier constant
	 * 
	 * @param access access
	 * @return is valid access
	 */
	public abstract boolean isValidAccess(int access);

	/**
	 * is a persistent component (orm)
	 * 
	 * @return is a persistent component
	 */
	public boolean isPersistent();

	/**
	 * has accessors set
	 * 
	 * @return are accessors enabled
	 */
	public boolean isAccessors();

	/**
	 * returns Meta Data to the Component
	 * 
	 * @param pc page context
	 * @return meta data to component
	 * @throws PageException Page Exception
	 */
	public Struct getMetaData(PageContext pc) throws PageException;

	public Object getMetaStructItem(Collection.Key name);

	/**
	 * call a method of the component with no named arguments
	 * 
	 * @param pc PageContext
	 * @param key name of the method
	 * @param args Arguments for the method
	 * @return return result of the method
	 * @throws PageException Page Exception
	 */
	public abstract Object call(PageContext pc, String key, Object[] args) throws PageException;

	/**
	 * call a method of the component with named arguments
	 * 
	 * @param pc PageContext
	 * @param key name of the method
	 * @param args Named Arguments for the method
	 * @return return result of the method
	 * @throws PageException Page Exception
	 */
	public abstract Object callWithNamedValues(PageContext pc, String key, Struct args) throws PageException;

	/**
	 * return all properties from component
	 * 
	 * @param onlyPeristent if true return only columns where attribute persistent is not set to false
	 * @return all component properties
	 * @deprecated use instead
	 *             getProperties(boolean onlyPeristent, boolean includeBaseProperties, boolean preferBaseProperties, boolean inheritedMappedSuperClassOnly)
	 */
	@Deprecated
	public Property[] getProperties(boolean onlyPeristent);

	/**
	 * return all properties from component
	 * 
	 * @param onlyPeristent if true return only columns where attribute persistent is not set to false
	 * @param includeBaseProperties include base properties
	 * @param preferBaseProperties prefer base properties
	 * @param inheritedMappedSuperClassOnly inherited Mapped Super Class Only
	 * @return all component properties
	 */
	public Property[] getProperties(boolean onlyPeristent, boolean includeBaseProperties, boolean preferBaseProperties, boolean inheritedMappedSuperClassOnly);

	/**
	 * set component property
	 * 
	 * @param property property
	 * @throws PageException Page Exception
	 */
	public void setProperty(Property property) throws PageException;

	public ComponentScope getComponentScope();

	public boolean contains(PageContext pc, Key key);

	public PageSource getPageSource();

	// public Member getMember(int access,Collection.Key key, boolean dataMember,boolean superAccess);

	public String getBaseAbsName();

	public boolean isBasePeristent();

	public boolean equalTo(String type);

	public String getWSDLFile();

	public void setEntity(boolean entity);

	public boolean isEntity();

	public Component getBaseComponent();

	/**
	 * register UDF
	 * 
	 * @param key key
	 * @param udf User Defined Function
	 * @throws PageException Page Exception
	 */
	public void registerUDF(Collection.Key key, UDF udf) throws PageException;

	public void registerUDF(Collection.Key key, UDFProperties props) throws PageException;

	// access
	Set keySet(int access);

	Object call(PageContext pc, int access, Collection.Key name, Object[] args) throws PageException;

	Object callWithNamedValues(PageContext pc, int access, Collection.Key name, Struct args) throws PageException;

	int size(int access);

	Collection.Key[] keys(int access);

	Iterator keyIterator(int access);

	Iterator keysAsStringIterator(int access);

	Iterator> entryIterator(int access);

	Iterator valueIterator(int access);

	Object get(int access, Collection.Key key) throws PageException;

	Object get(int access, Collection.Key key, Object defaultValue);

	DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp, int access);

	boolean contains(int access, Key name);

	Member getMember(int access, Collection.Key key, boolean dataMember, boolean superAccess);

	public Scope staticScope();

	public Interface[] getInterfaces();

	public String id();
}