@Test public void lindenSchemaBuilderTest() throws Exception { String schemaPath = TestLindenSchemaBuilder.class.getResource("/test_builder_schema.xml").getPath(); LindenSchema schema = LindenSchemaBuilder.build(new File(schemaPath)); Assert.assertEquals("aid", schema.getId()); Assert.assertEquals(9, schema.getFieldsSize()); Assert.assertTrue(schema.getFields().get(0).isSnippet()); Assert.assertTrue(schema.getFields().get(0).isOmitFreqs()); Assert.assertTrue(schema.getFields().get(1).isIndexed()); Assert.assertFalse(schema.getFields().get(6).isIndexed()); Assert.assertEquals(LindenType.STRING, schema.getFields().get(5).getType()); Assert.assertEquals(LindenType.FACET, schema.getFields().get(8).getType()); }
public static LindenSchema build(File schemaFile) throws Exception { Preconditions.checkNotNull(schemaFile); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document dom = db.parse(schemaFile); dom.getDocumentElement().normalize(); NodeList table = dom.getElementsByTagName(TABLE); Node colNode = table.item(0); LindenSchema lindenSchema = new LindenSchema(); lindenSchema.setId(colNode.getAttributes().getNamedItem(TABLE_ID).getNodeValue()); NodeList colList = dom.getElementsByTagName(TABLE_COLUMN); for (int i = 0; i < colList.getLength(); ++i) { Element element = (Element) colList.item(i); LindenFieldSchema fieldSchema = parseFiled(element); verifyFieldSchema(fieldSchema); lindenSchema.addToFields(fieldSchema); } return lindenSchema; }
LindenSchemaBuilder { public static LindenSchema build(File schemaFile) throws Exception { Preconditions.checkNotNull(schemaFile); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document dom = db.parse(schemaFile); dom.getDocumentElement().normalize(); NodeList table = dom.getElementsByTagName(TABLE); Node colNode = table.item(0); LindenSchema lindenSchema = new LindenSchema(); lindenSchema.setId(colNode.getAttributes().getNamedItem(TABLE_ID).getNodeValue()); NodeList colList = dom.getElementsByTagName(TABLE_COLUMN); for (int i = 0; i < colList.getLength(); ++i) { Element element = (Element) colList.item(i); LindenFieldSchema fieldSchema = parseFiled(element); verifyFieldSchema(fieldSchema); lindenSchema.addToFields(fieldSchema); } return lindenSchema; } }
LindenSchemaBuilder { public static LindenSchema build(File schemaFile) throws Exception { Preconditions.checkNotNull(schemaFile); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document dom = db.parse(schemaFile); dom.getDocumentElement().normalize(); NodeList table = dom.getElementsByTagName(TABLE); Node colNode = table.item(0); LindenSchema lindenSchema = new LindenSchema(); lindenSchema.setId(colNode.getAttributes().getNamedItem(TABLE_ID).getNodeValue()); NodeList colList = dom.getElementsByTagName(TABLE_COLUMN); for (int i = 0; i < colList.getLength(); ++i) { Element element = (Element) colList.item(i); LindenFieldSchema fieldSchema = parseFiled(element); verifyFieldSchema(fieldSchema); lindenSchema.addToFields(fieldSchema); } return lindenSchema; }  }
LindenSchemaBuilder { public static LindenSchema build(File schemaFile) throws Exception { Preconditions.checkNotNull(schemaFile); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document dom = db.parse(schemaFile); dom.getDocumentElement().normalize(); NodeList table = dom.getElementsByTagName(TABLE); Node colNode = table.item(0); LindenSchema lindenSchema = new LindenSchema(); lindenSchema.setId(colNode.getAttributes().getNamedItem(TABLE_ID).getNodeValue()); NodeList colList = dom.getElementsByTagName(TABLE_COLUMN); for (int i = 0; i < colList.getLength(); ++i) { Element element = (Element) colList.item(i); LindenFieldSchema fieldSchema = parseFiled(element); verifyFieldSchema(fieldSchema); lindenSchema.addToFields(fieldSchema); } return lindenSchema; }  static LindenSchema build(File schemaFile); static void verifyFieldSchema(LindenFieldSchema schema); }
LindenSchemaBuilder { public static LindenSchema build(File schemaFile) throws Exception { Preconditions.checkNotNull(schemaFile); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document dom = db.parse(schemaFile); dom.getDocumentElement().normalize(); NodeList table = dom.getElementsByTagName(TABLE); Node colNode = table.item(0); LindenSchema lindenSchema = new LindenSchema(); lindenSchema.setId(colNode.getAttributes().getNamedItem(TABLE_ID).getNodeValue()); NodeList colList = dom.getElementsByTagName(TABLE_COLUMN); for (int i = 0; i < colList.getLength(); ++i) { Element element = (Element) colList.item(i); LindenFieldSchema fieldSchema = parseFiled(element); verifyFieldSchema(fieldSchema); lindenSchema.addToFields(fieldSchema); } return lindenSchema; }  static LindenSchema build(File schemaFile); static void verifyFieldSchema(LindenFieldSchema schema); static final String TABLE; static final String TABLE_ID; static final String TABLE_COLUMN; static final String NAME; static final String TYPE; static final String STORE; static final String INDEX; static final String TOKENIZED; static final String OMITNORMS; static final String OMITFREQS; static final String SNIPPET; static final String DOCVALUES; static final String MULTI; static final String TEXT; static final String YES; static final String NO; static final String INT; }