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


Java Inclusion类代码示例

本文整理汇总了Java中org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion的典型用法代码示例。如果您正苦于以下问题:Java Inclusion类的具体用法?Java Inclusion怎么用?Java Inclusion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: writeObjectToJson

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
protected void writeObjectToJson(HttpServletResponse resp,Object obj) throws ServletException, IOException{
	resp.setHeader("Access-Control-Allow-Origin", "*");
	resp.setContentType("text/json");
	resp.setCharacterEncoding("UTF-8");
	ObjectMapper mapper=new ObjectMapper();
	mapper.setSerializationInclusion(Inclusion.NON_NULL);
	mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,false);
	mapper.setDateFormat(new SimpleDateFormat(Configure.getDateFormat()));
	OutputStream out = resp.getOutputStream();
	try {
		mapper.writeValue(out, obj);
	} finally {
		out.flush();
		out.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:17,代码来源:WriteJsonServletHandler.java

示例2: writeObjectToJson

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
protected void writeObjectToJson(HttpServletResponse resp,Object obj) throws ServletException, IOException{
	resp.setHeader("Access-Control-Allow-Origin", "*");
	resp.setContentType("text/json");
	resp.setCharacterEncoding("UTF-8");
	ObjectMapper mapper=new ObjectMapper();
	mapper.setSerializationInclusion(Inclusion.NON_NULL);
	mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,false);
	mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
	OutputStream out = resp.getOutputStream();
	try {
		mapper.writeValue(out, obj);
	} finally {
		out.flush();
		out.close();
	}
}
 
开发者ID:youseries,项目名称:uflo,代码行数:17,代码来源:WriteJsonServletHandler.java

示例3: JsonModelSerializer

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
public JsonModelSerializer(boolean doNullValues, Class<T> serializedType) {
		super();
		objectMapper = new ObjectMapper();
		AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
		// make serializer use JAXB annotations (only)
		SerializationConfig sc = objectMapper.getSerializationConfig().withAnnotationIntrospector(introspector);
		sc.with(SerializationConfig.Feature.INDENT_OUTPUT);
		
		if (!doNullValues) {
			sc.without(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES);
			sc.without(SerializationConfig.Feature.WRITE_EMPTY_JSON_ARRAYS);
			sc = sc.withSerializationInclusion(Inclusion.NON_EMPTY);
		}
		
		objectMapper.setSerializationConfig(sc);
//		if (!doNullValues) {
//			objectMapper.setSerializationInclusion(Inclusion.NON_EMPTY);
//		}
	}
 
开发者ID:ina-foss,项目名称:amalia-model,代码行数:20,代码来源:JsonModelSerializer.java

示例4: broadcastByActivity

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
private void broadcastByActivity(User owner, Activity activity, BaseProjectItem originalItem, BaseProjectItem updatedItem)
        throws IOException {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
    ObjectWriter ow = objectMapper.writer().withDefaultPrettyPrinter();
    activity.setSubscribers(userService.getUserByProjectId(activity.getProjectId()));
    activity.setAttachObject((BaseProjectItem)identifiableManager.getIdentifiableByTypeAndId(activity.getAttachType(),
            activity.getAttachId()));
    String message = "";
    try {
        message = ow.writeValueAsString(activity);
    } catch (IOException e) {
        e.printStackTrace();
    }
    template.convertAndSend("channel", message);
}
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:17,代码来源:RedisPublisher.java

示例5: createFieldsMapper

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
public static ObjectMapper createFieldsMapper()
	{
		ObjectMapper mapper = new ObjectMapper();

		// limit to fields only
		mapper.enable(SerializationConfig.Feature.AUTO_DETECT_FIELDS);
		mapper.enable(DeserializationConfig.Feature.AUTO_DETECT_FIELDS);
		mapper.disable(SerializationConfig.Feature.AUTO_DETECT_GETTERS);
		mapper.disable(SerializationConfig.Feature.AUTO_DETECT_IS_GETTERS);
		mapper.disable(DeserializationConfig.Feature.AUTO_DETECT_SETTERS);
		mapper.disable(DeserializationConfig.Feature.AUTO_DETECT_CREATORS);

		// general configuration
		mapper.setSerializationInclusion(Inclusion.NON_NULL);
		mapper.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
//		json.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);

		return mapper;
	}
 
开发者ID:zach-m,项目名称:gae-jersey-guice-jsf,代码行数:20,代码来源:Jackson1.java

示例6: createPropsMapper

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
public static ObjectMapper createPropsMapper()
	{
		ObjectMapper mapper = new ObjectMapper();

		// limit to properties only
		mapper.disable(SerializationConfig.Feature.AUTO_DETECT_FIELDS);
		mapper.enable(SerializationConfig.Feature.AUTO_DETECT_GETTERS);
		mapper.enable(SerializationConfig.Feature.AUTO_DETECT_IS_GETTERS);
		mapper.disable(DeserializationConfig.Feature.AUTO_DETECT_FIELDS);
		mapper.enable(DeserializationConfig.Feature.AUTO_DETECT_SETTERS);
		mapper.enable(DeserializationConfig.Feature.AUTO_DETECT_CREATORS);

		// general configuration
		mapper.setSerializationInclusion(Inclusion.NON_NULL);
		mapper.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
//		json.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);

		return mapper;
	}
 
开发者ID:zach-m,项目名称:gae-jersey-guice-jsf,代码行数:20,代码来源:Jackson1.java

示例7: fromAnnotations

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
public void fromAnnotations(Class<?> paramClass)
{
  AnnotationIntrospector localAnnotationIntrospector = getAnnotationIntrospector();
  AnnotatedClass localAnnotatedClass = AnnotatedClass.construct(paramClass, localAnnotationIntrospector, null);
  this._base = this._base.withVisibilityChecker(localAnnotationIntrospector.findAutoDetectVisibility(localAnnotatedClass, getDefaultVisibilityChecker()));
  JsonSerialize.Inclusion localInclusion = localAnnotationIntrospector.findSerializationInclusion(localAnnotatedClass, null);
  if (localInclusion != this._serializationInclusion)
    setSerializationInclusion(localInclusion);
  JsonSerialize.Typing localTyping = localAnnotationIntrospector.findSerializationTyping(localAnnotatedClass);
  Feature localFeature;
  if (localTyping != null)
  {
    localFeature = Feature.USE_STATIC_TYPING;
    if (localTyping != JsonSerialize.Typing.STATIC)
      break label92;
  }
  label92: for (boolean bool = true; ; bool = false)
  {
    set(localFeature, bool);
    return;
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:23,代码来源:SerializationConfig.java

示例8: BaseLensCommand

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
 * Instantiates a new base lens command.
 */
public BaseLensCommand() {
  mapper = new ObjectMapper();
  mapper.setSerializationInclusion(Inclusion.NON_NULL);
  mapper.setSerializationInclusion(Inclusion.NON_DEFAULT);
  pp = new DefaultPrettyPrinter();
  pp.indentObjectsWith(new Indenter() {
    @Override
    public void writeIndentation(JsonGenerator jg, int level) throws IOException {
      jg.writeRaw("\n");
      for (int i = 0; i < level; i++) {
        jg.writeRaw(" ");
      }
    }

    @Override
    public boolean isInline() {
      return false;
    }
  });
}
 
开发者ID:apache,项目名称:lens,代码行数:24,代码来源:BaseLensCommand.java

示例9: StarTreeIndexViewer

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
public StarTreeIndexViewer(File segmentDir) throws Exception {
  IndexSegment indexSegment = Loaders.IndexSegment.load(segmentDir, ReadMode.heap);

  dictionaries = new HashMap<String, Dictionary>();
  valueIterators = new HashMap<String, BlockSingleValIterator>();
  SegmentMetadataImpl metadata = new SegmentMetadataImpl(segmentDir);

  for (String columnName : metadata.getAllColumns()) {
    DataSource dataSource = indexSegment.getDataSource(columnName);
    Block block = dataSource.nextBlock();
    BlockValSet blockValSet = block.getBlockValueSet();
    BlockSingleValIterator itr = (BlockSingleValIterator) blockValSet.iterator();
    valueIterators.put(columnName, itr);
    dictionaries.put(columnName, dataSource.getDictionary());
  }
  File starTreeFile = SegmentDirectoryPaths.findStarTreeFile(segmentDir);
  StarTree tree = new OffHeapStarTree(starTreeFile, ReadMode.mmap);
  _dimensionNames = tree.getDimensionNames();
  StarTreeJsonNode jsonRoot = new StarTreeJsonNode("ROOT");
  build(tree.getRoot(), jsonRoot);
  ObjectMapper objectMapper = new ObjectMapper();
  objectMapper.getSerializationConfig().withSerializationInclusion(Inclusion.NON_NULL);
  String writeValueAsString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonRoot);
  LOGGER.info(writeValueAsString);
  startServer(segmentDir, writeValueAsString);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:27,代码来源:StarTreeIndexViewer.java

示例10: fromAnnotations

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
/**
 * Method that checks class annotations that the argument Object has,
 * and modifies settings of this configuration object accordingly,
 * similar to how those annotations would affect actual value classes
 * annotated with them, but with global scope. Note that not all
 * annotations have global significance, and thus only subset of
 * Jackson annotations will have any effect.
 *<p>
 * Serialization annotations that are known to have effect are:
 *<ul>
 * <li>{@link JsonWriteNullProperties}</li>
 * <li>{@link JsonAutoDetect}</li>
 * <li>{@link JsonSerialize#typing}</li>
 *</ul>
 * 
 * @param cls Class of which class annotations to use
 *   for changing configuration settings
 */
//@Override
public void fromAnnotations(Class<?> cls)
{
    /* 10-Jul-2009, tatu: Should be able to just pass null as
     *    'MixInResolver'; no mix-ins set at this point
     * 29-Jul-2009, tatu: Also, we do NOT ignore annotations here, even
     *    if Feature.USE_ANNOTATIONS was disabled, since caller
     *    specifically requested annotations to be added with this call
     */
    AnnotatedClass ac = AnnotatedClass.construct(cls, _annotationIntrospector, null);
    _visibilityChecker = _annotationIntrospector.findAutoDetectVisibility(ac, _visibilityChecker);

    // How about writing null property values?
    JsonSerialize.Inclusion incl = _annotationIntrospector.findSerializationInclusion(ac, null);
    if (incl != _serializationInclusion) {
        setSerializationInclusion(incl);
	}

    JsonSerialize.Typing typing = _annotationIntrospector.findSerializationTyping(ac);
    if (typing != null) {
        set(Feature.USE_STATIC_TYPING, (typing == JsonSerialize.Typing.STATIC));
    }
}
 
开发者ID:r00li,项目名称:RHome,代码行数:42,代码来源:SerializationConfig.java

示例11: toJson

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
public static String toJson(Object object) {
	ObjectMapper mapper = new ObjectMapper(new MyJsonFactory());
	SimpleModule module = new SimpleModule("fullcalendar", new Version(1, 0, 0, null));
	module.addSerializer(new DateTimeSerializer());
	module.addSerializer(new LocalTimeSerializer());
	mapper.registerModule(module);
	mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);

	String json = null;
	try {
		json = mapper.writeValueAsString(object);
	} catch (Exception e) {
		throw new RuntimeException("Error encoding object: " + object + " into JSON string", e);
	}
	return json;
}
 
开发者ID:micromata,项目名称:projectforge-webapp,代码行数:17,代码来源:Json.java

示例12: ApiHttpMessage

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
@JsonCreator
protected ApiHttpMessage(@JsonProperty("httpRequest") HttpRequest httpRequest,
                         @JsonProperty("version") String version,
                         @JsonProperty("domain") String domain,
                         @JsonProperty("actorId") String actorId,
                         @JsonProperty("action") String action) {
    this.httpRequest = httpRequest;
    this.actorId = actorId;
    this.domain = domain;
    this.version = version;
    this.action = action;

    // init object mapper
    objectMapper = new ObjectMapper();
    //objectMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
    objectMapper.setSerializationInclusion(Inclusion.NON_NULL);
}
 
开发者ID:elasticsoftwarefoundation,项目名称:elasterix,代码行数:18,代码来源:ApiHttpMessage.java

示例13: getObjectMapper

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
@Provides
public ObjectMapper getObjectMapper() {
	// configure objectmapper and provide it
	SimpleModule module = new SimpleModule("SimpleAbstractTypeResolver", Version.unknownVersion());
	module.addAbstractTypeMapping(MutableBlobProperties.class, MutableBlobPropertiesImpl.class);
	module.addAbstractTypeMapping(MutableContentMetadata.class, BaseMutableContentMetadata.class);
	module.addAbstractTypeMapping(OrionSpecificFileMetadata.class, OrionSpecificFileMetadataImpl.class);
	module.addAbstractTypeMapping(Attributes.class, AttributesImpl.class);
	module.addAbstractTypeMapping(OrionError.class, OrionErrorImpl.class);
	module.addAbstractTypeMapping(OrionChildMetadata.class, OrionChildMetadataImpl.class);
	ObjectMapper mapper = new ObjectMapper();
	mapper.registerModule(module);
	mapper.setSerializationInclusion(Inclusion.NON_NULL);
	mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	return mapper;
}
 
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:17,代码来源:OrionCustomModule.java

示例14: simpleTest

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
@Test
public void simpleTest( ) throws JsonGenerationException, JsonMappingException, IOException {
    UserDao userDao = new UserDao();
    userDao.setName("sss");

    TwitterAccountDao accountDao = new TwitterAccountDao();
    accountDao.setAccessToken("1234");
    accountDao.setAccessTokenSecret("456");
    accountDao.setAccountName("test");
    accountDao.setDeleted(false);
    accountDao.setExternalId(1l);
    accountDao.setId(1l);

    userDao.setAccounts(new HashSet<>(Arrays.asList(accountDao)));
    accountDao.addUser(userDao);

    ObjectMapper objectMapper = new ObjectMapper();

    objectMapper.getSerializationConfig().withSerializationInclusion(Inclusion.NON_NULL);
    String result = objectMapper.writeValueAsString(userDao);
}
 
开发者ID:voncuver,项目名称:cwierkacz,代码行数:22,代码来源:TwitterAccountDaoTest.java

示例15: pushKnowledgePackageToClients

import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; //导入依赖的package包/类
public void pushKnowledgePackageToClients(HttpServletRequest req, HttpServletResponse resp) throws Exception {
	String project=req.getParameter("project");
	project=Utils.decodeURL(project);
	String packageId=project+"/"+Utils.decodeURL(req.getParameter("packageId"));
	if(packageId.startsWith("/")){
		packageId=packageId.substring(1,packageId.length());
	}
	KnowledgePackage knowledgePackage=CacheUtils.getKnowledgeCache().getKnowledge(packageId);
	
	ObjectMapper mapper=new ObjectMapper();
	mapper.setSerializationInclusion(Inclusion.NON_NULL);
	mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,false);
	mapper.setDateFormat(new SimpleDateFormat(Configure.getDateFormat()));
	StringWriter writer=new StringWriter();
	mapper.writeValue(writer, new KnowledgePackageWrapper(knowledgePackage));
	String content=writer.getBuffer().toString();
	writer.close();
	StringBuffer sb=new StringBuffer();
	List<ClientConfig> clients=repositoryService.loadClientConfigs(project);
	int i=0;
	for(ClientConfig config:clients){
		if(i>0){
			sb.append("<br>");
		}
		boolean result=pushKnowledgePackage(packageId,content,config.getClient());
		if(result){
			sb.append("<span class=\"text-info\" style='line-height:30px'>推送到客户端:"+config.getName()+":"+config.getClient()+" 成功</span>");
		}else{
			sb.append("<span class=\"text-danger\" style='line-height:30px'>推送到客户端:"+config.getName()+":"+config.getClient()+" 失败</span>");
		}
		i++;
	}
	Map<String,Object> map=new HashMap<String,Object>();
	map.put("info", sb.toString());
	writeObjectToJson(resp, map);
}
 
开发者ID:youseries,项目名称:urule,代码行数:37,代码来源:PackageServletHandler.java


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