Get the reader schema based on the given type and writer schema.

@param <E> The entity type
@param type The Java class of the entity type
@param schema The {@link Schema} for the entity
@return The reader schema based on the given type and writer schema
7826
public static <E> Schema getReaderSchema(Class<E> type, Schema schema) {
    Schema readerSchema = schema;
    GenericData dataModel = getDataModelForType(type);

    if (dataModel instanceof SpecificData) {
      readerSchema = ((SpecificData)dataModel).getSchema(type);
    }

    return readerSchema;
  }
106940
public static <T> List<T> parseListFrom(InputStream in, Schema<T> schema)
            throws IOException
    {
        return parseListFrom(in, schema, DEFAULT_INPUT_FACTORY);
    }
386210
public <T> boolean registerPojo(Class<T> typeClass, Schema<T> schema)
    {
        assert typeClass != null && schema != null;
        
        final HasSchema<?> last = pojoMapping.putIfAbsent(typeClass.getName(), 
                new Registered<T>(schema));
        
        return last == null || (last instanceof Registered<?> && 
                ((Registered<?>)last).schema == schema);
    }
538241
public static <T> Schema<T> getSchema(Class<T> typeClass,
            IdStrategy strategy)
    {
        return strategy.getSchemaWrapper(typeClass, true).getSchema();
    }
314703
public String getRecordSchema() throws IOException {
        Schema schema = getInputPathAvroSchema();
        String recSchema = schema.toString();
        return recSchema;
    }
787659
private static Schema getSchema(InputStream schemaStream) throws SAXException {
        Schema result;
        synchronized(SCHEMA_FACTORY){
            result = SCHEMA_FACTORY.newSchema(new StreamSource(schemaStream));
        }
        return result;
    }
596080
public static org.apache.arrow.vector.types.pojo.Schema toArrowSchema(Schema schema) {
        List<Field> fields = new ArrayList<>(schema.numColumns());
        for(int i = 0; i < schema.numColumns(); i++) {
            fields.add(getFieldForColumn(schema.getName(i),schema.getType(i)));
        }

        return new org.apache.arrow.vector.types.pojo.Schema(fields);
    }
930292
static TypeInformation schemaToTypeInfo(TypeDescription schema) {
		switch (schema.getCategory()) {
			case BOOLEAN:
				return BasicTypeInfo.BOOLEAN_TYPE_INFO;
			case BYTE:
				return BasicTypeInfo.BYTE_TYPE_INFO;
			case SHORT:
				return BasicTypeInfo.SHORT_TYPE_INFO;
			case INT:
				return BasicTypeInfo.INT_TYPE_INFO;
			case LONG:
				return BasicTypeInfo.LONG_TYPE_INFO;
			case FLOAT:
				return BasicTypeInfo.FLOAT_TYPE_INFO;
			case DOUBLE:
				return BasicTypeInfo.DOUBLE_TYPE_INFO;
			case DECIMAL:
				return BasicTypeInfo.BIG_DEC_TYPE_INFO;
			case STRING:
			case CHAR:
			case VARCHAR:
				return BasicTypeInfo.STRING_TYPE_INFO;
			case DATE:
				return SqlTimeTypeInfo.DATE;
			case TIMESTAMP:
				return SqlTimeTypeInfo.TIMESTAMP;
			case BINARY:
				return PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO;
			case STRUCT:
				List<TypeDescription> fieldSchemas = schema.getChildren();
				TypeInformation[] fieldTypes = new TypeInformation[fieldSchemas.size()];
				for (int i = 0; i < fieldSchemas.size(); i++) {
					fieldTypes[i] = schemaToTypeInfo(fieldSchemas.get(i));
				}
				String[] fieldNames = schema.getFieldNames().toArray(new String[]{});
				return new RowTypeInfo(fieldTypes, fieldNames);
			case LIST:
				TypeDescription elementSchema = schema.getChildren().get(0);
				TypeInformation<?> elementType = schemaToTypeInfo(elementSchema);
				// arrays of primitive types are handled as object arrays to support null values
				return ObjectArrayTypeInfo.getInfoFor(elementType);
			case MAP:
				TypeDescription keySchema = schema.getChildren().get(0);
				TypeDescription valSchema = schema.getChildren().get(1);
				TypeInformation<?> keyType = schemaToTypeInfo(keySchema);
				TypeInformation<?> valType = schemaToTypeInfo(valSchema);
				return new MapTypeInfo<>(keyType, valType);
			case UNION:
				throw new UnsupportedOperationException("UNION type is not supported yet.");
			default:
				throw new IllegalArgumentException("Unknown type " + schema);
		}
	}
239563
@Override
	public SchemaDefinition readSchema() {

		SchemaRepresentation representation = template
				.execute(solrClient -> new SchemaRequest().process(solrClient, collection).getSchemaRepresentation());

		SchemaDefinition sd = new SchemaDefinition(collection);

		for (Map<String, Object> fieldValueMap : representation.getFields()) {
			sd.addFieldDefinition(FieldDefinition.fromMap(fieldValueMap));
		}
		for (Map<String, Object> fieldValueMap : representation.getCopyFields()) {

			CopyFieldDefinition cf = CopyFieldDefinition.fromMap(fieldValueMap);
			sd.addCopyField(cf);

			if (sd.getFieldDefinition(cf.getSource()) != null) {
				sd.getFieldDefinition(cf.getSource()).setCopyFields(cf.getDestination());
			}
		}

		return sd;
	}
493584
public Schema loadSchema(String schema) {
    try {
      JSONObject rawSchema = new JSONObject(new JSONTokener(schema));
      return SchemaLoader.load(rawSchema);
    } catch (JSONException | SchemaException e) {
      throw new InvalidJsonSchemaException(e);
    }
  }
919090
public JSONObject parseJSONSchema(JSONObject schema) throws Exception {
        JSONObject json = new JSONObject();
        String name = "";
        JSONObject properties = schema;

        // Check if key 'properties' exists
        if (schema.has("properties")) {
            // Obtain properties
            properties = schema.getJSONObject("properties");
        }

        // Obtain all keys and iterate through them
        Iterator<?> keys = properties.keys();
        while (keys.hasNext()) {
            // Obtain key
            String key = keys.next().toString();
            // Obtain value of key
            JSONObject element = properties.getJSONObject(key);
            // Check if value contain properties
            // If it DOESN'T CONTAIN properties
            if (!element.has("properties")) {
                // Check if it has default value
                if (element.has("default")) {
                    // Add element with the default value assigned
                    json.put(key, element.get("default"));
                // If it doesn't have default value, we assign a default value depending on the type
                } else {
                    switch (element.getString("type")) {
                        case "string":
                            json.put(key, "");
                            break;
                        case "boolean":
                            json.put(key, false);
                            break;
                        case "number": case "integer":
                            json.put(key, 0);
                            break;
                        default:
                            Assertions.fail("type not expected");
                    }
                }
            // If it CONTAINS properties
            } else {
                // Recursive call, keep evaluating json
                json.put(key, parseJSONSchema(element));
            }
        }

        return json;
    }
808472
def get_schema_from_type(resource_type):
    
    for cls_name, cls in class_registry._registry.items():
        try:
            if cls[0].opts.type_ == resource_type:
                return cls[0]
        except Exception:
            pass

    raise Exception("Couldn't find schema for type: {}".format(resource_type))
813698
public static <T> List<T> parseListFrom(final InputStream in, final Schema<T> schema) 
    throws IOException
    {
        int size = in.read();
        if(size == -1)
            return Collections.emptyList();
        
        if(size > 0x7f)
            size = CodedInput.readRawVarint32(in, size);
        
        final ArrayList<T> list = new ArrayList<T>(size);
        final CodedInput input = new CodedInput(in, true);
        for(int i = 0; i < size; i++)
        {
            final T message = schema.newMessage();
            list.add(message);
            schema.mergeFrom(input, message);
            input.checkLastTagWas(0);
        }
        
        assert in.read() == -1;

        return list;
    }
523632
public static function typeFromAST(Schema $schema, $inputType)
    {
        if ($inputType instanceof ListType) {
            $innerType = self::typeFromAST($schema, $inputType->get('type'));
            return $innerType ? new ListModifier($innerType) : NULL;
        }

        if ($inputType instanceof NonNullType) {
            $innerType = self::typeFromAST($schema, $inputType->get('type'));
            return $innerType ? new NonNullModifier($innerType) : NULL;
        }

        if (!($inputType instanceof NamedType)) {
            throw new \LogicException('Must be a type name.');
        }

        return $schema->getType($inputType->get('name')->get('value'));
    }
141744
@Override
    public Schema schema() {
        LOG.ok("Schema retrieving");

        final Provisioning provisioning = connection.getProvisioning();

        if (provisioning == null) {
            throw new IllegalStateException("Web Service client not found");
        }

        if (wsAttributes != null) {
            wsAttributes.clear();
        }
        wsAttributes = new HashMap<String, WSAttribute>();

        final Set<AttributeInfo> attributes = new HashSet<AttributeInfo>();
        final List<WSAttribute> wsAttrs = provisioning.schema();
        for (WSAttribute attribute : wsAttrs) {

            wsAttributes.put(getAttributeName(attribute), attribute);

            if (LOG.isOk()) {
                LOG.ok("\nAttribute: "
                        + "\n\tName: " + attribute.getName()
                        + "\n\tType: " + attribute.getType()
                        + "\n\tIsKey: " + attribute.isKey()
                        + "\n\tIsPassword: " + attribute.isPassword()
                        + "\n\tIsNullable: " + attribute.isNullable());
            }

            try {
                attributes.add(buildAttribute(attribute));
            } catch (IllegalArgumentException ila) {

                LOG.error("Invalid attribute " + attribute.getName(), ila);
            }
        }

        final SchemaBuilder schemaBld = new SchemaBuilder(getClass());

        final ObjectClassInfoBuilder objectclassInfoBuilder = new ObjectClassInfoBuilder();
        objectclassInfoBuilder.setType(ObjectClass.ACCOUNT_NAME);
        objectclassInfoBuilder.addAllAttributeInfo(attributes);

        final ObjectClassInfo objectclassInfo = objectclassInfoBuilder.build();
        schemaBld.defineObjectClass(objectclassInfo);

        /*
         * Note: AuthenticateOp, and all the 'SPIOperation'-s are by default added by Reflection API to the Schema.
         *
         * See for details: FrameworkUtil.getDefaultSupportedOperations() ReflectionUtil.getAllInterfaces(connector); is
         * the line that *does* acquire the implemented interfaces by the connector class.
         */
        if (!provisioning.isAuthenticationSupported()) {
            LOG.ok("Authentication is not supported.");

            schemaBld.removeSupportedObjectClass(AuthenticateOp.class, objectclassInfo);
        }

        if (!provisioning.isSyncSupported()) {
            LOG.ok("Synchronization is not supported.");

            schemaBld.removeSupportedObjectClass(SyncOp.class, objectclassInfo);
        }

        schema = schemaBld.build();
        return schema;
    }
803457
public static JsonSchema buildBaseSchema(Type type) {
    JsonObject jsonObject = new JsonObject();
    JsonObject dataType = new JsonObject();
    jsonObject.addProperty(COLUMN_NAME_KEY, DEFAULT_RECORD_COLUMN_NAME);
    dataType.addProperty(TYPE_KEY, type.toString());
    jsonObject.add(DATA_TYPE_KEY, dataType);
    return new JsonSchema(jsonObject);
  }
1295033
public static String serialize(StreamSchema schema) {
    StringBuilder builder = new StringBuilder();
    int fieldCount = 1;
    for (GDATField field : schema.getFields()) {
      builder.append(field.getType().getTypeName()).append(" ").append(field.getName()).append(" get_gdat_")
        .append(field.getType().getTypeName()).append("_pos").append(fieldCount);
      builder.append(field.getSlidingWindowType().getAttribute());
      builder.append(";").append(Constants.NEWLINE);
      fieldCount++;
    }
    return builder.toString();
  }