GVKun编程网logo

织梦新闻简介[field:description /]怎么修改字数限制(织梦修改文章发布时间)

15

本篇文章给大家谈谈织梦新闻简介[field:description/]怎么修改字数限制,以及织梦修改文章发布时间的知识点,同时本文还将给你拓展@Api(tags="testController",de

本篇文章给大家谈谈织梦新闻简介[field:description /]怎么修改字数限制,以及织梦修改文章发布时间的知识点,同时本文还将给你拓展@Api(tags = "testController", description = "测试使用") 不显示description 内容、clickhouse-copier 失败了,有人遇到这个问题吗?Can''t get description node /root/t.xml/description、com.google.protobuf.Descriptors.FieldDescriptor.Type的实例源码、com.google.protobuf.Descriptors.FieldDescriptor的实例源码等相关知识,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

织梦新闻简介[field:description /]怎么修改字数限制(织梦修改文章发布时间)

织梦新闻简介[field:description /]怎么修改字数限制(织梦修改文章发布时间)

 

在用织梦系统时,用[field:description /]标签调取新闻简介时,限制字数的办法有下面3种:

  *种办法:(推荐!)

  [field:description function='cn_substr(@me,228)'/]

  调用现成的cn_substr()字符串截取函数来实现,228为限制字节数(一个汉字等于2个字节);

  第二种办法:(推荐!)

  使用 [field:infos/] 代替 [field:description/] 在 arclist 标签内设定 infolen='30' 来设定长度;

  第三种办法:

  织梦默认[field:description/]长度为255个字节,如果想调取更多的字节需要更改以下文件:

  dede 文件下的 article_add.php 和 article_edit.php

  $description = cn_substrR($description,250);

  把250改为你想要的字节 2个字节等于一个中文字符

  或者修改数据库表单

  dede_archives 里面的 description

  把原来的 varchar(255) 改为想要的。

本文章网址:http://www.ppssdd.com/code/11381.html。转载请保留出处,谢谢合作!

@Api(tags =

@Api(tags = "testController", description = "测试使用") 不显示description 内容

在knife4j-spring-boot-starter 2.0.3中集成后,怎么显示出标记类中的@Api(tags = "testController", description = "测试使用") description 内容

clickhouse-copier  失败了,有人遇到这个问题吗?Can''t get description node /root/t.xml/description

clickhouse-copier 失败了,有人遇到这个问题吗?Can''t get description node /root/t.xml/description


clickhouse-copier  失败了

 clickhouse-copier --daemon --config   /root/zookeeper.xml  --task-path   /root/t.xml   --base-dir /root

 

Code: 36, e.displayText() = DB::Exception: Can''t get description node /root/t.xml/description, Stack trace (when copying this message, always include the lines below):

 

 

Can''t get description node /root/t.xml/description

 

Can''t get description node /root/t.xml/description

 


/clickhouse-copier_20210322025609_129# cat log.log
2021.03.22 02:56:09.187831 [ 129 ] {} <Information> SentryWriter: Sending crash reports is disabled
2021.03.22 02:56:09.187900 [ 129 ] {} <Trace> Pipe: Pipe capacity is 1.00 MiB
2021.03.22 02:56:09.232163 [ 129 ] {} <Information> : Starting ClickHouse 20.12.4.5 with revision 54443, build id: CB7174248A8BDC07, PID 129
2021.03.22 02:56:09.232315 [ 129 ] {} <Information> Application: Starting clickhouse-copier (id 20210322025609_129, host_id f192bbeca914#20210322025609_129, path /root/clickhouse-copier_20210322025609_129, revision 54443)
2021.03.22 02:56:09.240841 [ 129 ] {} <Trace> ZooKeeper: Initialized, hosts: 10.76.198.198:2181
2021.03.22 02:56:09.242019 [ 129 ] {} <Debug> MemoryTracker: Peak memory usage (for query): 0.00 B.
2021.03.22 02:56:09.243460 [ 129 ] {} <Error> : virtual int DB::ClusterCopierApp::main(const std::vector<std::string> &): Code: 36, e.displayText() = DB::Exception: Can''t get description node /root/t.xml/description, Stack trace (when copying this message, always include the lines below):

0. DB::ClusterCopier::reloadTaskDescription() @ 0x7df7f86 in /usr/bin/clickhouse
1. DB::ClusterCopier::init() @ 0x7df6ed1 in /usr/bin/clickhouse
2. DB::ClusterCopierApp::mainImpl() @ 0x7df4f4f in /usr/bin/clickhouse
3. DB::ClusterCopierApp::main(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x7df550d in /usr/bin/clickhouse
4. Poco::Util::Application::run() @ 0x10d99ff3 in /usr/bin/clickhouse
5. mainEntryClickHouseClusterCopier(int, char**) @ 0x7df565d in /usr/bin/clickhouse
6. main @ 0x7ceacbd in /usr/bin/clickhouse
7. __libc_start_main @ 0x270b3 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
8. _start @ 0x7c9b02e in /usr/bin/clickhouse
 (version 20.12.4.5 (official build))
2021.03.22 02:56:09.243496 [ 129 ] {} <Debug> Application: Uninitializing subsystem: Logging Subsystem
2021.03.22 02:56:09.243566 [ 132 ] {} <Trace> BaseDaemon: Received signal -2
2021.03.22 02:56:09.243606 [ 132 ] {} <Information> BaseDaemon: Stop SignalListener thread

com.google.protobuf.Descriptors.FieldDescriptor.Type的实例源码

com.google.protobuf.Descriptors.FieldDescriptor.Type的实例源码

项目:rejoiner    文件:ProtoToGql.java   
/** Returns a GraphQLOutputType generated from a FieldDescriptor. */
static GraphQLOutputType convertType(FieldDescriptor fieldDescriptor) {
  final GraphQLOutputType type;

  if (fieldDescriptor.getType() == Type.MESSAGE) {
    type = getReference(fieldDescriptor.getMessageType());
  } else if (fieldDescriptor.getType() == Type.GROUP) {
    type = getReference(fieldDescriptor.getMessageType());
  } else if (fieldDescriptor.getType() == Type.ENUM) {
    type = getReference(fieldDescriptor.getEnumType());
  } else {
    type = TYPE_MAP.get(fieldDescriptor.getType());
  }

  if (type == null) {
    throw new RuntimeException("UnkNown type: " + fieldDescriptor.getType());
  }

  if (fieldDescriptor.isRepeated()) {
    return new GraphQLList(type);
  } else {
    return type;
  }
}
项目:curiostack    文件:protofieldInfo.java   
/**
 * Returns the {@link Method} that sets a single value of the field. For repeated and map fields,* this is the add or put method that only take an individual element;
 */
Method setValueMethod() {
  StringBuilder setter = new StringBuilder();
  final Class<?>[] args;
  if (field.isMapField()) {
    setter.append("put");
    args = new Class<?>[] {mapKeyField.javaClass(),javaClass()};
  } else {
    args = new Class<?>[] {javaClass()};
    if (field.isRepeated()) {
      setter.append("add");
    } else {
      setter.append("set");
    }
  }
  setter.append(camelCaseName);
  if (valueType() == Type.ENUM) {
    setter.append("Value");
  }
  try {
    return builderClass.getDeclaredMethod(setter.toString(),args);
  } catch (NoSuchMethodException e) {
    throw new IllegalStateException("Could not find setter.",e);
  }
}
项目:shapeshifter    文件:NamedSchema.java   
/**
 * Populates a JSON schema for a repeated primitive proto field.
 * 
 * @param field the field being considered
 * @param property the JSON schema being built
 */
private void populateRepeatedPrimitiveSchema(FieldDescriptor field,JsonSchema.Builder property) {
    property.setType(JsonType.ARRAY);
    JsonSchema.Builder itemsSchema = JsonSchema.newBuilder();

    if (treatLongsAsstrings && field.getJavaType().equals(JavaType.LONG)
            && !transforms.containsKey(field.getName())) {
        itemsSchema.setType(JsonType.STRING);
        if (field.getType().equals(Type.UINT64) || field.getType().equals(Type.FIXED64)) {
            itemsSchema.setFormat(UINT64_STRING_FORMAT);
        } else {
            itemsSchema.setFormat(INT64_STRING_FORMAT);
        }
    } else {
        itemsSchema.setType(getReifiedFieldType(field));
    }
    property.setItems(itemsSchema);

    if (field.getType().equals(Type.ENUM)) {
        for (EnumValueDescriptor enumValue : field.getEnumType().getValues()) {
            property.addEnum(PROTO_ENUM_CASE_FORMAT.to(
                    enumCaseFormat,enumValue.getName()));
        }
    }
}
项目:core-java    文件:Sample.java   
/**
 * Generates a non-default value for the given message field.
 *
 * <p>All the protobuf types are supported including nested {@link Message}s and
 * the {@code enum}s.
 *
 * @param field {@link FieldDescriptor} to take the type info from
 * @return a non-default generated value of type of the given field
 */
@SuppressWarnings("OverlyComplexMethod")
private static Object valueFor(FieldDescriptor field) {
    final Type type = field.getType();
    final JavaType javaType = type.getJavaType();
    final Random random = new SecureRandom();
    switch (javaType) {
        case INT:
            return random.nextInt();
        case LONG:
            return random.nextLong();
        case FLOAT:
            return random.nextFloat();
        case DOUBLE:
            return random.nextDouble();
        case BOOLEAN:
            return random.nextBoolean();
        case STRING:
            final byte[] bytes = new byte[8];
            random.nextBytes(bytes);
            return new String(bytes);
        case BYTE_STRING:
            final byte[] bytesPrimitive = new byte[8];
            random.nextBytes(bytesPrimitive);
            return ByteString.copyFrom(bytesPrimitive);
        case ENUM:
            return enumValueFor(field,random);
        case MESSAGE:
            return messageValueFor(field);
        default:
            throw new IllegalArgumentException(format("Field type %s is not supported.",type));
    }
}
项目:ndn-dot-net    文件:ProtobufTlv.java   
/**
 * This is a helper for decodeMessageValue. Decode a single field and return
 * the value. Assume the field type is not Type.MESSAGE.
 */
private static Object
decodeFieldValue
  (FieldDescriptor field,int tlvType,TlvDecoder decoder,int endOffset)
    throws EncodingException
{
  if (field.getType() == Type.UINT32)
    return (int)decoder.readNonNegativeIntegerTlv(tlvType);
  else if (field.getType() == Type.UINT64)
    return decoder.readNonNegativeIntegerTlv(tlvType);
  else if (field.getType() == Type.ENUM)
    return field.getEnumType().findValueByNumber
      ((int)decoder.readNonNegativeIntegerTlv(tlvType));
  else if (field.getType() == Type.BYTES)
    return ByteString.copyFrom(decoder.readBlobTlv(tlvType));
  else if (field.getType() == Type.STRING) {
    try {
      ByteBuffer byteBuffer = decoder.readBlobTlv(tlvType);
      // Use Blob to get the byte array.
      return new String(new Blob(byteBuffer,false).getImmutableArray(),"UTF-8");
    } catch (UnsupportedEncodingException ex) {
      // We don't expect this to happen.
      throw new Error("UTF-8 decoder not supported: " + ex.getMessage());
    }
  }
  else if (field.getType() == Type.BOOL)
    return decoder.readBooleanTlv(tlvType,endOffset);
  else
    throw new Error("ProtobufTlv.decode: UnkNown field type");
}
项目:jndn    文件:ProtobufTlv.java   
/**
 * This is a helper for decodeMessageValue. Decode a single field and return
 * the value. Assume the field type is not Type.MESSAGE.
 */
private static Object
decodeFieldValue
  (FieldDescriptor field,endOffset);
  else
    throw new Error("ProtobufTlv.decode: UnkNown field type");
}
项目:shapeshifter    文件:NamedSchema.java   
/**
 * Returns a new schema in which the given field will be delegated to the
 * specified schema.
 *
 * <p>The field must be a submessage and its type must match that of
 * {@code schema}.
 *
 * @param fieldName the name of the field,which must be of object type
 * @param schemaName the name of the schema to delegate this field to
 */
public NamedSchema useSchema(String fieldName,String schemaName) {
    Preconditions.checkNotNull(fieldName);
    Preconditions.checkNotNull(schemaName);
    Preconditions.checkState(has(fieldName));
    FieldDescriptor field = fields.get(fieldName);
    Preconditions.checkArgument(Type.MESSAGE.equals(field.getType()));
    ImmutableMap.Builder<String,String> subObjectSchemascopy = ImmutableMap.builder();
    subObjectSchemascopy.putAll(subObjectSchemas);
    subObjectSchemascopy.put(fieldName,schemaName);
    return new NamedSchema(descriptor,name,skippedFields,constants,enumCaseFormat,substitutions,transforms,mappings,descriptions,subObjectSchemascopy.build(),formats,treatLongsAsstrings);
}
项目:shapeshifter    文件:ProtoDescriptorgraph.java   
private static void populate(Descriptor descriptor,Multimap<Descriptor,Descriptor> graphBuilder) {
    if (graphBuilder.containsKey(descriptor)) {
        return;
    }

    for (FieldDescriptor field : descriptor.getFields()) {
        if (Type.MESSAGE.equals(field.getType())) {
            Descriptors.Descriptor subDescriptor = field.getMessageType();
            graphBuilder.put(descriptor,subDescriptor);
            populate(subDescriptor,graphBuilder);
        }   
    }       
}
项目:cloudata    文件:DynamodbDataStore.java   
public AttributeValue buildAttributeValue(Object value) {
  Type type = field.getType();
  if (type == Type.BYTES) {
    ByteString b = (ByteString) value;
    AttributeValue attributeValue = new AttributeValue().withB(b.asReadOnlyByteBuffer());
    return attributeValue;
    // AttributeValue attributeValue = tableInfo.mapToAttributeValue(fieldDescriptor,fieldValue);
    // expected.put(attributeName,new ExpectedAttributeValue(toAttributeValue(where.getVersion())));
  } else {
    throw new UnsupportedOperationException("Unsupport field type: " + type);
  }
}
项目:ndn-dot-net    文件:ProtobufTlv.java   
private static void
encodeMessageValue(Message message,TlvEncoder encoder)
{
  // Note: We can't use ListFields because it sorts by field number.
  Descriptor descriptor = message.getDescriptorForType();
  // Go in reverse so that we encode backwards.
  List fields = descriptor.getFields();
  for (int i = fields.size() - 1; i >= 0; --i) {
    FieldDescriptor field = (FieldDescriptor)fields.get(i);

    int tlvType = field.getNumber();

    int valueCount = 0;
    if (field.isRepeated())
      valueCount = message.getRepeatedFieldCount(field);
    else {
      if (message.hasField(field))
        valueCount = 1;
    }

    // Reverse so that we encode backwards.
    for (int iValue = valueCount - 1; iValue >= 0; --iValue) {
      Object value;
      if (field.isRepeated())
        value = message.getRepeatedField(field,iValue);
      else
        value = message.getField(field);

      if (field.getType() == Type.MESSAGE) {
        int saveLength = encoder.getLength();

        // Encode backwards.
        encodeMessageValue((Message)value,encoder);
        encoder.writeTypeAndLength(tlvType,encoder.getLength() - saveLength);
      }
      else if (field.getType() == Type.UINT32)
        encoder.writeNonNegativeIntegerTlv(tlvType,(Integer)value);
      else if (field.getType() == Type.UINT64)
        encoder.writeNonNegativeIntegerTlv(tlvType,(Long)value);
      else if (field.getType() == Type.ENUM) {
        int intValue = ((EnumValueDescriptor)value).getNumber();
        if (intValue < 0)
          throw new Error("ProtobufTlv.encode: ENUM value may not be negative");
        encoder.writeNonNegativeIntegerTlv(tlvType,intValue);
      }
      else if (field.getType() == Type.BYTES)
        encoder.writeBlobTlv(tlvType,((ByteString)value).asReadOnlyByteBuffer());
      else if (field.getType() == Type.STRING)
        // Use Blob to UTF-8 encode and get a ByteBuffer.
        encoder.writeBlobTlv(tlvType,new Blob((String)value).buf());
      else if (field.getType() == Type.BOOL) {
        if ((boolean)(Boolean)value)
          encoder.writeTypeAndLength(tlvType,0);
      }
      else
        throw new Error("ProtobufTlv.encode: UnkNown field type");
    }
  }
}
项目:closure-templates    文件:ProtoUtils.java   
/** Returns true if fieldDescriptor holds a sanitized proto type. */
public static boolean isSanitizedContentField(FieldDescriptor fieldDescriptor) {
  return fieldDescriptor.getType() == Type.MESSAGE
      && SafeStringTypes.SAFE_PROTO_TO_SANITIZED_TYPE.containsKey(
          fieldDescriptor.getMessageType().getFullName());
}
项目:jndn    文件:ProtobufTlv.java   
private static void
encodeMessageValue(Message message,0);
      }
      else
        throw new Error("ProtobufTlv.encode: UnkNown field type");
    }
  }
}
项目:fuchsia    文件:ProtoGenerator.java   
private void generateProtoFromDescriptor(FieldDescriptor descriptor,Appendable out,String indent,Map<Descriptor,Boolean> descriptors)
        throws IOException {
    out.append(indent);
    if (descriptor.isrequired()) {
        out.append("required ");
    }

    if (descriptor.isOptional()) {
        out.append("optional ");
    }

    if (descriptor.isRepeated()) {
        out.append("repeated ");
    }

    if (descriptor.getType().equals(Type.MESSAGE)) {
        out.append(descriptor.getMessageType().getFullName() + " ");
        Descriptor messageType = descriptor.getMessageType();
        if (descriptors.get(messageType) == null) {
            descriptors.put(messageType,false);
        }
    } else if (descriptor.getType().equals(Type.ENUM)) {
        out.append(descriptor.getEnumType().getFullName() + " ");
    } else {
        out.append(descriptor.getType().toString().toLowerCase() + " ");
    }

    out.append(descriptor.getName() + " = " + descriptor.getNumber());

    if (descriptor.hasDefaultValue()) {
        out.append(" [default = ");
        Object defaultValue = descriptor.getDefaultValue();

        if (defaultValue instanceof EnumValueDescriptor) {
            out.append(((EnumValueDescriptor) defaultValue).getName());
        }

        out.append("]");
    }

    out.append(";\n");
}
项目:shapeshifter    文件:NamedSchema.java   
/**
 * Returns a new schema that will serialize repeated objects as a JSON
 * object instead of a JSON array.
 *
 * <p>This transformation is useful in cases where the source object
 * contains a list of objects identified by a given field. normally,such
 * a list would be serialized as:<pre>{@code
 *
 * "users": [
 *      {"username": "lrichie",name: "Lionel Richie"},*      {"username": "stwain","name": "Shania Twain"}
 * ]}</pre>
 *
 * <p>A common JSON idiom is to represent such collections as pseudo-maps,*  i.e.objects with non-predefined keys:<pre>{@code
 *
 * "users": {
 *  "lrichie": {"name": "Lionel Richie"},*  "stwain": {"name": "Shania Twain"}
 * }}</pre>
 *
 * <p>To achieve this effect,call this method with {@code "users"} and
 * {@code "username"} as parameters,respectively.
 *
 * @param fieldName Must point to a repeated object field in this schema
 * @param keyFieldName Must be a string field in the repeated field
 */
public NamedSchema mapRepeatedField(String fieldName,String keyFieldName) {
    Preconditions.checkNotNull(fieldName);
    Preconditions.checkArgument(has(fieldName));
    Preconditions.checkNotNull(keyFieldName);
    FieldDescriptor field = fields.get(fieldName);
    Preconditions.checkArgument(field.isRepeated() && Type.MESSAGE.equals(field.getType()));
    Descriptor fieldDescriptor = field.getMessageType();
    boolean found = false;
    FieldDescriptor keyField = null;
    for (FieldDescriptor subField : fieldDescriptor.getFields()) {
        if (subField.getName().equals(keyFieldName)) {
            found = true;
            keyField = subField;
        }
    }
    if (!found || keyField.isRepeated() || !Type.STRING.equals(keyField.getType())) {
        throw new IllegalArgumentException();
    }
    ImmutableMap.Builder<String,FieldDescriptor> mappingscopy =
            ImmutableMap.<String,FieldDescriptor>builder();
    mappingscopy.putAll(mappings);
    mappingscopy.put(fieldName,keyField);
    return new NamedSchema(descriptor,mappingscopy.build(),subObjectSchemas,treatLongsAsstrings);
}
项目:curiostack    文件:protofieldInfo.java   
/**
 * Returns the {@link Type} of the actual value of this field,which for map fields is the type of
 * the map's value.
 */
FieldDescriptor.Type valueType() {
  return valueField().descriptor().getType();
}

com.google.protobuf.Descriptors.FieldDescriptor的实例源码

com.google.protobuf.Descriptors.FieldDescriptor的实例源码

项目:seldon-core    文件:JsonFormat.java   
private void mergeMessage(JsonElement json,Message.Builder builder,boolean skipTypeUrl)
    throws InvalidProtocolBufferException {
  if (!(json instanceof JsonObject)) {
    throw new InvalidProtocolBufferException("Expect message object but got: " + json);
  }
  JsonObject object = (JsonObject) json;
  Map<String,FieldDescriptor> fieldNameMap = getFieldNameMap(builder.getDescriptorForType());
  for (Map.Entry<String,JsonElement> entry : object.entrySet()) {
    if (skipTypeUrl && entry.getKey().equals("@type")) {
      continue;
    }
    FieldDescriptor field = fieldNameMap.get(entry.getKey());
    if (field == null) {
      if (ignoringUnkNownFields) {
        continue;
      }
      throw new InvalidProtocolBufferException(
          "Cannot find field: "
              + entry.getKey()
              + " in message "
              + builder.getDescriptorForType().getFullName());
    }
    mergeField(field,entry.getValue(),builder);
  }
}
项目:seldon-core    文件:JsonFormat.java   
private void mergeMapField(FieldDescriptor field,JsonElement json,Message.Builder builder)
    throws InvalidProtocolBufferException {
  if (!(json instanceof JsonObject)) {
    throw new InvalidProtocolBufferException("Expect a map object but found: " + json);
  }
  Descriptor type = field.getMessageType();
  FieldDescriptor keyField = type.findFieldByName("key");
  FieldDescriptor valueField = type.findFieldByName("value");
  if (keyField == null || valueField == null) {
    throw new InvalidProtocolBufferException("Invalid map field: " + field.getFullName());
  }
  JsonObject object = (JsonObject) json;
  for (Map.Entry<String,JsonElement> entry : object.entrySet()) {
    Message.Builder entryBuilder = builder.newBuilderForField(field);
    Object key = parseFieldValue(keyField,new JsonPrimitive(entry.getKey()),entryBuilder);
    Object value = parseFieldValue(valueField,entryBuilder);
    if (value == null) {
      throw new InvalidProtocolBufferException("Map value cannot be null.");
    }
    entryBuilder.setField(keyField,key);
    entryBuilder.setField(valueField,value);
    builder.addRepeatedField(field,entryBuilder.build());
  }
}
项目:rejoiner    文件:ProtoToGql.java   
@Override
public GraphQLFieldDeFinition apply(FieldDescriptor fieldDescriptor) {
  GraphQLFieldDeFinition.Builder builder =
      GraphQLFieldDeFinition.newFieldDeFinition()
          .type(convertType(fieldDescriptor))
          .dataFetcher(
              new ProtoDataFetcher(UNDERscore_TO_CAMEL.convert(fieldDescriptor.getName())))
          .name(UNDERscore_TO_CAMEL.convert(fieldDescriptor.getName()));
  if (fieldDescriptor.getFile().toProto().getSourceCodeInfo().getLocationCount()
      > fieldDescriptor.getIndex()) {
    builder.description(
        fieldDescriptor
            .getFile()
            .toProto()
            .getSourceCodeInfo()
            .getLocation(fieldDescriptor.getIndex())
            .getLeadingComments());
  }
  if (fieldDescriptor.getoptions().hasDeprecated()
      && fieldDescriptor.getoptions().getDeprecated()) {
    builder.deprecate("deprecated in proto");
  }
  return builder.build();
}
项目:sstore-soft    文件:GeneratedMessage.java   
@Override
public Object getField(final FieldDescriptor field) {
  if (field.isExtension()) {
    verifyContainingType(field);
    final Object value = extensions.getField(field);
    if (value == null) {
      if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
        // Lacking an ExtensionRegistry,we have no way to determine the
        // extension's real type,so we return a Dynamicmessage.
        return Dynamicmessage.getDefaultInstance(field.getMessageType());
      } else {
        return field.getDefaultValue();
      }
    } else {
      return value;
    }
  } else {
    return super.getField(field);
  }
}
项目:s-store    文件:GeneratedMessage.java   
/**
 * Convert from the type used by the reflection accessors to the type used
 * by native accessors.  E.g.,for enums,the reflection accessors use
 * EnumValueDescriptors but the native accessors use the generated enum
 * type.
 */
@SuppressWarnings("unchecked")
private Object fromreflectionType(final Object value) {
  if (descriptor.isRepeated()) {
    if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE ||
        descriptor.getJavaType() == FieldDescriptor.JavaType.ENUM) {
      // Must convert the whole list.
      final List result = new ArrayList();
      for (final Object element : (List) value) {
        result.add(singularFromreflectionType(element));
      }
      return result;
    } else {
      return value;
    }
  } else {
    return singularFromreflectionType(value);
  }
}
项目:s-store    文件:AbstractMessage.java   
public void writeto(final CodedOutputStream output) throws IOException {
  final boolean isMessageSet =
      getDescriptorForType().getoptions().getMessageSetWireFormat();

  for (final Map.Entry<FieldDescriptor,Object> entry :
      getAllFields().entrySet()) {
    final FieldDescriptor field = entry.getKey();
    final Object value = entry.getValue();
    if (isMessageSet && field.isExtension() &&
        field.getType() == FieldDescriptor.Type.MESSAGE &&
        !field.isRepeated()) {
      output.writeMessageSetExtension(field.getNumber(),(Message) value);
    } else {
      FieldSet.writeField(field,value,output);
    }
  }

  final UnkNownFieldSet unkNownFields = getUnkNownFields();
  if (isMessageSet) {
    unkNownFields.writeAsMessageSetTo(output);
  } else {
    unkNownFields.writeto(output);
  }
}
项目:s-store    文件:GeneratedMessage.java   
@Override
public Object getField(final FieldDescriptor field) {
  if (field.isExtension()) {
    verifyContainingType(field);
    final Object value = extensions.getField(field);
    if (value == null) {
      if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
        // Lacking an ExtensionRegistry,so we return a Dynamicmessage.
        return Dynamicmessage.getDefaultInstance(field.getMessageType());
      } else {
        return field.getDefaultValue();
      }
    } else {
      return value;
    }
  } else {
    return super.getField(field);
  }
}
项目:sstore-soft    文件:GeneratedMessage.java   
/**
 * Convert from the type used by the native accessors to the type used
 * by reflection accessors.  E.g.,the reflection accessors use
 * EnumValueDescriptors but the native accessors use the generated enum
 * type.
 */
@SuppressWarnings("unchecked")
private Object toReflectionType(final Object value) {
  if (descriptor.isRepeated()) {
    if (descriptor.getJavaType() == FieldDescriptor.JavaType.ENUM) {
      // Must convert the whole list.
      final List result = new ArrayList();
      for (final Object element : (List) value) {
        result.add(singularToReflectionType(element));
      }
      return result;
    } else {
      return value;
    }
  } else {
    return singularToReflectionType(value);
  }
}
项目:sstore-soft    文件:ExtensionRegistry.java   
private void add(final ExtensionInfo extension) {
  if (!extension.descriptor.isExtension()) {
    throw new IllegalArgumentException(
      "ExtensionRegistry.add() was given a FieldDescriptor for a regular " +
      "(non-extension) field.");
  }

  extensionsByName.put(extension.descriptor.getFullName(),extension);
  extensionsByNumber.put(
    new DescriptorIntPair(extension.descriptor.getContainingType(),extension.descriptor.getNumber()),extension);

  final FieldDescriptor field = extension.descriptor;
  if (field.getContainingType().getoptions().getMessageSetWireFormat() &&
      field.getType() == FieldDescriptor.Type.MESSAGE &&
      field.isOptional() &&
      field.getExtensionScope() == field.getMessageType()) {
    // This is an extension of a MessageSet type defined within the extension
    // type's own scope.  For backwards-compatibility,allow it to be looked
    // up by type name.
    extensionsByName.put(field.getMessageType().getFullName(),extension);
  }
}
项目:jigsaw-payment    文件:XmlFormat.java   
private Object handleObject(Tokenizer tokenizer,ExtensionRegistry extensionRegistry,FieldDescriptor field,ExtensionRegistry.ExtensionInfo extension) throws ParseException {

    Object value;
    Message.Builder subBuilder;
    if (extension == null) {
        subBuilder = builder.newBuilderForField(field);
    } else {
        subBuilder = extension.defaultInstance.newBuilderForType();
    }

    //tokenizer.consume("<");
    String endToken = "</";

    while (!tokenizer.tryConsume(endToken)) {
        if (tokenizer.atEnd()) {
            throw tokenizer.parseException("Expected \"" + endToken + "\".");
        }
        mergeField(tokenizer,extensionRegistry,subBuilder);
    }

    value = subBuilder.build();
    return value;
}
项目:s-store    文件:GeneratedMessage.java   
RepeatedMessageFieldAccessor(
    final FieldDescriptor descriptor,final String camelCaseName,final Class<? extends GeneratedMessage> messageClass,final Class<? extends Builder> builderClass) {
  super(descriptor,camelCaseName,messageClass,builderClass);

  newBuilderMethod = getmethodOrDie(type,"newBuilder");
}
项目:s-store    文件:GeneratedMessage.java   
/** Set the value of one element of a repeated extension. */
public final <Type> BuilderType setExtension(
    final GeneratedExtension<MessageType,List<Type>> extension,final int index,final Type value) {
  final ExtendableMessage<MessageType> message = internalGetResult();
  message.verifyExtensionContainingType(extension);
  final FieldDescriptor descriptor = extension.getDescriptor();
  message.extensions.setRepeatedField(
    descriptor,index,extension.singularToReflectionType(value));
  return (BuilderType) this;
}
项目:sstore-soft    文件:Dynamicmessage.java   
private static boolean isInitialized(Descriptor type,FieldSet<FieldDescriptor> fields) {
  // Check that all required fields are present.
  for (final FieldDescriptor field : type.getFields()) {
    if (field.isrequired()) {
      if (!fields.hasField(field)) {
        return false;
      }
    }
  }

  // Check that embedded messages are initialized.
  return fields.isInitialized();
}
项目:s-store    文件:textformat.java   
private static void printField(final FieldDescriptor field,final Object value,final TextGenerator generator)
                              throws IOException {
  if (field.isRepeated()) {
    // Repeated field.  Print each element.
    for (final Object element : (List) value) {
      printSingleField(field,element,generator);
    }
  } else {
    printSingleField(field,generator);
  }
}
项目:s-store    文件:ExtensionRegistry.java   
/** Add a non-message-type extension to the registry by descriptor. */
public void add(final FieldDescriptor type) {
  if (type.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
    throw new IllegalArgumentException(
      "ExtensionRegistry.add() must be provided a default instance when " +
      "adding an embedded message extension.");
  }
  add(new ExtensionInfo(type,null));
}
项目:seldon-core    文件:JsonFormat.java   
private void mergeWrapper(JsonElement json,Message.Builder builder)
    throws InvalidProtocolBufferException {
  Descriptor type = builder.getDescriptorForType();
  FieldDescriptor field = type.findFieldByName("value");
  if (field == null) {
    throw new InvalidProtocolBufferException("Invalid wrapper type: " + type.getFullName());
  }
  builder.setField(field,parseFieldValue(field,json,builder));
}
项目:s-store    文件:GeneratedMessage.java   
/** Get the number of elements in a repeated extension. */
public final <Type> int getExtensionCount(
    final GeneratedExtension<MessageType,List<Type>> extension) {
  verifyExtensionContainingType(extension);
  final FieldDescriptor descriptor = extension.getDescriptor();
  return extensions.getRepeatedFieldCount(descriptor);
}
项目:seldon-core    文件:JsonFormat.java   
private void mergeListValue(JsonElement json,Message.Builder builder)
    throws InvalidProtocolBufferException {
  Descriptor descriptor = builder.getDescriptorForType();
  FieldDescriptor field = descriptor.findFieldByName("values");
  if (field == null) {
    throw new InvalidProtocolBufferException("Invalid ListValue type.");
  }
  mergeRepeatedField(field,builder);
}
项目:seldon-core    文件:JsonFormat.java   
private void mergeRepeatedField(
    FieldDescriptor field,Message.Builder builder)
    throws InvalidProtocolBufferException {
  if (!(json instanceof JsonArray)) {
    throw new InvalidProtocolBufferException("Expect an array but found: " + json);
  }
  JsonArray array = (JsonArray) json;
  for (int i = 0; i < array.size(); ++i) {
    Object value = parseFieldValue(field,array.get(i),builder);
    if (value == null) {
      throw new InvalidProtocolBufferException("Repeated field elements cannot be null");
    }
    builder.addRepeatedField(field,value);
  }
}
项目:sstore-soft    文件:textformat.java   
public static void printField(final FieldDescriptor field,final Appendable output)
                              throws IOException {
  final TextGenerator generator = new TextGenerator(output);
  printField(field,generator);
}
项目:seldon-core    文件:JsonFormat.java   
/**
 * Gets the default value for a field type. Note that we use proto3
 * language defaults and ignore any default values set through the
 * proto "default" option.
 */
private Object getDefaultValue(FieldDescriptor field,Message.Builder builder) {
  switch (field.getType()) {
    case INT32:
    case SINT32:
    case SFIXED32:
    case UINT32:
    case FIXED32:
      return 0;
    case INT64:
    case SINT64:
    case SFIXED64:
    case UINT64:
    case FIXED64:
      return 0L;
    case FLOAT:
      return 0.0f;
    case DOUBLE:
      return 0.0;
    case BOOL:
      return false;
    case STRING:
      return "";
    case BYTES:
      return ByteString.EMPTY;
    case ENUM:
      return field.getEnumType().getValues().get(0);
    case MESSAGE:
    case GROUP:
      return builder.newBuilderForField(field).getDefaultInstanceForType();
    default:
      throw new IllegalStateException("Invalid field type: " + field.getType());
  }
}
项目:sstore-soft    文件:textformat.java   
private static void printField(final FieldDescriptor field,generator);
  }
}
项目:s-store    文件:DescriptorsTest.java   
public void testFieldDescriptorLabel() throws Exception {
  FieldDescriptor requiredField =
    Testrequired.getDescriptor().findFieldByName("a");
  FieldDescriptor optionalField =
    TestAllTypes.getDescriptor().findFieldByName("optional_int32");
  FieldDescriptor repeatedField =
    TestAllTypes.getDescriptor().findFieldByName("repeated_int32");

  assertTrue(requiredField.isrequired());
  assertFalse(requiredField.isRepeated());
  assertFalse(optionalField.isrequired());
  assertFalse(optionalField.isRepeated());
  assertFalse(repeatedField.isrequired());
  assertTrue(repeatedField.isRepeated());
}
项目:s-store    文件:Dynamicmessage.java   
public Object getField(FieldDescriptor field) {
  verifyContainingType(field);
  Object result = fields.getField(field);
  if (result == null) {
    if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
      result = getDefaultInstance(field.getMessageType());
    } else {
      result = field.getDefaultValue();
    }
  }
  return result;
}
项目:seldon-core    文件:JsonFormat.java   
private Map<String,FieldDescriptor> getFieldNameMap(Descriptor descriptor) {
  if (!fieldNameMaps.containsKey(descriptor)) {
    Map<String,FieldDescriptor> fieldNameMap = new HashMap<String,FieldDescriptor>();
    for (FieldDescriptor field : descriptor.getFields()) {
      fieldNameMap.put(field.getName(),field);
      fieldNameMap.put(field.getJsonName(),field);
    }
    fieldNameMaps.put(descriptor,fieldNameMap);
    return fieldNameMap;
  }
  return fieldNameMaps.get(descriptor);
}
项目:seldon-core    文件:JsonFormat.java   
/** Prints wrapper types (e.g.,google.protobuf.Int32Value) */
private void printWrapper(MessageOrBuilder message) throws IOException {
  Descriptor descriptor = message.getDescriptorForType();
  FieldDescriptor valueField = descriptor.findFieldByName("value");
  if (valueField == null) {
    throw new InvalidProtocolBufferException("Invalid Wrapper type.");
  }
  // When formatting wrapper types,we just print its value field instead of
  // the whole message.
  printSingleFieldValue(valueField,message.getField(valueField));
}
项目:sstore-soft    文件:GeneratedMessage.java   
/** Get one element of a repeated extension. */
@SuppressWarnings("unchecked")
public final <Type> Type getExtension(
    final GeneratedExtension<MessageType,final int index) {
  verifyExtensionContainingType(extension);
  FieldDescriptor descriptor = extension.getDescriptor();
  return (Type) extension.singularFromreflectionType(
      extensions.getRepeatedField(descriptor,index));
}
项目:seldon-core    文件:JsonFormat.java   
private void mergeStruct(JsonElement json,Message.Builder builder)
    throws InvalidProtocolBufferException {
  Descriptor descriptor = builder.getDescriptorForType();
  FieldDescriptor field = descriptor.findFieldByName("fields");
  if (field == null) {
    throw new InvalidProtocolBufferException("Invalid Struct type.");
  }
  mergeMapField(field,builder);
}
项目:sstore-soft    文件:GeneratedMessage.java   
@Override
public int getRepeatedFieldCount(final FieldDescriptor field) {
  if (field.isExtension()) {
    verifyContainingType(field);
    return extensions.getRepeatedFieldCount(field);
  } else {
    return super.getRepeatedFieldCount(field);
  }
}
项目:sstore-soft    文件:GeneratedMessage.java   
/** Set the value of an extension. */
public final <Type> BuilderType setExtension(
    final GeneratedExtension<MessageType,Type> extension,final Type value) {
  final ExtendableMessage<MessageType> message = internalGetResult();
  message.verifyExtensionContainingType(extension);
  final FieldDescriptor descriptor = extension.getDescriptor();
  message.extensions.setField(descriptor,extension.toReflectionType(value));
  return (BuilderType) this;
}
项目:sstore-soft    文件:GeneratedMessage.java   
/** Set the value of one element of a repeated extension. */
public final <Type> BuilderType setExtension(
    final GeneratedExtension<MessageType,extension.singularToReflectionType(value));
  return (BuilderType) this;
}
项目:sstore-soft    文件:GeneratedMessage.java   
/** Append a value to a repeated extension. */
public final <Type> BuilderType addExtension(
    final GeneratedExtension<MessageType,final Type value) {
  final ExtendableMessage<MessageType> message = internalGetResult();
  message.verifyExtensionContainingType(extension);
  final FieldDescriptor descriptor = extension.getDescriptor();
  message.extensions.addRepeatedField(
      descriptor,extension.singularToReflectionType(value));
  return (BuilderType) this;
}
项目:s-store    文件:Dynamicmessage.java   
private static boolean isInitialized(Descriptor type,FieldSet<FieldDescriptor> fields) {
  // Check that all required fields are present.
  for (final FieldDescriptor field : type.getFields()) {
    if (field.isrequired()) {
      if (!fields.hasField(field)) {
        return false;
      }
    }
  }

  // Check that embedded messages are initialized.
  return fields.isInitialized();
}
项目:seldon-core    文件:JsonFormat.java   
private void mergeField(FieldDescriptor field,Message.Builder builder)
    throws InvalidProtocolBufferException {
  if (field.isRepeated()) {
    if (builder.getRepeatedFieldCount(field) > 0) {
      throw new InvalidProtocolBufferException(
          "Field " + field.getFullName() + " has already been set.");
    }
  } else {
    if (builder.hasField(field)) {
      throw new InvalidProtocolBufferException(
          "Field " + field.getFullName() + " has already been set.");
    }
    if (field.getContainingOneof() != null
        && builder.getoneofFieldDescriptor(field.getContainingOneof()) != null) {
      FieldDescriptor other = builder.getoneofFieldDescriptor(field.getContainingOneof());
      throw new InvalidProtocolBufferException(
          "Cannot set field "
              + field.getFullName()
              + " because another field "
              + other.getFullName()
              + " belonging to the same oneof has already been set ");
    }
  }
  if (field.isRepeated() && json instanceof JsonNull) {
    // We allow "null" as value for all field types and treat it as if the
    // field is not present.
    return;
  }
  if (field.isMapField()) {
    mergeMapField(field,builder);
  } else if (field.isRepeated()) {
    mergeRepeatedField(field,builder);
  } else {
    Object value = parseFieldValue(field,builder);
    if (value != null) {
      builder.setField(field,value);
    }
  }
}
项目:sstore-soft    文件:GeneratedMessage.java   
/** Get the FieldAccessor for a particular field. */
private FieldAccessor getField(final FieldDescriptor field) {
  if (field.getContainingType() != descriptor) {
    throw new IllegalArgumentException(
      "FieldDescriptor does not match message type.");
  } else if (field.isExtension()) {
    // If this type had extensions,it would subclass ExtendableMessage,// which overrides the reflection interface to handle extensions.
    throw new IllegalArgumentException(
      "This type does not have extensions.");
  }
  return fields[field.getIndex()];
}
项目:s-store    文件:GeneratedMessage.java   
SingularFieldAccessor(
    final FieldDescriptor descriptor,final Class<? extends Builder> builderClass) {
  getmethod = getmethodOrDie(messageClass,"get" + camelCaseName);
  type = getmethod.getReturnType();
  setMethod = getmethodOrDie(builderClass,"set" + camelCaseName,type);
  hasMethod =
    getmethodOrDie(messageClass,"has" + camelCaseName);
  clearMethod = getmethodOrDie(builderClass,"clear" + camelCaseName);
}
项目:sstore-soft    文件:GeneratedMessage.java   
SingularEnumFieldAccessor(
    final FieldDescriptor descriptor,builderClass);

  valueOfMethod = getmethodOrDie(type,"valueOf",EnumValueDescriptor.class);
  getValueDescriptorMethod =
    getmethodOrDie(type,"getValueDescriptor");
}
项目:s-store    文件:GeneratedMessage.java   
/** Set the value of an extension. */
public final <Type> BuilderType setExtension(
    final GeneratedExtension<MessageType,extension.toReflectionType(value));
  return (BuilderType) this;
}

今天关于织梦新闻简介[field:description /]怎么修改字数限制织梦修改文章发布时间的讲解已经结束,谢谢您的阅读,如果想了解更多关于@Api(tags = "testController", description = "测试使用") 不显示description 内容、clickhouse-copier 失败了,有人遇到这个问题吗?Can''t get description node /root/t.xml/description、com.google.protobuf.Descriptors.FieldDescriptor.Type的实例源码、com.google.protobuf.Descriptors.FieldDescriptor的实例源码的相关知识,请在本站搜索。

本文标签: