Search in sources :

Example 16 with Array

use of lucee.runtime.type.Array in project Lucee by lucee.

the class _GetElement method toStruct.

@Override
public Object toStruct() {
    Resource[] locs = getCfcLocations();
    Array arrLocs = new ArrayImpl();
    if (locs != null)
        for (int i = 0; i < locs.length; i++) {
            arrLocs.appendEL(getAbsolutePath(locs[i]));
        }
    Struct sct = new StructImpl();
    sct.setEL(AUTO_GEN_MAP, this.autogenmap());
    sct.setEL(CATALOG, StringUtil.emptyIfNull(getCatalog()));
    sct.setEL(CFC_LOCATION, arrLocs);
    sct.setEL(IS_DEFAULT_CFC_LOCATION, isDefaultCfcLocation());
    sct.setEL(DB_CREATE, dbCreateAsString(getDbCreate()));
    sct.setEL(DIALECT, StringUtil.emptyIfNull(getDialect()));
    sct.setEL(EVENT_HANDLING, eventHandling());
    sct.setEL(EVENT_HANDLER, eventHandler());
    sct.setEL(NAMING_STRATEGY, namingStrategy());
    sct.setEL(FLUSH_AT_REQUEST_END, flushAtRequestEnd());
    sct.setEL(LOG_SQL, logSQL());
    sct.setEL(SAVE_MAPPING, saveMapping());
    sct.setEL(SCHEMA, StringUtil.emptyIfNull(getSchema()));
    sct.setEL(SECONDARY_CACHE_ENABLED, secondaryCacheEnabled());
    sct.setEL(SQL_SCRIPT, StringUtil.toStringEmptyIfNull(getSqlScript()));
    sct.setEL(USE_DB_FOR_MAPPING, useDBForMapping());
    sct.setEL(CACHE_CONFIG, getAbsolutePath(getCacheConfig()));
    sct.setEL(CACHE_PROVIDER, StringUtil.emptyIfNull(getCacheProvider()));
    sct.setEL(ORM_CONFIG, getAbsolutePath(getOrmConfig()));
    return sct;
}
Also used : Array(lucee.runtime.type.Array) StructImpl(lucee.runtime.type.StructImpl) ArrayImpl(lucee.runtime.type.ArrayImpl) Resource(lucee.commons.io.res.Resource) Struct(lucee.runtime.type.Struct)

Example 17 with Array

use of lucee.runtime.type.Array in project Lucee by lucee.

the class Reflector method toNativeArray.

private static Object toNativeArray(Class clazz, Object obj) throws PageException {
    // if(obj.getClass()==clazz) return obj;
    Object[] objs = null;
    if (obj instanceof Array)
        objs = toRefArray((Array) obj);
    else if (obj instanceof List)
        objs = toRefArray((List) obj);
    else if (Decision.isNativeArray(obj)) {
        if (obj.getClass() == boolean[].class)
            objs = toRefArray((boolean[]) obj);
        else if (obj.getClass() == byte[].class)
            objs = toRefArray((byte[]) obj);
        else if (obj.getClass() == char[].class)
            objs = toRefArray((char[]) obj);
        else if (obj.getClass() == short[].class)
            objs = toRefArray((short[]) obj);
        else if (obj.getClass() == int[].class)
            objs = toRefArray((int[]) obj);
        else if (obj.getClass() == long[].class)
            objs = toRefArray((long[]) obj);
        else if (obj.getClass() == float[].class)
            objs = toRefArray((float[]) obj);
        else if (obj.getClass() == double[].class)
            objs = toRefArray((double[]) obj);
        else
            // toRefArray((Object[])obj);
            objs = (Object[]) obj;
    }
    if (clazz == objs.getClass()) {
        return objs;
    }
    // if(objs==null) return defaultValue;
    // Class srcClass = objs.getClass().getComponentType();
    Class compClass = clazz.getComponentType();
    Object rtn = java.lang.reflect.Array.newInstance(compClass, objs.length);
    // try{
    for (int i = 0; i < objs.length; i++) {
        java.lang.reflect.Array.set(rtn, i, convert(objs[i], compClass, null));
    }
    return rtn;
}
Also used : Array(lucee.runtime.type.Array) JavaObject(lucee.runtime.java.JavaObject) List(java.util.List) ArrayList(java.util.ArrayList)

Example 18 with Array

use of lucee.runtime.type.Array in project Lucee by lucee.

the class SoftMethodStorage method storeMethod.

/**
 * stores a single method
 * @param method
 * @param methodsMap
 */
private void storeMethod(Method method, Map<Key, Array> methodsMap) {
    Key methodName = KeyImpl.init(method.getName());
    Array methodArgs;
    synchronized (methodsMap) {
        methodArgs = methodsMap.get(methodName);
        if (methodArgs == null) {
            methodArgs = new ArrayImpl();
            methodsMap.put(methodName, methodArgs);
        }
    }
    storeArgs(method, methodArgs);
// Modifier.isStatic(method.getModifiers());
}
Also used : Array(lucee.runtime.type.Array) ArrayImpl(lucee.runtime.type.ArrayImpl) Key(lucee.runtime.type.Collection.Key)

Example 19 with Array

use of lucee.runtime.type.Array in project Lucee by lucee.

the class WeakConstructorStorage method getConstructors.

/**
 * returns a constructor matching given criteria or null if Constructor doesn't exist
 * @param clazz Class to get Constructor for
 * @param count count of arguments for the constructor
 * @return returns the constructors
 */
public Constructor[] getConstructors(Class clazz, int count) {
    Array con;
    Object o;
    synchronized (map) {
        o = map.get(clazz);
        if (o == null) {
            con = store(clazz);
        } else
            con = (Array) o;
    }
    o = con.get(count + 1, null);
    if (o == null)
        return null;
    return (Constructor[]) o;
}
Also used : Array(lucee.runtime.type.Array)

Example 20 with Array

use of lucee.runtime.type.Array in project Lucee by lucee.

the class Perl5Util method match.

public static Array match(String strPattern, String strInput, int offset, boolean caseSensitive) throws MalformedPatternException {
    Perl5Matcher matcher = new Perl5Matcher();
    PatternMatcherInput input = new PatternMatcherInput(strInput);
    int compileOptions = caseSensitive ? 0 : Perl5Compiler.CASE_INSENSITIVE_MASK;
    compileOptions += Perl5Compiler.MULTILINE_MASK;
    if (offset < 1)
        offset = 1;
    Pattern pattern = getPattern(strPattern, compileOptions);
    Array rtn = new ArrayImpl();
    MatchResult result;
    while (matcher.contains(input, pattern)) {
        result = matcher.getMatch();
        rtn.appendEL(result.toString());
    }
    return rtn;
}
Also used : Array(lucee.runtime.type.Array) Pattern(org.apache.oro.text.regex.Pattern) PatternMatcherInput(org.apache.oro.text.regex.PatternMatcherInput) ArrayImpl(lucee.runtime.type.ArrayImpl) Perl5Matcher(org.apache.oro.text.regex.Perl5Matcher) MatchResult(org.apache.oro.text.regex.MatchResult)

Aggregations

Array (lucee.runtime.type.Array)169 ArrayImpl (lucee.runtime.type.ArrayImpl)79 Struct (lucee.runtime.type.Struct)49 StructImpl (lucee.runtime.type.StructImpl)25 Iterator (java.util.Iterator)24 PageException (lucee.runtime.exp.PageException)23 Entry (java.util.Map.Entry)22 ArrayList (java.util.ArrayList)20 Key (lucee.runtime.type.Collection.Key)20 ListIterator (java.util.ListIterator)16 Query (lucee.runtime.type.Query)16 List (java.util.List)14 ApplicationException (lucee.runtime.exp.ApplicationException)14 FunctionException (lucee.runtime.exp.FunctionException)14 ForEachQueryIterator (lucee.runtime.type.it.ForEachQueryIterator)14 Resource (lucee.commons.io.res.Resource)13 IOException (java.io.IOException)12 Collection (lucee.runtime.type.Collection)10 QueryImpl (lucee.runtime.type.QueryImpl)10 JavaObject (lucee.runtime.java.JavaObject)8