示例#1
0
 @Test
 public void testNullNamespaceAlias() throws Exception {
   Schema s = Schema.parse("{\"type\":\"record\",\"name\":\"Z\",\"fields\":[]}");
   Schema t =
       Schema.parse(
           "{\"type\":\"record\",\"name\":\"x.Y\",\"aliases\":[\".Z\"]," + "\"fields\":[]}");
   Schema u = Schema.applyAliases(s, t);
   assertEquals("x.Y", u.getFullName());
 }
示例#2
0
  public boolean Validate(ParserSession PS, Schema ParentSchema, int pos) {
    int Errs = PS.getErrorCount();
    _ParentSchema = ParentSchema;
    LOG.debug("  Validating Enumeration " + _Name + ".");

    // Mandatories
    if (TextUtil.isNullOrEmpty(_Name) == true)
      return PS.AddError(
          "Schema '"
              + _ParentSchema.getFullName()
              + "' is declaring an enumeration '"
              + _Name
              + "' without a name.");
    if (ValidationHelper.isValidIdentifier(_Name) == false)
      return PS.AddError(
          "Schema '"
              + _ParentSchema.getFullName()
              + "' is declaring an enumeration '"
              + _Name
              + "' with a name which is not valid. "
              + ValidationHelper._ValidIdentifierMessage);
    if (TextUtil.isNullOrEmpty(_Description) == true)
      return PS.AddError(
          "Schema '"
              + _ParentSchema.getFullName()
              + "' is declaring an enumeration '"
              + _Name
              + "' without a description.");
    if (_Id == null)
      return PS.AddError(
          "Schema '"
              + _ParentSchema.getFullName()
              + "' is declaring an enumeration '"
              + _Name
              + "' without an Id type.");
    if (_Value == null)
      return PS.AddError(
          "Schema '"
              + _ParentSchema.getFullName()
              + "' is declaring an enumeration '"
              + _Name
              + "' without a Value type.");

    Object O = new Object();
    O._FST = FrameworkSourcedType.ENUMERATION;
    O._Name = _Name;
    O._Description = _Description;

    Column C =
        new Column(
            "id",
            _Id._TypeStr,
            _Id._Size,
            false,
            ColumnMode.NORMAL,
            true,
            null,
            "The id for this enumeration.");
    O._Columns.add(C);

    C =
        new Column(
            "value",
            _Value._TypeStr,
            _Value._Size,
            false,
            ColumnMode.NORMAL,
            true,
            null,
            "The value for this enumeration.");
    O._Columns.add(C);

    C =
        new Column(
            "label",
            ColumnType.STRING.toString(),
            254,
            false,
            ColumnMode.NORMAL,
            false,
            ProtectionType.ABSOLUTE,
            "The label for this enumeration.");
    O._Columns.add(C);

    C =
        new Column(
            "deactivated",
            ColumnType.DATETIME.toString(),
            null,
            true,
            ColumnMode.NORMAL,
            false,
            null,
            "The label for this enumeration.");
    C._FrameworkManaged = true;
    O._Columns.add(C);

    PrimaryKey PK = new PrimaryKey();
    PK._Columns = new String[] {"id"};
    O._PrimaryKey = PK;

    O._Indices = new ArrayList<Index>();
    Index I = new Index();
    I._Name = "Id";
    I._Columns = new String[] {"id"};
    I._Db = true;
    O._Indices.add(I);

    I = new Index();
    I._Name = "Value";
    I._Columns = new String[] {"value"};
    I._Db = true;
    O._Indices.add(I);

    I = new Index();
    I._Name = "All";
    I._OrderBy = new String[] {"id"};
    I._Db = false;
    O._Indices.add(I);

    _ParentSchema._Objects.add(pos, O);

    return Errs == PS.getErrorCount();
  }