Esempio n. 1
0
  /** @tests java.net.URI#compareTo(java.net.URI) */
  public void test_compareToLjava_net_URI() throws URISyntaxException {
    URI uri1, uri2;

    // URIs whose host names have different casing
    uri1 = new URI("http://MixedCaseHost/path/resource");
    uri2 = new URI("http://mixedcasehost/path/resource");
    assertEquals("Assert 0: host name equality failure", 0, uri1.compareTo(uri2));
    assertEquals("Assert 1: host name equality failure", 0, uri1.compareTo(uri2));

    // URIs with one undefined component (port)
    uri1 = new URI("http://*****:*****@anyhost/path/resource");
    uri2 = new URI("http://anyhost/path/resource");
    assertTrue("Assert 4: comparison failure", uri1.compareTo(uri2) > 0);
    assertTrue("Assert 5: comparison failure", uri2.compareTo(uri1) < 0);
  }
  /**
   * @param v1 The first explicit dimension value.
   * @param v2 The second explicit dimension value.
   * @return a negative integer, zero, or a positive integer as the first argument is less than,
   *     equal to, or greater than the second.
   * @throws XBRLException
   */
  private int compareExplicitDimensionValues(DimensionValue v1, DimensionValue v2)
      throws XBRLException {

    Concept v1m = (Concept) v1.getValue();
    Concept v2m = (Concept) v2.getValue();

    URI v1ns = v1m.getTargetNamespace();
    URI v2ns = v2m.getTargetNamespace();
    int result = v1ns.compareTo(v2ns);
    if (result != 0) return result;

    String v1ln = v1m.getName();
    String v2ln = v2m.getName();
    return v1ln.compareTo(v2ln);
  }
  /**
   * Do a comparison of the dimensions themselves. This covers the dimensions but not the values of
   * those dimensions.
   *
   * @param v1 The first typed dimension value.
   * @param v2 The second typed dimension value.
   * @return a negative integer, zero, or a positive integer as the first argument is less than,
   *     equal to, or greater than the second.
   * @throws XBRLException
   */
  protected int compareDimensions(DimensionValue v1, DimensionValue v2) throws XBRLException {

    if (v1.isTypedDimensionValue() && v2.isExplicitDimensionValue()) return 1;

    if (v1.isExplicitDimensionValue() && v2.isTypedDimensionValue()) return -1;

    Dimension v1d = v1.getDimension();
    Dimension v2d = v2.getDimension();

    URI d1ns = v1d.getTargetNamespace();
    URI d2ns = v2d.getTargetNamespace();
    int result = d1ns.compareTo(d2ns);
    if (result != 0) return result;

    String d1ln = v1d.getName();
    String d2ln = v2d.getName();
    return d1ln.compareTo(d2ln);
  }
  /**
   * Get the source part URI from a specified relationships part.
   *
   * @param relationshipPartUri The relationship part use to retrieve the source part.
   * @return The source part URI from the specified relationships part.
   */
  public static URI getSourcePartUriFromRelationshipPartUri(URI relationshipPartUri) {
    if (relationshipPartUri == null) throw new IllegalArgumentException("Must not be null");

    if (!isRelationshipPartURI(relationshipPartUri))
      throw new IllegalArgumentException("Must be a relationship part");

    if (relationshipPartUri.compareTo(PACKAGE_RELATIONSHIPS_ROOT_URI) == 0) return PACKAGE_ROOT_URI;

    String filename = relationshipPartUri.getPath();
    String filenameWithoutExtension = getFilenameWithoutExtension(relationshipPartUri);
    filename =
        filename.substring(
            0,
            ((filename.length() - filenameWithoutExtension.length())
                - RELATIONSHIP_PART_EXTENSION_NAME.length()));
    filename =
        filename.substring(0, filename.length() - RELATIONSHIP_PART_SEGMENT_NAME.length() - 1);
    filename = combine(filename, filenameWithoutExtension);
    return getURIFromPath(filename);
  }
Esempio n. 5
0
 @Override
 public int compareTo(TachyonURI other) {
   return mUri.compareTo(other.mUri);
 }