本文整理汇总了Java中javax.jcr.Property.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java Property.getLong方法的具体用法?Java Property.getLong怎么用?Java Property.getLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jcr.Property
的用法示例。
在下文中一共展示了Property.getLong方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRealValue
import javax.jcr.Property; //导入方法依赖的package包/类
public Object getRealValue(Property property) throws ValueFormatException,
RepositoryException {
Object value = null;
switch (property.getType()) {
case PropertyType.BOOLEAN:
value = property.getBoolean();
break;
case PropertyType.DATE:
value = property.getDate().getTime();
break;
case PropertyType.STRING:
value = property.getString();
break;
case PropertyType.LONG:
value = property.getLong();
break;
case PropertyType.DECIMAL:
value = property.getDecimal();
break;
default:
value = null;
}
return value;
}
示例2: getIdFromRepository
import javax.jcr.Property; //导入方法依赖的package包/类
/**
* This method
* @param session
* @param path
* @return
* @throws Exception
*/
public synchronized static Long getIdFromRepository( Session session, String path, String id) throws Exception {
Long returnId = null;
//LockManager lockManager = session.getWorkspace().getLockManager();
try{
//Lock lock = lockManager.lock(path, false, false, 30000l, "");
//Node node = lock.getNode();
Node node = session.getNode(path);
try {
Property property = node.getProperty(id);
returnId = property.getLong();
} catch (PathNotFoundException e) {
returnId = 10001l;
}
node.setProperty(id, returnId+1);
session.save();
} finally {
//lockManager.unlock(path);
}
return returnId;
}
示例3: readIntProperty
import javax.jcr.Property; //导入方法依赖的package包/类
@SuppressWarnings("NumericCastThatLosesPrecision")
public static int readIntProperty(final Node node, final String name) throws RepositoryException {
if (node.hasProperty(name)) {
final Property property = node.getProperty(name);
final long aLong = property.getLong();
return (int) aLong;
}
return 0;
}
示例4: printAttributes
import javax.jcr.Property; //导入方法依赖的package包/类
private void printAttributes( final int indentLevel,
final Node node ) throws RepositoryException {
String maxOccurs = null;
for ( final PropertyIterator iter = node.getProperties(); iter.hasNext(); ) {
final Property prop = iter.nextProperty();
final String name = prop.getName();
if ( name.equals( XsdLexicon.NC_NAME ) ) printAttribute( "name", prop.getString() );
else if ( name.equals( XsdLexicon.TYPE_NAME ) ) {
printAttribute( "type",
namespacePrefixByUri.get( node.getProperty( XsdLexicon.TYPE_NAMESPACE ).getString() )
+ prop.getString() );
} else if ( name.equals( XsdLexicon.MIN_OCCURS ) ) {
if ( prop.getLong() != 1 ) printAttribute( "minOccurs", prop.getString() );
maxOccurs = "unbounded";
} else if ( name.equals( XsdLexicon.MAX_OCCURS ) ) {
if ( prop.getLong() != 1 ) printAttribute( "maxOccurs", prop.getString() );
maxOccurs = null;
} else if ( name.equals( XsdLexicon.USE ) ) {
if ( !prop.getString().equals( "optional" ) ) printAttribute( "use", prop.getString() );
} else if ( name.startsWith( "xmlns" ) ) printAttribute( name, prop.getString() );
else if ( name.equals( XsdLexicon.NAMESPACE ) ) {
if ( !prop.getString().equals( targetNamespace ) ) printAttribute( "namespace", prop.getString() );
}
else if ( name.equals( XsdLexicon.SCHEMA_LOCATION ) ) printAttribute( "schemaLocation", prop.getString() );
else if ( name.equals( "targetNamespace" ) ) {
targetNamespace = prop.getString();
printAttribute( name, targetNamespace );
}
}
if ( maxOccurs != null ) printAttribute( "maxOccurs", maxOccurs );
}
示例5: distill
import javax.jcr.Property; //导入方法依赖的package包/类
/**
* Extract property based on their type and return as object (of Property)
*
* @param property This is a property
* @return content This is node property object
* @throws Exception
*/
public static Object distill(Property property)
throws Exception {
Object content;
boolean isMulti = property.isMultiple();
switch (property.getType()) {
case PropertyType.LONG:
if (isMulti)
content = asLongs(property);
else
content = property.getLong();
break;
case PropertyType.DECIMAL:
case PropertyType.DOUBLE:
if (isMulti)
content = asDoubles(property);
else
content = property.getDouble();
break;
case PropertyType.BOOLEAN:
if (isMulti)
content = asBooleans(property);
else
content = property.getBoolean();
break;
case PropertyType.DATE:
if (isMulti)
content = asDates(property);
else
content = property.getValue().getString();
break;
case PropertyType.NAME:
case PropertyType.STRING:
case PropertyType.PATH:
case PropertyType.URI:
default:
if (isMulti)
content = asStrings(property);
else
content = property.getString();
break;
}
return content;
}
示例6: getPropertyLong
import javax.jcr.Property; //导入方法依赖的package包/类
/**
* Conventience method for getting a single-value Long property from a resource.
* @param resource The resource from which to get the property.
* @param namePattern Property name.
* @return Property value.
*/
public static Long getPropertyLong(Resource resource, String namePattern) throws RepositoryException {
Property prop = getProperty(resource, namePattern);
return prop != null ? prop.getLong() : null;
}