Skip navigation links
com.auxiliary.http

Enum MessageType

    • Enum Constant Detail

      • JSON

        public static final MessageType JSON
        json类型
      • HTML

        public static final MessageType HTML
        html类型
      • RAW

        public static final MessageType RAW
        纯文本类型
      • FORM_DATA

        public static final MessageType FORM_DATA
        表单类型
      • X_WWW_FORM_URLENCODED

        public static final MessageType X_WWW_FORM_URLENCODED
        表单上传编码类型
      • BINARY

        public static final MessageType BINARY
        二进制编码类型
      • FILE

        public static final MessageType FILE
        文件类型
      • NONE

        public static final MessageType NONE
        无报文类型
    • Method Detail

      • values

        public static MessageType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (MessageType c : MessageType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static MessageType valueOf(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getMediaValue

        public String getMediaValue()
        该方法用于返回报文类型名称
        Returns:
        报文类型名称
        Since:
        autest 3.3.0
      • typeOf

        public static MessageType typeOf(String typeName)
        该方法用于比对消息类型名称,返回对应的消息类型枚举
        Parameters:
        typeName - 消息类型名称
        Returns:
        消息类型枚举
        Since:
        autest 3.3.0
      • setCharset

        public MessageType setCharset(String charset)
        该方法用于设置报文类型的编码格式
        Parameters:
        charset - 编码格式名称字符串
        Returns:
        枚举本身
        Since:
        autest 3.6.0
      • toMessageTypeString

        public String toMessageTypeString()
        该方法用于返回报文类型的详细文本内容(包含编码)
        Returns:
        报文类型的详细文本内容
        Since:
        autest 3.6.0
      • typeText2Type

        public static MessageType typeText2Type(String type)
        该方法用于将枚举文本转换为消息枚举

        该方法本质上与valueOf(String)方法的作用一致,但其中加上了对文本的内容的判空、对文本内容大写转换、 对特殊文本进行处理以及对异常文本进行汉化的操作。可转换的枚举文本如下:

        • 若文本为“text”,则转换为“raw”输出
        • 若文本为“fd”,则转换为“form-data”输出
        • 若文本为“fu”,则转换为“X-WWW-FORM-URLENCODED”输出
        Parameters:
        type - 枚举文本内容
        Returns:
        转换后的枚举
        Throws:
        IllegalArgumentException - 当枚举文本为空或不能转换成枚举时抛出的异常
        Since:
        autest 3.7.0
      • typeText2Type

        public static MessageType typeText2Type(String type,
                                                Function<String,String> mapper)
        该方法用于将枚举文本转换为消息枚举

        该方法与typeText2Type(String)方法类似,其可对传入的文本进行自定义的转换,例如欲将传入的"text"转换为"raw",则可写为

         MessageType.typeText2MessageType("text", type -> {
              if ("text".equals(text)) {
                  text = "raw";
              }
        
              return text;
         });
         

        Parameters:
        type - 枚举文本内容
        mapper - 枚举文本的处理方法
        Returns:
        转换后的枚举
        Throws:
        IllegalArgumentException - 当枚举文本为空或不能转换成枚举时抛出的异常
        Since:
        autest 3.7.0

Copyright © 2024. All rights reserved.