/** * Return the {@link DataSchema}'s fully qualified name. * This name is used in the over-the-wire protocol. * * @return the {@link DataSchema}'s fully qualified name. */ @Override public String getFullName() { return _name.getFullName(); }
private void setCurrentImports(ImportDeclarationsContext imports) { Map<String, Name> importsBySimpleName = new HashMap<String, Name>(); for (ImportDeclarationContext importDecl: imports.importDeclaration()) { String importedFullname = importDecl.type.value; Name importedName = new Name(importedFullname); String importedSimpleName = importedName.getName(); if (importsBySimpleName.containsKey(importedSimpleName)) { startErrorMessage(importDecl) .append("'") .append(importsBySimpleName.get(importedSimpleName)) .append("' is already defined in an import.") .append("\n"); } importsBySimpleName.put(importedSimpleName, importedName); } this.currentImports = importsBySimpleName; } }
/** * Sets this {@link Name} with the specified name and namespace, * and append errors in the specified {@link StringBuilder}. * * @param name provides the name. * @param namespace provides the namespace. * @param errorMessageBuilder provides the {@link StringBuilder} to append * error messages to. */ public boolean setName(String name, String namespace, StringBuilder errorMessageBuilder) { boolean ok = true; _isEmpty = false; _name = name; _namespace = namespace; _fullName = namespace.isEmpty() ? _name : _namespace + "." + _name; if (isValidName(name) == false) { errorMessageBuilder.append("\"").append(name).append("\" is an invalid name.\n"); ok = false; } if (isValidNamespace(namespace) == false) { errorMessageBuilder.append("\"").append(namespace).append("\" is an invalid namespace.\n"); ok = false; } _hasError |= !ok; return ok; }
Name n = new Name(); if (name != null && name != SUBSTITUTE_FOR_REQUIRED_STRING) if (Name.isFullName(name)) n.setName(name, startCalleeMessageBuilder()); appendCalleeMessage(name); n.setName(name, namespace, startCalleeMessageBuilder()); appendCalleeMessage(name);
Name recordName = new Name(parentRecordFullName + unionFieldName, errorMessageBuilder); recordName.getFullName(), memberKeys, errorMessageBuilder); discriminatorField.setRecord(recordDataSchema); fields.add(discriminatorField);
Name name = new Name(namedSchema.getFullName()); if (name.getNamespace().equals(_namespace)) importsAcc.put(name.getName(), name); importsAcc.putIfAbsent(name.getName(), name);
public String computeFullName(String name) { String fullname; if (DataSchemaUtil.typeStringToPrimitiveDataSchema(name) != null) { fullname = name; } else if (Name.isFullName(name)) { fullname = name; // already a fullname } else if (currentImports.containsKey(name)) { // imported names are higher precedence than names in current namespace fullname = currentImports.get(name).getFullName(); } else if (getCurrentNamespace().isEmpty()) { fullname = name; } else { fullname = getCurrentNamespace() + "." + name; // assumed to be in current namespace } return fullname; }
String fullName = name.getFullName(); if (name.isEmpty()) DataSchema found = getResolver().existingDataSchema(name.getFullName()); if (found != null) startErrorMessage(name).append("\"").append(name.getFullName()).append("\" already defined as " + found + ".\n"); ok = false;
if (!importName.getNamespace().equals(_namespace)) writeLine("import " + escapeIdentifier(importName.getFullName()));
/** * Return the {@link DataSchema}'s unqualified name. * * @return the {@link DataSchema}'s unqualified name. */ @Override public String getName() { return _name.getName(); }
/** * Compute the full name from a name. * * If the name identifies a primitive type, return the name. * If the name is unqualified, the full name is computed by * pre-pending the current namespace and "." to the input name. * If the name is a full name, i.e. it contains a ".", then * return the name. * * @param name as input to compute the full name. * @return the computed full name. */ public String computeFullName(String name) { String fullname; DataSchema schema = DataSchemaUtil.typeStringToPrimitiveDataSchema(name); if (schema != null) { fullname = name; } else if (Name.isFullName(name) || getCurrentNamespace().isEmpty()) { fullname = name; } else { fullname = getCurrentNamespace() + "." + name; } return fullname; }
ok = false; else if (Name.isValidNamespace((String) namespace) == false)
@Override public boolean equals(Object object) { if (object != null && object instanceof NamedDataSchema) { // Location is not used for comparison. // Equal if the schema is the same. NamedDataSchema other = (NamedDataSchema) object; return super.equals(object) && _name.equals(other._name) && _doc.equals(other._doc) && _aliases.equals(other._aliases); } return false; }
@Override public String computeFullName(String name) { String fullname; DataSchema schema = DataSchemaUtil.typeStringToPrimitiveDataSchema(name); if (schema != null) { fullname = name; } else if (Name.isFullName(name) || getCurrentNamespace().isEmpty()) { fullname = name; // already a fullname } else if (currentImports.containsKey(name)) { // imported names are higher precedence than names in current namespace fullname = currentImports.get(name).getFullName(); } else { fullname = getCurrentNamespace() + "." + name; // assumed to be in current namespace } return fullname; }
private static DataSchemaResolver createResolverFromSnapshot(AbstractSnapshot snapshot, String resolverPath) { final DataSchemaResolver resolver = CompatibilityUtil.getDataSchemaResolver(resolverPath); for (Map.Entry<String, NamedDataSchema> entry : snapshot.getModels().entrySet()) { Name name = new Name(entry.getKey()); NamedDataSchema schema = entry.getValue(); resolver.bindNameToSchema(name, schema, DataSchemaLocation.NO_LOCATION); } return resolver; }
private void setCurrentImports(ImportDeclarationsContext imports) { Map<String, Name> importsBySimpleName = new HashMap<>(); for (ImportDeclarationContext importDecl: imports.importDeclaration()) { String importedFullname = importDecl.type.value; Name importedName = new Name(importedFullname); String importedSimpleName = importedName.getName(); if (importsBySimpleName.containsKey(importedSimpleName)) { startErrorMessage(importDecl) .append("'") .append(importsBySimpleName.get(importedSimpleName)) .append("' is already defined in an import.") .append(NEWLINE); } importsBySimpleName.put(importedSimpleName, importedName); } this.currentImports = importsBySimpleName; }
/** * Return the fullname. * * @return the fullname. */ @Override public String toString() { return getFullName(); }
private Name toName(String name) { return new Name(name, getCurrentNamespace(), errorMessageBuilder()); }
@Override public int compareTo(Name o) { return this.getFullName().compareTo(o.getFullName()); }