当前位置: 首页>>代码示例>>Java>>正文


Java Component类代码示例

本文整理汇总了Java中lucee.runtime.Component的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Component类属于lucee.runtime包,在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toTypeName

import lucee.runtime.Component; //导入依赖的package包/类
/**
   * return the type name of a object (string, boolean, int aso.), type is not same like class name
   * @param o Object to get type from 
   * @return type of the object
  */
  public static String toTypeName(Object o) {
      if(o == null) return "null";
      else if(o instanceof String) return "string";
      else if(o instanceof Boolean) return "boolean";
      else if(o instanceof Number) return "int";
      else if(o instanceof Array) return "array";
      else if(o instanceof Component) return "component";
      else if(o instanceof Struct) return "struct";
      else if(o instanceof Query) return "query";
      else if(o instanceof DateTime) return "datetime";
      else if(o instanceof byte[]) return "binary";
      else if(o instanceof ObjectWrap) {
          return toTypeName(((ObjectWrap)o).getEmbededObject(null));
      }
      
      Class clazz=o.getClass();
      String className=clazz.getName();
if(className.startsWith("java.lang.")) {
	return className.substring(10);
}
return toClassName(clazz);
  }
 
开发者ID:lucee,项目名称:Lucee,代码行数:28,代码来源:Caster.java

示例2: call

import lucee.runtime.Component; //导入依赖的package包/类
public static Object call(ConfigWeb config,Component cfc, String methodName, Object... arguments) {
	try {
		
		PageContext pc = ThreadLocalPageContext.get();
		if(pc==null) {
			//PageSource ps = cfc.getPageSource();
			pc=ThreadUtil.createPageContext(
					config, 
					DevNullOutputStream.DEV_NULL_OUTPUT_STREAM, 
					"Lucee", "/", "", null, null, null, null);
			pc.addPageSource(cfc.getPageSource(), true);
			
		}
		
		return cfc.call(
				ThreadLocalPageContext.get(), 
				methodName, 
				arguments);
	} catch (PageException pe) {
		throw new PageRuntimeException(pe);
	}
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:23,代码来源:JavaProxy.java

示例3: toDateSimple

import lucee.runtime.Component; //导入依赖的package包/类
/**
 * converts a Object to a DateTime Object, returns null if invalid string
 * @param o Object to Convert
 * @param convertingType one of the following values:
 * - CONVERTING_TYPE_NONE: number are not converted at all
 * - CONVERTING_TYPE_YEAR: integers are handled as years
 * - CONVERTING_TYPE_OFFSET: numbers are handled as offset from 1899-12-30 00:00:00 UTC
 * @param timeZone
 * @return coverted Date Time Object
 * @throws PageException
 */
public static DateTime toDateSimple(Object o, short convertingType,boolean alsoMonthString, TimeZone timeZone) throws PageException {
	if(o instanceof DateTime) 		return (DateTime)o;
	else if(o instanceof Date) 		return new DateTimeImpl((Date)o);
	else if(o instanceof Castable) 	return ((Castable)o).castToDateTime();
	else if(o instanceof String) 	return toDateSimple(o.toString(),convertingType,alsoMonthString, timeZone);
	else if(o instanceof Number) 		return util.toDateTime(((Number)o).doubleValue());
	else if(o instanceof Calendar) 		return new DateTimeImpl((Calendar)o);
	else if(o instanceof ObjectWrap) return toDateSimple(((ObjectWrap)o).getEmbededObject(),convertingType,alsoMonthString,timeZone);
	else if(o instanceof Calendar){
		return new DateTimeImpl((Calendar)o);
	}
	
	if(o instanceof Component)
		throw new ExpressionException("can't cast component ["+((Component)o).getAbsName()+"] to date value");
	
	throw new ExpressionException("can't cast ["+Caster.toTypeName(o)+"] to date value");
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:29,代码来源:DateCaster.java

示例4: _isCastableTo

import lucee.runtime.Component; //导入依赖的package包/类
private static boolean _isCastableTo(PageContext pcMaybeNull,String type, Object o) {
      if(o instanceof Component) {
          Component comp=((Component)o);
          return comp.instanceOf(type);
      }
      if(o instanceof Pojo) {
      	pcMaybeNull = ThreadLocalPageContext.get(pcMaybeNull);
	return pcMaybeNull!=null && AxisCaster.toComponent(pcMaybeNull,((Pojo)o),type,null)!=null;
      }
      
      if(isArrayType(type) && isArray(o)){
      	String _strType=type.substring(0,type.length()-2);
      	short _type=CFTypes.toShort(_strType, false, (short)-1);
      	Array arr = Caster.toArray(o,null);
      	if(arr!=null){
      		Iterator<Object> it = arr.valueIterator();
      		while(it.hasNext()){
      			Object obj = it.next();
      			if(!isCastableTo(pcMaybeNull,_type,_strType, obj))
      				return false; 
      		}
      		return true;
      	}
      }
return false;
  }
 
开发者ID:lucee,项目名称:Lucee4,代码行数:27,代码来源:Decision.java

示例5: createComponentFromPath

import lucee.runtime.Component; //导入依赖的package包/类
@Override
public Component createComponentFromPath(PageContext pc, String path) throws PageException {	
	path=path.trim();
	String pathContracted=ContractPath.call(pc, path);
   	
	if(pathContracted.toLowerCase().endsWith(".cfc"))
		pathContracted=pathContracted.substring(0,pathContracted.length()-4);
	
   	pathContracted=pathContracted
		.replace(File.pathSeparatorChar, '.')
		.replace('/', '.')
		.replace('\\', '.');
   	
   	while(pathContracted.toLowerCase().startsWith("."))
		pathContracted=pathContracted.substring(1);
   	
	return createComponentFromName(pc, pathContracted);
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:19,代码来源:CreationImpl.java

示例6: toQuery

import lucee.runtime.Component; //导入依赖的package包/类
/**
 * cast a Object to a Query Object
 * @param o Object to cast
 * @return casted Query Object
 * @throws PageException
 */
public static Query toQuery(Object o) throws PageException {
	if(o instanceof Query) return (Query)o;
	if(o instanceof ObjectWrap) {
        return toQuery(((ObjectWrap)o).getEmbededObject());
    }
    if(o instanceof ResultSet) return new QueryImpl((ResultSet)o,"query", ThreadLocalPageContext.getTimeZone());
    if(o instanceof Component) {
    	Member member = ((Component)o).getMember(Component.ACCESS_PRIVATE, KeyConstants.__toQuery, false, false);
		if(member instanceof UDFPlus) {
			UDFPlus udf = (UDFPlus)member;
 		if(udf.getReturnType()==CFTypes.TYPE_QUERY && udf.getFunctionArguments().length==0) {
 			return Caster.toQuery(((Component)o).call(ThreadLocalPageContext.get(), KeyConstants.__toQuery, new Object[]{}));
 		}
		}
    }
    
    
    throw new CasterException(o,"query");
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:26,代码来源:Caster.java

示例7: createMappings

import lucee.runtime.Component; //导入依赖的package包/类
private static void createMappings(ORMConfiguration ormConf, String key, CFCInfo value,Set<String> done,StringBuilder mappings, SessionFactoryData data) {
	if(done.contains(key)) return;
	CFCInfo v;
	String ext = value.getCFC().getExtends();
	if(!Util.isEmpty(ext)){
		try {
			Component base = data.getEntityByCFCName(ext, false);
			ext=HibernateCaster.getEntityName(base);
		} catch (Throwable t) {
			lucee.commons.lang.ExceptionUtil.rethrowIfNecessary(t);
		}
		
		
		ext=HibernateUtil.id(CommonUtil.last(ext, '.').trim());
		if(!done.contains(ext)) {
			v = data.getCFC(ext,null);
			if(v!=null)createMappings(ormConf, ext, v, done, mappings,data);
		}
	}
	
	mappings.append(value.getXML());
	done.add(key);
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:24,代码来源:HibernateSessionFactory.java

示例8: getName

import lucee.runtime.Component; //导入依赖的package包/类
public static String getName(Class clazz) {
    if(clazz == null) return "null";
    //String name=clazz.getName();
    //if(Reflector.isInstaneOf(clazz,String.class))                   return "String";
    if(Reflector.isInstaneOf(clazz,UDF.class)) return "user defined function";
    //else if(Reflector.isInstaneOf(clazz,Boolean.class))             return "Boolean";
    //else if(Reflector.isInstaneOf(clazz,Number.class))              return "Number";
    else if(Reflector.isInstaneOf(clazz,Array.class))               return "Array";
    else if(Reflector.isInstaneOf(clazz,Struct.class))              return "Struct";
    else if(Reflector.isInstaneOf(clazz,Query.class))               return "Query";
    else if(Reflector.isInstaneOf(clazz,DateTime.class))            return "DateTime";
    else if(Reflector.isInstaneOf(clazz,Component.class))           return "Component";
    else if(Reflector.isInstaneOf(clazz,byte[].class))              return "Binary";
    else {
        String className=clazz.getName();
        if(className.startsWith("java.lang.")) {
            return className.substring(10);
        }
        return className;
    }
    
    
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:24,代码来源:Type.java

示例9: _toPojo

import lucee.runtime.Component; //导入依赖的package包/类
private static Pojo _toPojo(PageContext pc, Pojo pojo, TypeMapping tm,TypeEntry typeEntry,QName type,Component comp, Set<Object> done) throws PageException {//print.ds();System.exit(0);
  	comp=ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE,comp);
ComponentScope scope = comp.getComponentScope();
  	
// create Pojo
if(pojo==null) {
   	try {
		pojo = (Pojo) ClassUtil.loadInstance(ComponentUtil.getComponentPropertiesClass(pc,comp));
	} catch (ClassException e) {
		throw Caster.toPageException(e);
	}
}
  	
  	// initialize Pojo
Property[] props=ComponentProUtil.getProperties(comp, false, true, false, false);
_initPojo(pc,typeEntry,type,pojo,props,scope,comp,tm,done);

  	return pojo;
  }
 
开发者ID:lucee,项目名称:Lucee4,代码行数:20,代码来源:AxisCaster.java

示例10: doGet

import lucee.runtime.Component; //导入依赖的package包/类
/**
 * Process GET requests. This includes handoff of pseudo-SOAP requests
 *
 * @param request request in
 * @param response request out
 * @throws ServletException
 */
public void doGet(HttpServletRequest request, HttpServletResponse response, Component component) throws ServletException {
	PrintWriter writer = new FilterPrintWriter(response);
	
	try {
		if (!doGet(request, response, writer,component)) {
			response.setContentType("text/html; charset=utf-8");
			writer.println("<html><h1>Lucee Webservice</h1>");
			writer.println(Messages.getMessage("reachedServlet00"));
			writer.println("<p>" + Messages.getMessage("transportName00","<b>http</b>"));
			writer.println("</html>");
		}
	} 
	catch (Throwable e) {
		ExceptionUtil.rethrowIfNecessary(e);
		if(e instanceof InvocationTargetException)
			e= ((InvocationTargetException)e).getTargetException();
		if(e instanceof PageException)
			throw new PageServletException((PageException)e);
		throw new ServletException(e);
	}
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:29,代码来源:RPCServer.java

示例11: doGet

import lucee.runtime.Component; //导入依赖的package包/类
/**
   * Process GET requests. This includes handoff of pseudo-SOAP requests
   *
   * @param request request in
   * @param response request out
   * @throws ServletException
   */
  public void doGet(HttpServletRequest request, HttpServletResponse response, Component component) throws ServletException {
      PrintWriter writer = new FilterPrintWriter(response);
      
      try {
	if (!doGet(request, response, writer,component)) {
		ReqRspUtil.setContentType(response,"text/html; charset=utf-8");
		writer.println("<html><h1>"+lucee.runtime.config.Constants.NAME+" Webservice</h1>");
              writer.println(Messages.getMessage("reachedServlet00"));
              writer.println("<p>" + Messages.getMessage("transportName00","<b>http</b>"));
              writer.println("</html>");
	}
} 
      catch (Throwable e) {
	ExceptionUtil.rethrowIfNecessary(e);
      	if(e instanceof InvocationTargetException)
      		e= ((InvocationTargetException)e).getTargetException();
      	if(e instanceof PageException)
          	throw new PageServletException((PageException)e);
      	throw new ServletException(e);
}
  }
 
开发者ID:lucee,项目名称:Lucee,代码行数:29,代码来源:RPCServer.java

示例12: save

import lucee.runtime.Component; //导入依赖的package包/类
@Override
public void save(PageContext pc, Object obj,boolean forceInsert) throws PageException {
	Component cfc = HibernateCaster.toComponent(obj);
	String name = HibernateCaster.getEntityName(cfc);
	Key dsn = KeyImpl.init(ORMUtil.getDataSourceName(pc, cfc));
	
	try {
		Session session = getSession(dsn);
		if(forceInsert)
			session.save(name, cfc);
		else
			session.saveOrUpdate(name, cfc);
	}
	catch(Throwable t){
		lucee.commons.lang.ExceptionUtil.rethrowIfNecessary(t);
		throw ExceptionUtil.createException(this,null,t);
	}
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:19,代码来源:HibernateORMSession.java

示例13: invoke

import lucee.runtime.Component; //导入依赖的package包/类
public static Component invoke(PageContext pc, String name, String md5, Struct sctThis, Struct sctVariables) throws PageException {
	// Load comp
	Component comp=null;
	try {
		comp = pc.loadComponent(name);
		if(!ComponentUtil.md5(comp).equals(md5)){	
			SystemOut.printDate(pc.getConfig().getErrWriter(),"component ["+name+"] in this enviroment has not the same interface as the component to load, it is possible that one off the components has Functions added dynamicly.");
			//throw new ExpressionException("component ["+name+"] in this enviroment has not the same interface as the component to load");
		}
	}
	catch (Exception e) {
		throw Caster.toPageException(e);
	}
	setInternalState(comp,sctThis,sctVariables);
	return comp;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:17,代码来源:EvaluateComponent.java

示例14: addRelation

import lucee.runtime.Component; //导入依赖的package包/类
private static int addRelation(Component cfc,Element clazz, PageContext pc,PropertyCollection propColl, Struct columnsInfo, String tableName, DatasourceConnection dc, SessionFactoryData data) throws PageException {
   	Property[] props = propColl.getProperties();
	int count=0;
   	for(int y=0;y<props.length;y++){
		String fieldType = CommonUtil.toString(props[y].getDynamicAttributes().get(FIELDTYPE,"column"),"column");
		if("one-to-one".equalsIgnoreCase(fieldType)){
			createXMLMappingOneToOne(clazz,pc, cfc,props[y],data);
			count++;
		}
		else if("many-to-one".equalsIgnoreCase(fieldType)){
			createXMLMappingManyToOne(clazz,pc, cfc,props[y],propColl,data);
			count++;
		}
		else if("one-to-many".equalsIgnoreCase(fieldType)){
			createXMLMappingOneToMany(cfc,propColl,clazz,pc, props[y],data);
			count++;
		}
		else if("many-to-many".equalsIgnoreCase(fieldType)){
			createXMLMappingManyToMany(cfc,propColl,clazz,pc, props[y],dc,data);
			count++;
		}
	}
   	return count;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:25,代码来源:HBMCreator.java

示例15: has

import lucee.runtime.Component; //导入依赖的package包/类
private boolean has(PageContext pageContext) {
	Object propValue = component.getComponentScope().get(propName,null);
	
	// struct
	if(isStruct()) {
		if(propValue instanceof Map) {
			return !((Map)propValue).isEmpty();
		}
		return false;
	}
	
		//Object o;
		if(propValue instanceof Array) {
			Array arr = ((Array)propValue);
			return arr.size()>0;
		}
		else if(propValue instanceof java.util.List) {
			
			return ((java.util.List)propValue).size()>0;
		}
		return propValue instanceof Component;
	
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:24,代码来源:UDFHasProperty.java


注:本文中的lucee.runtime.Component类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。