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


Java MimeTypeUtils.parseMimeType方法代码示例

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


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

示例1: read

import org.springframework.util.MimeTypeUtils; //导入方法依赖的package包/类
public void read(String mimeType, InputStream is) throws IOException {
    Assert.hasText(mimeType, "MimeType string is null or empty.");
    Assert.notNull(is, "InputStream is null or empty.");
    MimeType mimeTypeObj = MimeTypeUtils.parseMimeType(mimeType);
    if(MimeTypeUtils.APPLICATION_JSON.equals(mimeTypeObj)) {
        Assert.hasText(mimeType, "MimeType '" + mimeType + "' is not supported.");
    }
    AppConfigObject aco = objectMapper.readValue(is, AppConfigObject.class);
    final String version = aco.getVersion();
    if(!VERSION.equals(version)) {
        throw new RuntimeException("Unsupported version of config: " + version);
    }

    ConfigReadContext ctx = new ConfigReadContext();
    Map<String, Object> map = aco.getData();
    Assert.notNull(map, "config has empty map");
    for(Map.Entry<String, Object> oe : map.entrySet()) {
        String name = oe.getKey();
        ReConfigurableAdapter ca = adapters.get(name);
        Assert.notNull(ca, "Can not find adapter with name: " + name);
        Object value = oe.getValue();
        Assert.notNull(value, "Config object is null for name: " + name);
        ca.setConfig(ctx, value);
    }
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:26,代码来源:AppConfigService.java

示例2: updateSimpMessageHeadersFromStompHeaders

import org.springframework.util.MimeTypeUtils; //导入方法依赖的package包/类
void updateSimpMessageHeadersFromStompHeaders() {
	if (getNativeHeaders() == null) {
		return;
	}
	String value = getFirstNativeHeader(STOMP_DESTINATION_HEADER);
	if (value != null) {
		super.setDestination(value);
	}
	value = getFirstNativeHeader(STOMP_CONTENT_TYPE_HEADER);
	if (value != null) {
		super.setContentType(MimeTypeUtils.parseMimeType(value));
	}
	StompCommand command = getCommand();
	if (StompCommand.MESSAGE.equals(command)) {
		value = getFirstNativeHeader(STOMP_SUBSCRIPTION_HEADER);
		if (value != null) {
			super.setSubscriptionId(value);
		}
	}
	else if (StompCommand.SUBSCRIBE.equals(command) || StompCommand.UNSUBSCRIBE.equals(command)) {
		value = getFirstNativeHeader(STOMP_ID_HEADER);
		if (value != null) {
			super.setSubscriptionId(value);
		}
	}
	else if (StompCommand.CONNECT.equals(command)) {
		protectPasscode();
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:StompHeaderAccessor.java

示例3: write

import org.springframework.util.MimeTypeUtils; //导入方法依赖的package包/类
/**
 */
public void write(String mimeType, OutputStream os) throws IOException {
    Assert.hasText(mimeType, "MimeType string is null or empty.");
    Assert.notNull(os, "OutputStream is null or empty.");
    MimeType mimeTypeObj = MimeTypeUtils.parseMimeType(mimeType);
    if(MimeTypeUtils.APPLICATION_JSON.equals(mimeTypeObj)) {
        Assert.hasText(mimeType, "MimeType '" + mimeType + "' is not supported.");
    }
    AppConfigObject aco = new AppConfigObject();
    aco.setDate(LocalDateTime.now());
    aco.setVersion(VERSION);
    Map<String, Object> map = new HashMap<>();
    aco.setData(map);
    ConfigWriteContext ctx = ConfigWriteContext.builder()
      .mimeType(mimeTypeObj)
      .build();
    for(ConcurrentMap.Entry<String, ReConfigurableAdapter> cae : adapters.entrySet()) {
        ReConfigurableAdapter ca = cae.getValue();
        Object o = ca.getConfig(ctx);
        if(o == null) {
            continue;
        }
        String name = cae.getKey();
        map.put(name, o);
    }
    objectMapper.writeValue(os, aco);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:29,代码来源:AppConfigService.java

示例4: isValidContentType

import org.springframework.util.MimeTypeUtils; //导入方法依赖的package包/类
/**
 * Indicates whether the content type represented by the given string
 * is a valid, known content type.
 * 
 * @param contentType the content type string.
 * @return true if the content is valid, false if not.
 */
public static boolean isValidContentType( String contentType )
{
    try
    {
        MimeTypeUtils.parseMimeType( contentType );
    }
    catch ( InvalidMimeTypeException ignored )
    {
        return false;
    }

    return true;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:21,代码来源:FileResourceUtils.java

示例5: isValidContentType

import org.springframework.util.MimeTypeUtils; //导入方法依赖的package包/类
private boolean isValidContentType( String contentType )
{
    try
    {
        MimeTypeUtils.parseMimeType( contentType );
    }
    catch ( InvalidMimeTypeException e )
    {
        return false;
    }

    return true;
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:14,代码来源:FileResourceController.java

示例6: getContentType

import org.springframework.util.MimeTypeUtils; //导入方法依赖的package包/类
/**
 * Return the content-type header value.
 */
public MimeType getContentType() {
	String value = getFirst(CONTENT_TYPE);
	return (StringUtils.hasLength(value) ? MimeTypeUtils.parseMimeType(value) : null);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:StompHeaders.java

示例7: deserialize

import org.springframework.util.MimeTypeUtils; //导入方法依赖的package包/类
@Override
public MimeType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    String mimeString = p.readValueAs(String.class);
    return MimeTypeUtils.parseMimeType(mimeString);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:6,代码来源:MimeTypeDeserializer.java

示例8: parse

import org.springframework.util.MimeTypeUtils; //导入方法依赖的package包/类
/***************************************************************************
 *                                                                         *
 * Static builder                                                          *
 *                                                                         *
 **************************************************************************/

public static MimeType parse(String mimeType){
    org.springframework.util.MimeType spring = MimeTypeUtils.parseMimeType(mimeType);
    return new MimeType(spring.getType(), spring.getSubtype());
}
 
开发者ID:Vidada-Project,项目名称:vidada-server,代码行数:11,代码来源:MimeType.java


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