Tabnine Logo
Property.getLengths
Code IndexAdd Tabnine to your IDE (free)

How to use
getLengths
method
in
javax.jcr.Property

Best Java code snippets using javax.jcr.Property.getLengths (Showing top 20 results out of 315)

origin: org.onehippo.cms7/hippo-repository-connector

/**
 * @inheritDoc
 */
public long[] getLengths() throws ValueFormatException, RepositoryException {
  return property.getLengths();
}
origin: org.apache.sling/org.apache.sling.scripting.javascript

public long[] jsGet_lengths() {
  try {
    return property.getLengths();
  } catch (RepositoryException re) {
    return new long[0];
  }
}
origin: net.adamcin.oakpal/oakpal-core

@Override
public long[] getLengths() throws RepositoryException {
  return delegate.getLengths();
}
origin: net.adamcin.commons/net.adamcin.commons.jcr

public long[] getLengths() throws RepositoryException
{ return this.item.getLengths();}
origin: apache/jackrabbit

/** {@inheritDoc} */
public long[] getLengths() throws RepositoryException, RemoteException {
  try {
    return property.getLengths();
  } catch (RepositoryException ex) {
    throw getRepositoryException(ex);
  }
}
origin: info.magnolia/magnolia-core

@Override
public long[] getLengths() throws ValueFormatException, RepositoryException {
  return getWrappedProperty().getLengths();
}
origin: brix-cms/brix-cms

  public long[] execute() throws Exception {
    return getDelegate().getLengths();
  }
});
origin: org.apache.jackrabbit.vault/org.apache.jackrabbit.vault

/**
 * {@inheritDoc}
 */
public long getContentLength() {
  if (contentLength == null) {
    if (tmpFile == null) {
      contentLength = -1L;
      try {
        if (valueIndex < 0) {
          contentLength = property.getLength();
        } else {
          long[] lengths = property.getLengths();
          if (valueIndex < lengths.length) {
            contentLength = lengths[valueIndex];
          }
        }
      } catch (RepositoryException e) {
        // ignore
      }
    } else {
      contentLength = tmpFile.length();
    }
  }
  return contentLength;
}
origin: apache/jackrabbit

/**
 * Tests the Property.getLengths() method. The returned values are either -1
 * or the lengths of the according strings.
 */
public void testGetLengths() throws RepositoryException {
  if (multiple) {
    Value[] values = prop.getValues();
    long[] lengths = prop.getLengths();
    for (int i = 0; i < lengths.length; i++) {
      if (lengths[i] > -1) {
        assertEquals("Property.getLengths() returns " +
            "wrong array of the lengths of a multivalue property.",
            values[i].getString().length(), lengths[i]);
      }
    }
  } else {
    try {
      prop.getLengths();
      fail("Property.getLengths() called on a sinlge value property " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      // ok
    }
  }
}
origin: apache/jackrabbit

  /**
   * Tests the Property.getLengths() method. The returned values are either -1
   * or the lengths of the according conversions to strings.
   */
  public void testGetLengths() throws RepositoryException {
    if (multiple) {
      Value[] values = prop.getValues();
      long[] lengths = prop.getLengths();
      for (int i = 0; i < lengths.length; i++) {
        if (lengths[i] > -1) {
          assertEquals("Property.getLengths() returns " +
              "wrong array of the lengths of a multivalue property.",
              values[i].getString().length(), lengths[i]);
        }
      }
    } else {
      try {
        prop.getLengths();
        fail("Property.getLengths() called on a sinlge value property " +
            "should throw a ValueFormatException.");

      } catch (ValueFormatException vfe) {
        // ok
      }
    }
  }
}
origin: apache/jackrabbit

  /**
   * Tests the Property.getLengths() method. The returned values are either -1
   * or the lengths of the according conversions to strings.
   */
  public void testGetLengths() throws RepositoryException {
    if (multiple) {
      Value[] values = prop.getValues();
      long[] lengths = prop.getLengths();
      for (int i = 0; i < lengths.length; i++) {
        if (lengths[i] > -1) {
          assertEquals("Property.getLengths() returns " +
              "wrong array of the lengths of a multivalue property.",
              values[i].getString().length(), lengths[i]);
        }
      }
    } else {
      try {
        prop.getLengths();
        fail("Property.getLengths() called on a sinlge value property " +
            "should throw a ValueFormatException.");

      } catch (ValueFormatException vfe) {
        // ok
      }
    }
  }
}
origin: apache/jackrabbit

/**
 * Tests the Property.getLengths() method. The test is successful, if either
 * -1 is returned
 */
public void testGetLengths() throws RepositoryException {
  if (multiple) {
    Value[] values = prop.getValues();
    long[] lengths = prop.getLengths();
    for (int i = 0; i < lengths.length; i++) {
      long length = PropertyUtil.countBytes(values[i]);
      assertEquals("Property.getLengths() returns " +
          "wrong array of the lengths of a multivalue property.",
          length, lengths[i]);
    }
  } else {
    try {
      prop.getLengths();
      fail("Property.getLengths() called on a sinlge value property " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      // ok
    }
  }
}
origin: brix-cms/brix-cms

public long[] getLengths(Property property) throws RepositoryException {
  if (getPrevious() != null) {
    return getPrevious().getLengths(property);
  } else {
    return property.getLengths();
  }
}
origin: apache/jackrabbit

@Override
public DavProperty<?> getProperty(DavPropertyName name) {
  DavProperty prop = super.getProperty(name);
  if (prop == null && exists()) {
    try {
      Property p = (Property) item;
      if (isMultiple()) {
        if (JCR_LENGTHS.equals(name)) {
          prop = new LengthsProperty(p.getLengths());
        }
      } else {
        if (JCR_LENGTH.equals(name)) {
          long length = p.getLength();
          prop = new DefaultDavProperty<String>(JCR_LENGTH, String.valueOf(length), true);
        } else if (JCR_GET_STRING.equals(name) && p.getType() != PropertyType.BINARY) {
          // getstring property is only created for single value
          // non-binary jcr properties
          prop = new DefaultDavProperty<String>(JCR_GET_STRING, p.getString(), true);
        }
      }
    } catch (RepositoryException e) {
      log.error("Failed to retrieve resource properties: "+e.getMessage());
    }
  }
  return prop;
}
origin: apache/jackrabbit

  /**
   * Tests if Property.getLengths() fails for single value property.
   */
  public void testGetLengthsFromSingleValued() throws RepositoryException, NotExecutableException {
    Property singleProp = PropertyUtil.searchSingleValuedProperty(testRootNode);
    if (singleProp == null) {
      throw new NotExecutableException("No single valued property found.");
    }
    try {
      singleProp.getLengths();
      fail("Property.getLengths() called on a single value property must fail (ValueFormatException).");
    } catch (ValueFormatException vfe) {
      // ok
    }
  }
}
origin: org.apache.jackrabbit/jackrabbit-jcr-commons

/**
 * Returns the values of the given value length operand at the given row.
 *
 * @see #getProperty(PropertyValue, Row)
 * @param operand value length operand
 * @param row row
 * @return values of the operand at the given row
 * @throws RepositoryException if the operand can't be evaluated
 */
private Value[] getLengthValues(Length operand, Row row)
    throws RepositoryException {
  Property property = getProperty(operand.getPropertyValue(), row);
  if (property == null) {
    return new Value[0];
  } else if (property.isMultiple()) {
    long[] lengths = property.getLengths();
    Value[] values = new Value[lengths.length];
    for (int i = 0; i < lengths.length; i++) {
      values[i] = factory.createValue(lengths[i]);
    }
    return values;
  } else {
    long length = property.getLength();
    return new Value[] { factory.createValue(length) };
  }
}
origin: org.apache.jackrabbit/jackrabbit-jcr-commons

/**
 * Returns the values of the given value length operand for the given node.
 *
 * @see #getProperty(PropertyValue, Node)
 * @param operand value length operand
 * @param node node
 * @return values of the operand for the given node
 * @throws RepositoryException if the operand can't be evaluated
 */
private Value[] getLengthValues(Length operand, Node n)
    throws RepositoryException {
  Property property = getProperty(operand.getPropertyValue(), n);
  if (property == null) {
    return new Value[0];
  }
  if (property.isMultiple()) {
    long[] lengths = property.getLengths();
    Value[] values = new Value[lengths.length];
    for (int i = 0; i < lengths.length; i++) {
      values[i] = factory.createValue(lengths[i]);
    }
    return values;
  }
  long length = property.getLength();
  return new Value[] { factory.createValue(length) };
}
origin: apache/jackrabbit

/**
 * Returns the values of the given value length operand for the given node.
 *
 * @see #getProperty(PropertyValue, Node)
 * @param operand value length operand
 * @param node node
 * @return values of the operand for the given node
 * @throws RepositoryException if the operand can't be evaluated
 */
private Value[] getLengthValues(Length operand, Node n)
    throws RepositoryException {
  Property property = getProperty(operand.getPropertyValue(), n);
  if (property == null) {
    return new Value[0];
  }
  if (property.isMultiple()) {
    long[] lengths = property.getLengths();
    Value[] values = new Value[lengths.length];
    for (int i = 0; i < lengths.length; i++) {
      values[i] = factory.createValue(lengths[i]);
    }
    return values;
  }
  long length = property.getLength();
  return new Value[] { factory.createValue(length) };
}
origin: apache/jackrabbit

private static void checkLength(Property p) throws RepositoryException {
  if (p.isMultiple()) {
    Value[] vals = p.getValues();
    long[] lengths = p.getLengths();
    for (int i = 0; i < lengths.length; i++) {
      assertTrue("Wrong property length", lengths[i] == getValueLength(vals[i]));
    }
  } else {
    assertTrue("Wrong property length", p.getLength() == getValueLength(p.getValue()));
  }
}
origin: ModeShape/modeshape

public void checkValue( Property prop ) throws Exception {
  // Should provide a value and not multiple values ...
  Value val = prop.getValue();
  assertThat(val, notNullValue());
  assertThat(prop.getDefinition(), notNullValue());
  // Should not allow multiple-value methods ...
  try {
    prop.getValues();
    fail("Should not be able to call 'getValues()' on a single-value property");
  } catch (ValueFormatException e) {
    // expected
  }
  try {
    prop.getLengths();
    fail("Should not be able to call 'getValues()' on a single-value property");
  } catch (ValueFormatException e) {
    // expected
  }
}
javax.jcrPropertygetLengths

Javadoc

Returns an array holding the lengths of the values of this (multi-value) property in bytes where each is individually calculated as described in #getLength().

Returns a -1 in the appropriate position if the implementation cannot determine the length of a value.

Popular methods of Property

  • getString
    Returns a String representation of the value of this property. A shortcut for Property.getValue().g
  • getValues
    Returns an array of all the values of this property. Used to access multi-value properties. The arra
  • getValue
    Returns the value of this property as a Value object. The object returned is a copy of the stored va
  • getName
  • getType
    Returns the type of this Property. One of: * PropertyType.STRING * PropertyType.BINARY * Property
  • getBinary
    Returns a Binary representation of the value of this property. A shortcut for Property.getValue().g
  • getBoolean
    Returns a boolean representation of the value of this property. A shortcut for Property.getValue().
  • remove
  • isMultiple
    Returns true if this property is multi-valued andfalse if this property is single-valued.
  • getDate
    Returns a Calendar representation of the value of this property. A shortcut for Property.getValue()
  • getLong
    Returns a long representation of the value of this property. A shortcut for Property.getValue().get
  • getDefinition
    Returns the property definition that applies to this property. In some cases there may appear to be
  • getLong,
  • getDefinition,
  • setValue,
  • getParent,
  • getPath,
  • getNode,
  • getLength,
  • getDouble,
  • getStream,
  • getSession

Popular in Java

  • Updating database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onCreateOptionsMenu (Activity)
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Table (org.hibernate.mapping)
    A relational table
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now