⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propertyimpl.java

📁 jsr170接口的java实现。是个apache的开源项目。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                    }                }                internalValues[i] = internalValue;            }        }        internalSetValue(internalValues, reqType);    }    /**     * {@inheritDoc}     */    public QName getQName() {        return ((PropertyId) id).getName();    }    /**     * Returns the internal values of this property     *     * @return     * @throws RepositoryException     */    public InternalValue[] internalGetValues() throws RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (!definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath() + " is not multi-valued");        }        PropertyState state = (PropertyState) getItemState();        return state.getValues();    }    /**     * Returns the internal values of this property     *     * @return     * @throws RepositoryException     */    public InternalValue internalGetValue() throws RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath()                    + " is multi-valued and can therefore only be retrieved as an array of values");        }        PropertyState state = (PropertyState) getItemState();        return state.getValues()[0];    }    //-------------------------------------------------------------< Property >    /**     * {@inheritDoc}     */    public Value[] getValues() throws ValueFormatException, RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (!definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath()                    + " is not multi-valued");        }        PropertyState state = (PropertyState) getItemState();        InternalValue[] internalValues = state.getValues();        Value[] values = new Value[internalValues.length];        for (int i = 0; i < internalValues.length; i++) {            values[i] = internalValues[i].toJCRValue(session.getNamespaceResolver());        }        return values;    }    /**     * {@inheritDoc}     */    public Value getValue() throws ValueFormatException, RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath()                    + " is multi-valued and can therefore only be retrieved as an array of values");        }        PropertyState state = (PropertyState) getItemState();        try {            InternalValue val = state.getValues()[0];            return val.toJCRValue(session.getNamespaceResolver());        } catch (RepositoryException e) {            throw e;        } catch (Exception e) {            String msg = "Internal error while retrieving value of "                    + safeGetJCRPath();            log.error(msg, e);            throw new RepositoryException(msg, e);        }    }    /**     * {@inheritDoc}     */    public String getString() throws ValueFormatException, RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath()                    + " is multi-valued and can therefore only be retrieved as an array of values");        }        return getValue().getString();    }    /**     * {@inheritDoc}     */    public InputStream getStream() throws ValueFormatException, RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath()                    + " is multi-valued and can therefore only be retrieved as an array of values");        }        return getValue().getStream();    }    /**     * {@inheritDoc}     */    public long getLong() throws ValueFormatException, RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath()                    + " is multi-valued and can therefore only be retrieved as an array of values");        }        PropertyState state = (PropertyState) getItemState();        InternalValue val = state.getValues()[0];        int type = val.getType();        if (type == PropertyType.LONG) {            return ((Long) val.internalValue()).longValue();        }        // not a LONG value, delegate conversion to Value object        return val.toJCRValue(session.getNamespaceResolver()).getLong();    }    /**     * {@inheritDoc}     */    public double getDouble() throws ValueFormatException, RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath()                    + " is multi-valued and can therefore only be retrieved as an array of values");        }        // avoid unnecessary object creation if possible        PropertyState state = (PropertyState) getItemState();        InternalValue val = state.getValues()[0];        int type = val.getType();        if (type == PropertyType.DOUBLE) {            return ((Double) val.internalValue()).doubleValue();        }        // not a DOUBLE value, delegate conversion to Value object        return val.toJCRValue(session.getNamespaceResolver()).getDouble();    }    /**     * {@inheritDoc}     */    public Calendar getDate() throws ValueFormatException, RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath()                    + " is multi-valued and can therefore only be retrieved as an array of values");        }        // avoid unnecessary object creation if possible        PropertyState state = (PropertyState) getItemState();        InternalValue val = state.getValues()[0];        int type = val.getType();        if (type == PropertyType.DATE) {            return (Calendar) val.internalValue();        }        // not a DATE value, delegate conversion to Value object        return val.toJCRValue(session.getNamespaceResolver()).getDate();    }    /**     * {@inheritDoc}     */    public boolean getBoolean() throws ValueFormatException, RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath()                    + " is multi-valued and can therefore only be retrieved as an array of values");        }        // avoid unnecessary object creation if possible        PropertyState state = (PropertyState) getItemState();        InternalValue val = state.getValues()[0];        int type = val.getType();        if (type == PropertyType.BOOLEAN) {            return ((Boolean) val.internalValue()).booleanValue();        }        // not a BOOLEAN value, delegate conversion to Value object        return val.toJCRValue(session.getNamespaceResolver()).getBoolean();    }    /**     * {@inheritDoc}     */    public Node getNode() throws ValueFormatException, RepositoryException {        // check state of this instance        sanityCheck();        // check multi-value flag        if (definition.isMultiple()) {            throw new ValueFormatException(safeGetJCRPath()                    + " is multi-valued and can therefore only be retrieved as an array of values");        }        PropertyState state = (PropertyState) getItemState();        InternalValue val = state.getValues()[0];        if (val.getType() == PropertyType.REFERENCE) {            // reference, i.e. target UUID            UUID targetUUID = (UUID) val.internalValue();            return (Node) itemMgr.getItem(new NodeId(targetUUID));        } else {            throw new ValueFormatException("property must be of type REFERENCE");        }    }    /**     * {@inheritDoc}     */    public void setValue(Calendar date)            throws ValueFormatException, VersionException,            LockException, ConstraintViolationException,            RepositoryException {        // check state of this instance        sanityCheck();        // check pre-conditions for setting property value        checkSetValue(false);        // check type according to definition of this property        int reqType = definition.getRequiredType();        if (reqType == PropertyType.UNDEFINED) {            reqType = PropertyType.DATE;        }        if (date == null) {            internalSetValue(null, reqType);            return;        }        InternalValue value;        if (reqType != PropertyType.DATE) {            // type conversion required            Value targetVal = ValueHelper.convert(                    new DateValue(date), reqType,                    ValueFactoryImpl.getInstance());            value = InternalValue.create(targetVal, session.getNamespaceResolver());        } else {            // no type conversion required            value = InternalValue.create(date);        }        internalSetValue(new InternalValue[]{value}, reqType);    }    /**     * {@inheritDoc}     */    public void setValue(double number)            throws ValueFormatException, VersionException,            LockException, ConstraintViolationException,            RepositoryException {        // check state of this instance        sanityCheck();        // check pre-conditions for setting property value        checkSetValue(false);        // check type according to definition of this property        int reqType = definition.getRequiredType();        if (reqType == PropertyType.UNDEFINED) {            reqType = PropertyType.DOUBLE;        }        InternalValue value;        if (reqType != PropertyType.DOUBLE) {            // type conversion required            Value targetVal = ValueHelper.convert(                    new DoubleValue(number), reqType,                    ValueFactoryImpl.getInstance());            value = InternalValue.create(targetVal, session.getNamespaceResolver());        } else {            // no type conversion required            value = InternalValue.create(number);        }        internalSetValue(new InternalValue[]{value}, reqType);    }    /**     * {@inheritDoc}     */    public void setValue(InputStream stream)            throws ValueFormatException, VersionException,            LockException, ConstraintViolationException,            RepositoryException {        // check state of this instance        sanityCheck();        // check pre-conditions for setting property value        checkSetValue(false);        // check type according to definition of this property        int reqType = definition.getRequiredType();        if (reqType == PropertyType.UNDEFINED) {            reqType = PropertyType.BINARY;        }        if (stream == null) {            internalSetValue(null, reqType);            return;        }        InternalValue value;        try {            if (reqType != PropertyType.BINARY) {                // type conversion required                Value targetVal = ValueHelper.convert(                        new BLOBFileValue(stream), reqType,                        ValueFactoryImpl.getInstance());                value = InternalValue.create(targetVal, session.getNamespaceResolver());            } else {                // no type conversion required                value = InternalValue.create(stream);            }        } catch (IOException ioe) {            String msg = "failed to spool stream to internal storage";            log.debug(msg);            throw new RepositoryException(msg, ioe);        }        internalSetValue(new InternalValue[]{value}, reqType);    }    /**     * {@inheritDoc}     */    public void setValue(String string)            throws ValueFormatException, VersionException,            LockException, ConstraintViolationException,            RepositoryException {        // check state of this instance        sanityCheck();        // check pre-conditions for setting property value        checkSetValue(false);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -