Search in sources :

Example 11 with Signature

use of php.runtime.annotation.Reflection.Signature in project jphp by jphp-compiler.

the class PHttpResponse method setRawCookies.

@Signature
public void setRawCookies(ArrayMemory rawCookies) {
    this.rawCookies = rawCookies;
    ArrayMemory cookies = new ArrayMemory();
    ForeachIterator iterator = rawCookies.foreachIterator(false, false);
    while (iterator.next()) {
        cookies.putAsKeyString(iterator.getStringKey(), iterator.getValue().valueOfIndex("value").toImmutable());
    }
    this.cookies = cookies;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ForeachIterator(php.runtime.lang.ForeachIterator) Signature(php.runtime.annotation.Reflection.Signature)

Example 12 with Signature

use of php.runtime.annotation.Reflection.Signature in project jphp by jphp-compiler.

the class WrapConfiguration method set.

@Signature
public String set(String key, Memory value) {
    String s = value.toString();
    if (value.isArray()) {
        s = StringUtils.join(value.toValue(ArrayMemory.class).toStringArray(), "|");
    }
    Object property = properties.setProperty(key, s);
    return property == null ? null : property.toString();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) BaseObject(php.runtime.lang.BaseObject) Signature(php.runtime.annotation.Reflection.Signature)

Example 13 with Signature

use of php.runtime.annotation.Reflection.Signature in project jphp by jphp-compiler.

the class FsUtils method hash.

@Signature
public static Memory hash(InputStream source, String algo, @Nullable Invoker invoker) throws NoSuchAlgorithmException {
    MessageDigest messageDigest = MessageDigest.getInstance(algo);
    byte[] buffer = new byte[BUFFER_SIZE];
    int len;
    try {
        int sum = 0;
        while ((len = source.read(buffer)) > 0) {
            messageDigest.update(buffer, 0, len);
            sum += len;
            if (invoker != null) {
                if (invoker.callAny(sum, len).toValue() == Memory.FALSE) {
                    break;
                }
            }
        }
        return StringMemory.valueOf(DigestUtils.bytesToHex(messageDigest.digest()));
    } catch (FileNotFoundException e) {
        return Memory.NULL;
    } catch (IOException e) {
        return Memory.NULL;
    }
}
Also used : MessageDigest(java.security.MessageDigest) Signature(php.runtime.annotation.Reflection.Signature)

Example 14 with Signature

use of php.runtime.annotation.Reflection.Signature in project jphp by jphp-compiler.

the class WrapXmlProcessor method __construct.

@Signature
public void __construct(final Environment env) throws ParserConfigurationException, TransformerConfigurationException {
    transformerFactory = TransformerFactory.newInstance();
    transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    builderFactory = DocumentBuilderFactory.newInstance();
    builder = builderFactory.newDocumentBuilder();
    builder.setErrorHandler(new ErrorHandler() {

        @Override
        public void warning(SAXParseException exception) throws SAXException {
            if (onWarning != null) {
                onWarning.callAny(new JavaException(env, exception));
            }
        }

        @Override
        public void error(SAXParseException exception) throws SAXException {
            if (onError != null) {
                onError.callAny(new JavaException(env, exception));
            }
        }

        @Override
        public void fatalError(SAXParseException exception) throws SAXException {
            if (onFatalError != null) {
                onFatalError.callAny(new JavaException(env, exception));
            } else {
                throw exception;
            }
        }
    });
}
Also used : ErrorHandler(org.xml.sax.ErrorHandler) JavaException(php.runtime.ext.java.JavaException) SAXParseException(org.xml.sax.SAXParseException) SAXException(org.xml.sax.SAXException) Signature(php.runtime.annotation.Reflection.Signature)

Example 15 with Signature

use of php.runtime.annotation.Reflection.Signature in project jphp by jphp-compiler.

the class PSqlResult method toArray.

@Signature
public ArrayMemory toArray(Environment env, boolean assoc) throws SQLException {
    ResultSetMetaData metaData = resultSet.getMetaData();
    ArrayMemory result = new ArrayMemory();
    int count = metaData.getColumnCount();
    for (int i = 0; i < count; i++) {
        Memory value = getTyped(env, i);
        if (assoc) {
            result.putAsKeyString(metaData.getColumnLabel(i + 1), value);
        } else {
            result.add(value);
        }
    }
    return result.toConstant();
}
Also used : Memory(php.runtime.Memory) Signature(php.runtime.annotation.Reflection.Signature)

Aggregations

Signature (php.runtime.annotation.Reflection.Signature)30 ArrayMemory (php.runtime.memory.ArrayMemory)8 InputStream (java.io.InputStream)4 Memory (php.runtime.Memory)4 ForeachIterator (php.runtime.lang.ForeachIterator)4 StringMemory (php.runtime.memory.StringMemory)4 ZipEntry (java.util.zip.ZipEntry)2 DOMSource (javax.xml.transform.dom.DOMSource)2 StreamResult (javax.xml.transform.stream.StreamResult)2 Stream (php.runtime.ext.core.classes.stream.Stream)2 WrapTime (php.runtime.ext.core.classes.time.WrapTime)2 LongMemory (php.runtime.memory.LongMemory)2 Intent (android.content.Intent)1 Button (android.widget.Button)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 HikariConfig (com.zaxxer.hikari.HikariConfig)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1