Package com.google.enterprise.connector.spi

Examples of com.google.enterprise.connector.spi.Value


    assertNotNull("Document list is null", docList);
    Document doc = docList.nextDocument();
    while (doc != null && doc instanceof FileDocument) {
      Property lastModifiedProp =
          doc.findProperty(SpiConstants.PROPNAME_LASTMODIFIED);
      Value lastModifiedValue = lastModifiedProp.nextValue();
      Calendar cal = Value.iso8601ToCalendar(lastModifiedValue.toString());

      Document nextDoc = docList.nextDocument();
      if (nextDoc != null && nextDoc instanceof FileDocument) {
        Property nextDocLastModifiedProp =
            nextDoc.findProperty(SpiConstants.PROPNAME_LASTMODIFIED);
        Value nextDocLastModifiedValue = nextDocLastModifiedProp.nextValue();
        Calendar nextCal =
            Value.iso8601ToCalendar(nextDocLastModifiedValue.toString());
        assertTrue(cal.compareTo(nextCal) <= 0);
        isTested = true;
      }
      doc = nextDoc;
    }
View Full Code Here


  private void validateRepeatedProperty(List<?> expect, Property property)
      throws RepositoryException {
    assertNotNull(property);
    int size = 0;
    while (true) {
      Value v = property.nextValue();
      if (v == null) {
        break;
      }
      size++;
      String name = (v instanceof PrincipalValue) ?
        ((PrincipalValue) v).getPrincipal().getName() : v.toString();
      assertTrue(name, expect.contains(name));
    }
    assertEquals(expect.size(), size);
  }
View Full Code Here

    JsonDocument doc = getJsonDocument(builder, rowMap);
    for (String propName : doc.getPropertyNames()) {
      LOG.info(propName + ":    " + getProperty(doc, propName));
    }
    assertEquals("BF/1/last_01", getProperty(doc, SpiConstants.PROPNAME_DOCID));
    Value contentValue = Value.getSingleValue(doc,
        SpiConstants.PROPNAME_CONTENT);
    assertNotNull(contentValue);
    String content = new String(
        Base64.decode(InputStreamFactories.toString(contentValue)), "UTF-8");
    assertEquals(SpiConstants.ContentEncoding.BASE64BINARY.toString(),
View Full Code Here

    DocumentHandle handle = new DBHandle(jsonDocument);
    Document document = handle.getDocument();
    DocumentHandle deserialHandle = new DBHandle(handle.toString());
    Document deserialDocument = deserialHandle.getDocument();

    Value value = Value.getSingleValue(document,
        SpiConstants.PROPNAME_LASTMODIFIED);
    Value deserialValue = Value.getSingleValue(deserialDocument,
        SpiConstants.PROPNAME_LASTMODIFIED);
    assertEquals(lastModified, value.toString());
    assertEquals(value.toString(), deserialValue.toString());
    assertTrue(value.getClass().toString(), value instanceof DateValue);
    assertEquals(value.getClass(), deserialValue.getClass());
  }
View Full Code Here

  private void assertPropertyEquals(String message, Property expectedProperty,
      Property actualProperty) throws RepositoryException, IOException {
    assertNotNull(message, expectedProperty);
    assertNotNull(message, actualProperty);
    Value expectedValue = expectedProperty.nextValue();
    Value actualValue = actualProperty.nextValue();
    if (expectedValue instanceof BinaryValue) {
      assertTrue(actualValue.getClass().toString(),
          actualValue instanceof BinaryValue);
      assertBinaryValueEquals(message, (BinaryValue) expectedValue,
          (BinaryValue) actualValue);
    } else {
      assertEquals(message, expectedValue.toString(), actualValue.toString());
    }
  }
View Full Code Here

          rowMap);

      assertEquals("BF/1/last_01", Value.getSingleValueString(doc,
          SpiConstants.PROPNAME_DOCID));

      Value contentValue = Value.getSingleValue(doc,
          SpiConstants.PROPNAME_CONTENT);
      assertNotNull(contentValue);
      String content = new String(
          Base64.decode(InputStreamFactories.toString(contentValue)), "UTF-8");
      assertEquals(SpiConstants.ContentEncoding.BASE64BINARY.toString(),
View Full Code Here

    dbContext.setGoogleConnectorName("test_connector");
  }

  public static String getProperty(JsonDocument doc, String propName)
      throws IOException, RepositoryException {
    Value value = Value.getSingleValue(doc, propName);
    if (value == null) {
      return null;
    } else if (propName.equals(SpiConstants.PROPNAME_CONTENT)) {
      byte[] content = getBytes(value);
      return new String(content, Charsets.UTF_8);
    } else {
      return value.toString();
    }
  }
View Full Code Here

    }
  }

  protected static byte[] readBlobContent(JsonDocument doc)
      throws IOException, RepositoryException {
    Value value = Value.getSingleValue(doc, SpiConstants.PROPNAME_CONTENT);
    if (value == null) {
      return null;
    }
    return getBytes(value);
  }
View Full Code Here

  }

  private void assertEmptyContent(JsonDocument doc)
      throws IOException, RepositoryException {
    // SQL NULLs are rendered as empty byte arrays for easier handling.
    Value value = Value.getSingleValue(doc, SpiConstants.PROPNAME_CONTENT);
    assertTrue(value.getClass().toString(), value instanceof BinaryValue);
    assertEquals(-1, ((BinaryValue) value).getInputStream().read());
  }
View Full Code Here

  /** Returns the first value of the named property as a String. */
  private String getSingleValueString(String name) {
    List<Value> values = properties.get(name);
    if (values != null) {
      Value value = values.iterator().next();
      if (value != null) {
        return value.toString();
      }
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.spi.Value

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.