当前位置: 首页>>代码示例>>Java>>正文


Java TType.STRING属性代码示例

本文整理汇总了Java中org.apache.thrift.protocol.TType.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java TType.STRING属性的具体用法?Java TType.STRING怎么用?Java TType.STRING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.thrift.protocol.TType的用法示例。


在下文中一共展示了TType.STRING属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

/**
 * 读取操作
 */
@Override
public void read(TProtocol iprot) throws TException {
	if (!"org.apache.thrift.scheme.StandardScheme".equals(iprot.getScheme().getName()))
		throw new TApplicationException("Service scheme must be 'org.apache.thrift.scheme.StandardScheme' !");
	TField schemeField;
	iprot.readStructBegin();
	while (Boolean.TRUE) {
		schemeField = iprot.readFieldBegin();
		if (schemeField.type == TType.STOP)
			break;
		if (schemeField.type == TType.STRING)
			str = iprot.readString();
		else
			throw new TApplicationException("field type must be 'String' !");
		iprot.readFieldEnd();
	}
	iprot.readStructEnd();
}
 
开发者ID:venwyhk,项目名称:ikasoa,代码行数:21,代码来源:AbstractThriftBase.java

示例2: setTraceHeader

public void setTraceHeader(ThriftHeader headerKey, Object value) throws TException {
    byte headerType = headerKey.getType();
    if (headerType == TType.STRING) {
        // skipped Strings are read as byte buffer.
        // see org.apache.thrift.protocol.TProtocolUtil.skip(TProtocol, byte, int)
        this.thriftHeaders.put(headerKey, byteBufferToString((ByteBuffer)value));
    } else if (headerType == TType.I64) {
        this.thriftHeaders.put(headerKey, (Long)value);
    } else if (headerType == TType.I16) {
        this.thriftHeaders.put(headerKey, (Short)value);
    } else if (headerType == TType.BOOL) {
        this.thriftHeaders.put(headerKey, (Boolean)value);
    } else {
        throw new TProtocolException("Invalid pinpoint header type - " + headerType);
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:16,代码来源:ThriftRequestProperty.java

示例3: writeTraceHeader

public void writeTraceHeader(ThriftHeader headerKey, TProtocol oprot) throws TException {
    Object headerValue = this.thriftHeaders.get(headerKey);
    if (headerValue == null) {
        return;
    }
    byte headerType = headerKey.getType();
    TField traceField = new TField(headerKey.name(), headerKey.getType(), headerKey.getId());
    oprot.writeFieldBegin(traceField);
    try {
        if (headerType == TType.STRING) {
            // these will be read as byte buffer although it's probably safe to just use writeString here.
            // see org.apache.thrift.protocol.TProtocolUtil.skip(TProtocol, byte, int)
            oprot.writeBinary(stringToByteBuffer((String)headerValue));
        } else if (headerType == TType.I64) {
            oprot.writeI64((Long)headerValue);
        } else if (headerType == TType.I16) {
            oprot.writeI16((Short)headerValue);
        } else if (headerType == TType.BOOL) {
            oprot.writeBool((Boolean)headerValue);
        } else {
            throw new TProtocolException("Invalid pinpoint header type - " + headerType);
        }
    } finally {
        oprot.writeFieldEnd();
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:26,代码来源:ThriftRequestProperty.java

示例4: write

public void write(TProtocol oprot) throws TException {
  TStruct struct = new TStruct("TApplicationException");
  TField field = new TField();
  oprot.writeStructBegin(struct);
  if (getMessage() != null) {
    field.name = "message";
    field.type = TType.STRING;
    field.id = 1;
    oprot.writeFieldBegin(field);
    oprot.writeString(getMessage());
    oprot.writeFieldEnd();
  }
  field.name = "type";
  field.type = TType.I32;
  field.id = 2;
  oprot.writeFieldBegin(field);
  oprot.writeI32(type_);
  oprot.writeFieldEnd();
  oprot.writeFieldStop();
  oprot.writeStructEnd();

}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:22,代码来源:TApplicationException.java

示例5: read

public static TApplicationException read(TProtocol iprot) throws TException {
  TField field;
  iprot.readStructBegin();

  String message = null;
  int type = UNKNOWN;

  while (true) {
    field = iprot.readFieldBegin();
    if (field.type == TType.STOP) {
      break;
    }
    switch (field.id) {
    case 1:
      if (field.type == TType.STRING) {
        message = iprot.readString();
      } else {
        TProtocolUtil.skip(iprot, field.type);
      }
      break;
    case 2:
      if (field.type == TType.I32) {
        type = iprot.readI32();
      } else {
        TProtocolUtil.skip(iprot, field.type);
      }
      break;
    default:
      TProtocolUtil.skip(iprot, field.type);
      break;
    }
    iprot.readFieldEnd();
  }
  iprot.readStructEnd();

  return new TApplicationException(type, message);
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:37,代码来源:TApplicationException.java

示例6: stringToTypeId

private byte stringToTypeId(String fieldType) throws TProtocolException {
    switch (fieldType) {
        case "bool":
            return TType.BOOL;
        case "i8":
            return TType.BYTE;
        case "i16":
            return TType.I16;
        case "i32":
            return TType.I32;
        case "i64":
            return TType.I64;
        case "double":
            return TType.DOUBLE;
        case "string":
            return TType.STRING;
        case "struct":
        case "union":
        case "exception":
            return TType.STRUCT;
        case "map":
            return TType.MAP;
        case "set":
            return TType.SET;
        case "list":
            return TType.LIST;
        default:
            throw new TProtocolException(TProtocolException.INVALID_DATA,
                    new Exception("Unknown type identifier " + fieldType));
    }
}
 
开发者ID:degupta,项目名称:human_readable_json_protocol,代码行数:31,代码来源:HumanReadableJsonProtocol.java

示例7: read

/**
 * Reads a {@link TApplicationException} from the specified {@link TProtocol}.
 *
 * <p>Note: This has been copied from {@link TApplicationException#read(TProtocol)} due to API differences
 * between libthrift 0.9.x and 0.10.x.
 */
public static TApplicationException read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();

    String message = null;
    int type = TApplicationException.UNKNOWN;

    while (true) {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) {
            break;
        }
        switch (field.id) {
            case 1:
                if (field.type == TType.STRING) {
                    message = iprot.readString();
                } else {
                    TProtocolUtil.skip(iprot, field.type);
                }
                break;
            case 2:
                if (field.type == TType.I32) {
                    type = iprot.readI32();
                } else {
                    TProtocolUtil.skip(iprot, field.type);
                }
                break;
            default:
                TProtocolUtil.skip(iprot, field.type);
                break;
        }
        iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    return new TApplicationException(type, message);
}
 
开发者ID:line,项目名称:armeria,代码行数:43,代码来源:TApplicationExceptions.java

示例8: readMapBegin

public TMap readMapBegin() throws TException {
	StructContext context = (StructContext) peekContext();
	if(context.fieldsStack.isEmpty()) {
     return EMPTY_MAP;
   }
   String fieldName = context.fieldsStack.peek();

   MapContext mapContext = new MapContext(TType.VOID);
   BasicDBObject dbMap = (BasicDBObject) context.dbObject.get(fieldName);

   mapContext.setDbMap(dbMap);
   mapContext.thriftObject = getThriftObject(context.thriftObject, fieldName);
   pushContext(mapContext);
   return new TMap(TType.STRING, TType.STRING,dbMap.size());
}
 
开发者ID:BreizhBeans,项目名称:ThriftMongoBridge,代码行数:15,代码来源:TBSONProtocol.java

示例9: getTType

@Override
public byte getTType() {
    return TType.STRING;
}
 
开发者ID:meituan,项目名称:Firefly,代码行数:4,代码来源:TypeAdapter.java

示例10: partialDeserializeField

private Object partialDeserializeField(byte ttype, byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
  try {
    TField field = locateField(bytes, fieldIdPathFirst, fieldIdPathRest);
    if (field != null) {
      // if this point is reached, iprot will be positioned at the start of the field.
      switch(ttype){
        case TType.BOOL:
          if (field.type == TType.BOOL){
            return protocol_.readBool();
          }
          break;
        case TType.BYTE:
          if (field.type == TType.BYTE) {
            return protocol_.readByte();
          }
          break;
        case TType.DOUBLE:
          if (field.type == TType.DOUBLE) {
            return protocol_.readDouble();
          }
          break;
        case TType.I16:
          if (field.type == TType.I16) {
            return protocol_.readI16();
          }
          break;
        case TType.I32:
          if (field.type == TType.I32) {
            return protocol_.readI32();
          }
          break;
        case TType.I64:
          if (field.type == TType.I64) {
            return protocol_.readI64();
          }
          break;
        case TType.STRING:
          if (field.type == TType.STRING) {
            return protocol_.readString();
          }
          break;
        case 100: // hack to differentiate between string and binary
          if (field.type == TType.STRING) {
            return protocol_.readBinary();
          }
          break;
      }
    }
    return null;
  } catch (Exception e) {
    throw new TException(e);
  } finally {
    trans_.clear();
    protocol_.reset();
  }
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:56,代码来源:TDeserializer.java

示例11: toTypeSignature

@VisibleForTesting
static TypeSignature toTypeSignature(FieldValueMetaData fieldValueMetaData) {
    if (fieldValueMetaData instanceof StructMetaData) {
        return TypeSignature.ofNamed(((StructMetaData) fieldValueMetaData).structClass);
    }

    if (fieldValueMetaData instanceof EnumMetaData) {
        return TypeSignature.ofNamed(((EnumMetaData) fieldValueMetaData).enumClass);
    }

    if (fieldValueMetaData instanceof ListMetaData) {
        return TypeSignature.ofList(toTypeSignature(((ListMetaData) fieldValueMetaData).elemMetaData));
    }

    if (fieldValueMetaData instanceof SetMetaData) {
        return TypeSignature.ofSet(toTypeSignature(((SetMetaData) fieldValueMetaData).elemMetaData));
    }

    if (fieldValueMetaData instanceof MapMetaData) {
        return TypeSignature.ofMap(toTypeSignature(((MapMetaData) fieldValueMetaData).keyMetaData),
                                   toTypeSignature(((MapMetaData) fieldValueMetaData).valueMetaData));
    }

    if (fieldValueMetaData.isBinary()) {
        return BINARY;
    }

    switch (fieldValueMetaData.type) {
        case TType.VOID:
            return VOID;
        case TType.BOOL:
            return BOOL;
        case TType.BYTE:
            return I8;
        case TType.DOUBLE:
            return DOUBLE;
        case TType.I16:
            return I16;
        case TType.I32:
            return I32;
        case TType.I64:
            return I64;
        case TType.STRING:
            return STRING;
    }

    final String unresolvedName;
    if (fieldValueMetaData.isTypedef()) {
        unresolvedName = fieldValueMetaData.getTypedefName();
    } else {
        unresolvedName = null;
    }

    return TypeSignature.ofUnresolved(firstNonNull(unresolvedName, "unknown"));
}
 
开发者ID:line,项目名称:armeria,代码行数:55,代码来源:ThriftDocServicePlugin.java

示例12: readOneValue

void readOneValue(TProtocol in, TProtocol out, byte type)
    throws TException {
  switch (type) {
  case TType.LIST:
    readOneList(in, out);
    break;
  case TType.MAP:
    readOneMap(in, out);
    break;
  case TType.SET:
    readOneSet(in, out);
    break;
  case TType.STRUCT:
    readOneStruct(in, out);
    break;
  case TType.STOP:
    break;
  case TType.BOOL:
    out.writeBool(in.readBool());
    break;
  case TType.BYTE:
    out.writeByte(in.readByte());
    break;
  case TType.DOUBLE:
    out.writeDouble(in.readDouble());
    break;
  case TType.I16:
    out.writeI16(in.readI16());
    break;
  case TType.ENUM: // same as i32 => actually never seen in the protocol layer as enums are written as a i32 field
  case TType.I32:
    out.writeI32(in.readI32());
    break;
  case TType.I64:
    out.writeI64(in.readI64());
    break;
  case TType.STRING:
    out.writeBinary(in.readBinary());
    break;
  case TType.VOID:
    break;
  default:
    throw new TException("Unknown type: " + type);
  }
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:45,代码来源:ProtocolReadToWrite.java

示例13: readOneValue

/**
 * @return true when all value is consumed, false when some values is ignored due to the field is not defined in expectedType
 * @throws TException
 */
private boolean readOneValue(TProtocol in, byte type, List<Action> buffer, ThriftType expectedType) throws TException {
  if (expectedType != null && expectedType.getType().getSerializedThriftType() != type) {
    throw new DecodingSchemaMismatchException("the data type does not match the expected thrift structure: expected " + expectedType + " got " + typeName(type));
  }
  boolean hasFieldsIgnored = false;
  switch (type) {
  case TType.LIST:
    hasFieldsIgnored = readOneList(in, buffer, (ListType)expectedType);
    break;
  case TType.MAP:
    hasFieldsIgnored = readOneMap(in, buffer, (MapType)expectedType);
    break;
  case TType.SET:
    hasFieldsIgnored = readOneSet(in, buffer, (SetType)expectedType);
    break;
  case TType.STRUCT:
    hasFieldsIgnored = readOneStruct(in, buffer, (StructType)expectedType);
    break;
  case TType.STOP:
    break;
  case TType.BOOL:
    final boolean bool = in.readBool();
    writeBoolAction(buffer, bool);
    break;
  case TType.BYTE:
    final byte b = in.readByte();
    writeByteAction(buffer, b);
    break;
  case TType.DOUBLE:
    final double d = in.readDouble();
    writeDoubleAction(buffer, d);
    break;
  case TType.I16:
    final short s = in.readI16();
    writeShortAction(buffer, s);
    break;
  case TType.ENUM: // same as i32 => actually never seen in the protocol layer as enums are written as a i32 field
  case TType.I32:
    final int i = in.readI32();
    checkEnum(expectedType,i);
    writeIntAction(buffer, i);
    break;
  case TType.I64:
    final long l = in.readI64();
    writeLongAction(buffer, l);
    break;
  case TType.STRING:
    final ByteBuffer bin = in.readBinary();
    writeStringAction(buffer, bin);
    break;
  case TType.VOID:
    break;
  default:
    throw new TException("Unknown type: " + type);
  }
  return hasFieldsIgnored;
}
 
开发者ID:apache,项目名称:parquet-mr,代码行数:61,代码来源:BufferedProtocolReadToWrite.java

示例14: secureThriftFields

public void secureThriftFields(Class<? extends TBase> tbase, boolean hash, TFieldIdEnum... fields) throws Exception {
  Map<Short, ThriftSecuredField> classSecuredFields = securedFields.get(tbase);
  if(classSecuredFields==null) {
    classSecuredFields = new ConcurrentHashMap<>();
  }

  // get the Field class
  Class<?> fieldClass = null;
  Class<?>[] innerClasses = tbase.getClasses();
  for (Class<?> innerClass : innerClasses) {
    if ("_Fields".equals(innerClass.getSimpleName())) {
      fieldClass = innerClass;
      break;
    }
  }

  // extract _Fields
  Class[] findByNameArgs = new Class[1];
  findByNameArgs[0] = String.class;
  Method findByNameMethod = fieldClass.getMethod("findByName", findByNameArgs);

  // extract metadataMap
  Field metafaField = tbase.getField("metaDataMap");
  Map<?, FieldMetaData> metaDataMap = (Map<?, org.apache.thrift.meta_data.FieldMetaData>) metafaField.get(tbase);

  for(TFieldIdEnum field : fields) {
    // get the _Field instance
    org.apache.thrift.TFieldIdEnum  tfieldEnum = (TFieldIdEnum) findByNameMethod.invoke(null, field.getFieldName());

    // get the matadata
    FieldMetaData fieldMetaData = metaDataMap.get(tfieldEnum);

    // only string are supported
    switch(fieldMetaData.valueMetaData.type) {
      case TType.STRING:
        break;

      case TType.MAP:
        MapMetaData mapMetaData = (MapMetaData) fieldMetaData.valueMetaData;

        if (mapMetaData.valueMetaData.type != TType.STRING) {
          throw new UnsupportedTTypeException("Unsupported secured type - FIELD:" + field.getFieldName() + " TYPE:" + mapMetaData.valueMetaData.type);
        }
        break;
      default:
        throw new UnsupportedTTypeException("Unsupported secured type - FIELD:" + field.getFieldName() + " TYPE:" + fieldMetaData.valueMetaData.type);
    }

    classSecuredFields.put(field.getThriftFieldId(), new ThriftSecuredField(true, hash));
  }

  securedFields.put(tbase,classSecuredFields);
}
 
开发者ID:BreizhBeans,项目名称:ThriftMongoBridge,代码行数:53,代码来源:TBSONSecuredWrapper.java


注:本文中的org.apache.thrift.protocol.TType.STRING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。