Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.opensearch.javasdk.object;
  
  import java.util.List;
  
schema的一个表

Author(s):
童昭
CreateDate:
2013-12-18
 
 public class SchemaTable {
 
     private String tableName;// schema的表的名称
     private boolean masterTable;// 是否是主表
 
     // schema的属性
     private List<SchemaTableFieldfieldList = new ArrayList<SchemaTableField>();
 
     public void setTableName(String tableName) {
         this. = tableName;
     }
 
     public String getTableName() {
         return ;
     }

    
add a field of schemaTable

Parameters:
schemaTableField
 
     public void addField(SchemaTableField schemaTableField) {
         if (schemaTableField == null) {
             return;
         }
         if (schemaTableField.isPrimarykey()) {
             schemaTableField.setSearch(true);
             schemaTableField.addIndex(schemaTableField.getFieldName());
             if (schemaTableField.getType().getType().equals(..getType())) {
                 // 如果是文字类型的
                 schemaTableField.setFilter(false);
                 schemaTableField.setAggregate(false);
             } else if (schemaTableField.getType().getType().equals(..getType())) {
                 schemaTableField.setFilter(false);
             }
         }
 
         // 检查TEXT类型的属性信息
         if (schemaTableField.getType().getType().equals(..getType())) {
             schemaTableField.setAggregate(false);
             schemaTableField.setFilter(false);
             if (schemaTableField.getIndexList().size() == 0) {
                 schemaTableField.addIndex("default");
             } else {
                 for (String indexStr : schemaTableField.getIndexList()) {
                     if (!indexStr.matches("^[_a-zA-Z][a-zA-Z0-9_]*")) {
                         return;// 不满足要求
                     }
                 }
             }
         }
 
         // 检查STRING类型的属性信息
         if (schemaTableField.getType().getType().equals(..getType())) {
             if (!schemaTableField.isMulti()) {
                 schemaTableField.setAggregate(false);
             }
             schemaTableField.setFilter(false);
             if (schemaTableField.getIndexList().size() == 0) {
                 schemaTableField.addIndex(schemaTableField.getFieldName());
             } else {
                 for (String indexStr : schemaTableField.getIndexList()) {
                     if (!indexStr.matches("^[_a-zA-Z][a-zA-Z0-9_]*")) {
                         return;// 不满足要求
                     }
                 }
             }
         }
 
         // 检查数字类型的属性信息
         if (schemaTableField.getType().getType().equals(..getType())
                 || schemaTableField.getType().getType().equals(..getType())
                 || schemaTableField.getType().getBigType().equals(..getBigType())) {
             schemaTableField.addIndex(schemaTableField.getFieldName());
             if (!schemaTableField.isMulti()) {
                 schemaTableField.setFilter(false);
             }
         }
 
         this..add(schemaTableField);
     }
 
     public List<SchemaTableFieldgetFieldList() {
         return ;
     }
 
    public void setFieldList(List<SchemaTableFieldfieldList) {
        this. = fieldList;
    }
    public boolean isMasterTable() {
        return ;
    }
    public void setMasterTable(boolean masterTable) {
        this. = masterTable;
    }
New to GrepCode? Check out our FAQ X