本文整理汇总了Java中org.codehaus.jackson.map.PropertyNamingStrategy类的典型用法代码示例。如果您正苦于以下问题:Java PropertyNamingStrategy类的具体用法?Java PropertyNamingStrategy怎么用?Java PropertyNamingStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyNamingStrategy类属于org.codehaus.jackson.map包,在下文中一共展示了PropertyNamingStrategy类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: AbstractFeatureTestCase
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
public AbstractFeatureTestCase() throws IOException, URISyntaxException {
final FileInputStream stream = new FileInputStream(new File(this.getClass()
.getResource(SAMPLE_TWEET_FILENAME).toURI()));
try {
final FileChannel fc = stream.getChannel();
final MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
String json = Charset.defaultCharset().decode(bb).toString();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper
.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
objectMapper.setDateFormat(new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy"));
sampleTweet = objectMapper.readValue(json, Tweet.class);
} finally {
stream.close();
}
}
开发者ID:Cybion-Italy,项目名称:socialeyeser,代码行数:22,代码来源:AbstractFeatureTestCase.java
示例2: buildSampleTweet
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
private Tweet buildSampleTweet() throws URISyntaxException, IOException {
final FileInputStream stream = new FileInputStream(new File(this.getClass()
.getResource(SAMPLE_TWEET_FILENAME).toURI()));
try {
final FileChannel fc = stream.getChannel();
final MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
String json = Charset.defaultCharset().decode(bb).toString();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper
.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
objectMapper.setDateFormat(new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy"));
Tweet sampleTweet = objectMapper.readValue(json, Tweet.class);
return sampleTweet;
} finally {
stream.close();
}
}
开发者ID:Cybion-Italy,项目名称:socialeyeser,代码行数:22,代码来源:CrisisDetectorTestCase.java
示例3: TrendsMiner
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
public TrendsMiner(String consumerKey, String consumerSecret, String userKey, String userSecret)
throws FileNotFoundException {
stats = new PrintStream(new File("/Data/alerts.txt"));
this.mapper = new ObjectMapper();
this.mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.mapper
.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
this.mapper.setDateFormat(new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy"));
this.applicationConsumerKey = consumerKey;
this.applicationConsumerSecret = consumerSecret;
this.userKey = userKey;
this.userSecret = userSecret;
registerShutdownHook();
initDetector();
}
开发者ID:Cybion-Italy,项目名称:socialeyeser,代码行数:22,代码来源:TrendsMiner.java
示例4: StreamReplayer
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
public StreamReplayer(double speedFactor, String jsonZipPath) {
this.speedFactor = speedFactor;
this.mapper = new ObjectMapper();
this.mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.mapper
.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
this.mapper.setDateFormat(new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy"));
try {
initStream(jsonZipPath);
} catch (IOException e) {
LOGGER.error("Could not init stream: " + e.getMessage());
}
}
开发者ID:Cybion-Italy,项目名称:socialeyeser,代码行数:18,代码来源:StreamReplayer.java
示例5: collect
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
public POJOPropertiesCollector collect()
{
this._properties.clear();
_addFields();
_addMethods();
_addCreators();
_addInjectables();
_removeUnwantedProperties();
_renameProperties();
PropertyNamingStrategy localPropertyNamingStrategy = this._config.getPropertyNamingStrategy();
if (localPropertyNamingStrategy != null)
_renameUsing(localPropertyNamingStrategy);
Iterator localIterator1 = this._properties.values().iterator();
while (localIterator1.hasNext())
((POJOPropertyBuilder)localIterator1.next()).trimByVisibility();
Iterator localIterator2 = this._properties.values().iterator();
while (localIterator2.hasNext())
((POJOPropertyBuilder)localIterator2.next()).mergeAnnotations(this._forSerialization);
_sortProperties();
return this;
}
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:22,代码来源:POJOPropertiesCollector.java
示例6: Client
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
/**
* @param apiKey your Stripe api key
* @param failOnUnknownProperties If true, a {@link org.codehaus.jackson.map.JsonMappingException} is thrown when
* unknown Stripe response object properties are encountered. This is primarily used for
* testing / debugging purposes.
*/
public Client(String apiKey, boolean failOnUnknownProperties) {
ObjectMapper mapper = new ObjectMapper();
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, failOnUnknownProperties);
mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
mapper.registerModule(new StripeModule());
DefaultClientConfig config = new DefaultClientConfig();
config.getSingletons().add(new JacksonJsonProvider(mapper));
com.sun.jersey.api.client.Client client = com.sun.jersey.api.client.Client.create(config);
client.addFilter(new HTTPBasicAuthFilter(apiKey, ""));
service = client.resource(UriBuilder.fromUri(BASE_URL + VERSION + "/").build());
}
开发者ID:jlinn,项目名称:stripe-api-java,代码行数:21,代码来源:Client.java
示例7: JsonOutputter
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
public JsonOutputter() {
mapper = new ObjectMapper();
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:7,代码来源:JsonOutputter.java
示例8: toRequest
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected MultivaluedMap<String, String> toRequest(Request request, final String prefix){
MultivaluedMapImpl map = new MultivaluedMapImpl();
Class cls = request.getClass();
PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy naming = new PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy();
while(!cls.equals(Request.class)){
for (Field field : cls.getDeclaredFields()) {
try {
boolean inaccessible = false;
if(!Modifier.isPublic(field.getModifiers())){
field.setAccessible(true);
inaccessible = true;
}
Object fieldValue = field.get(request);
if(fieldValue != null){
String key = naming.translate(field.getName());
if(prefix != null){
key = prefix + "[" + key + "]";
}
if(fieldValue instanceof Map){
map.putAll(mapToRequest((Map) fieldValue, key));
}
else if(fieldValue instanceof Request){
map.putAll(toRequest((Request) fieldValue, key));
}
else if(fieldValue instanceof Date){
map.add(key, dateToString((Date) fieldValue));
}
else{
map.add(key, String.valueOf(fieldValue));
}
}
if(inaccessible){
field.setAccessible(false);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
cls = cls.getSuperclass();
}
return map;
}
开发者ID:jlinn,项目名称:stripe-api-java,代码行数:44,代码来源:Request.java
示例9: _findPropertyFields
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
public LinkedHashMap<String, AnnotatedField> _findPropertyFields(VisibilityChecker<?> paramVisibilityChecker, Collection<String> paramCollection, boolean paramBoolean)
{
LinkedHashMap localLinkedHashMap = new LinkedHashMap();
PropertyNamingStrategy localPropertyNamingStrategy = this._config.getPropertyNamingStrategy();
Iterator localIterator = this._classInfo.fields().iterator();
label271:
while (localIterator.hasNext())
{
AnnotatedField localAnnotatedField1 = (AnnotatedField)localIterator.next();
String str1;
if (paramBoolean)
{
str1 = this._annotationIntrospector.findSerializablePropertyName(localAnnotatedField1);
label69: if (str1 == null)
break label232;
if (str1.length() == 0)
{
str1 = localAnnotatedField1.getName();
if (localPropertyNamingStrategy != null)
str1 = localPropertyNamingStrategy.nameForField(this._config, localAnnotatedField1, str1);
}
}
while (true)
{
if ((paramCollection != null) && (paramCollection.contains(str1)))
break label271;
AnnotatedField localAnnotatedField2 = (AnnotatedField)localLinkedHashMap.put(str1, localAnnotatedField1);
if ((localAnnotatedField2 == null) || (localAnnotatedField2.getDeclaringClass() != localAnnotatedField1.getDeclaringClass()))
break;
String str2 = localAnnotatedField2.getFullName();
String str3 = localAnnotatedField1.getFullName();
throw new IllegalArgumentException("Multiple fields representing property \"" + str1 + "\": " + str2 + " vs " + str3);
str1 = this._annotationIntrospector.findDeserializablePropertyName(localAnnotatedField1);
break label69;
label232: if (!paramVisibilityChecker.isFieldVisible(localAnnotatedField1))
break;
str1 = localAnnotatedField1.getName();
if (localPropertyNamingStrategy == null)
continue;
str1 = localPropertyNamingStrategy.nameForField(this._config, localAnnotatedField1, str1);
}
}
return localLinkedHashMap;
}
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:45,代码来源:BasicBeanDescription.java
示例10: findGetters
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
public LinkedHashMap<String, AnnotatedMethod> findGetters(VisibilityChecker<?> paramVisibilityChecker, Collection<String> paramCollection)
{
LinkedHashMap localLinkedHashMap = new LinkedHashMap();
PropertyNamingStrategy localPropertyNamingStrategy = this._config.getPropertyNamingStrategy();
Iterator localIterator = this._classInfo.memberMethods().iterator();
label130: label305: label327:
while (localIterator.hasNext())
{
AnnotatedMethod localAnnotatedMethod1 = (AnnotatedMethod)localIterator.next();
if (localAnnotatedMethod1.getParameterCount() != 0)
continue;
String str1 = this._annotationIntrospector.findGettablePropertyName(localAnnotatedMethod1);
String str2;
if (str1 != null)
{
if (str1.length() == 0)
{
str1 = okNameForAnyGetter(localAnnotatedMethod1, localAnnotatedMethod1.getName());
if (str1 == null)
str1 = localAnnotatedMethod1.getName();
if (localPropertyNamingStrategy != null)
str1 = localPropertyNamingStrategy.nameForGetterMethod(this._config, localAnnotatedMethod1, str1);
}
if ((paramCollection == null) || (!paramCollection.contains(str1)))
{
AnnotatedMethod localAnnotatedMethod2 = (AnnotatedMethod)localLinkedHashMap.put(str1, localAnnotatedMethod1);
if (localAnnotatedMethod2 == null)
continue;
String str3 = localAnnotatedMethod2.getFullName();
String str4 = localAnnotatedMethod1.getFullName();
throw new IllegalArgumentException("Conflicting getter definitions for property \"" + str1 + "\": " + str3 + " vs " + str4);
}
}
else
{
str2 = localAnnotatedMethod1.getName();
if (!str2.startsWith("get"))
break label305;
if (!paramVisibilityChecker.isGetterVisible(localAnnotatedMethod1))
continue;
}
for (str1 = okNameForGetter(localAnnotatedMethod1, str2); ; str1 = okNameForIsGetter(localAnnotatedMethod1, str2))
{
if ((str1 == null) || (this._annotationIntrospector.hasAnyGetterAnnotation(localAnnotatedMethod1)))
break label327;
if (localPropertyNamingStrategy == null)
break label130;
str1 = localPropertyNamingStrategy.nameForGetterMethod(this._config, localAnnotatedMethod1, str1);
break label130;
break;
if (!paramVisibilityChecker.isIsGetterVisible(localAnnotatedMethod1))
break;
}
}
return localLinkedHashMap;
}
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:57,代码来源:BasicBeanDescription.java
示例11: findSetters
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
public LinkedHashMap<String, AnnotatedMethod> findSetters(VisibilityChecker<?> paramVisibilityChecker)
{
LinkedHashMap localLinkedHashMap = new LinkedHashMap();
PropertyNamingStrategy localPropertyNamingStrategy = this._config.getPropertyNamingStrategy();
Iterator localIterator = this._classInfo.memberMethods().iterator();
while (localIterator.hasNext())
{
AnnotatedMethod localAnnotatedMethod1 = (AnnotatedMethod)localIterator.next();
if (localAnnotatedMethod1.getParameterCount() != 1)
continue;
String str1 = this._annotationIntrospector.findSettablePropertyName(localAnnotatedMethod1);
if (str1 != null)
if (str1.length() == 0)
{
str1 = okNameForSetter(localAnnotatedMethod1);
if (str1 == null)
str1 = localAnnotatedMethod1.getName();
if (localPropertyNamingStrategy != null)
str1 = localPropertyNamingStrategy.nameForSetterMethod(this._config, localAnnotatedMethod1, str1);
}
AnnotatedMethod localAnnotatedMethod2;
while (true)
{
localAnnotatedMethod2 = (AnnotatedMethod)localLinkedHashMap.put(str1, localAnnotatedMethod1);
if (localAnnotatedMethod2 == null)
break;
if (localAnnotatedMethod2.getDeclaringClass() != localAnnotatedMethod1.getDeclaringClass())
break label262;
String str2 = localAnnotatedMethod2.getFullName();
String str3 = localAnnotatedMethod1.getFullName();
throw new IllegalArgumentException("Conflicting setter definitions for property \"" + str1 + "\": " + str2 + " vs " + str3);
if (!paramVisibilityChecker.isSetterVisible(localAnnotatedMethod1))
break;
str1 = okNameForSetter(localAnnotatedMethod1);
if (str1 == null)
break;
if (localPropertyNamingStrategy == null)
continue;
str1 = localPropertyNamingStrategy.nameForSetterMethod(this._config, localAnnotatedMethod1, str1);
}
label262: localLinkedHashMap.put(str1, localAnnotatedMethod2);
}
return localLinkedHashMap;
}
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:45,代码来源:BasicBeanDescription.java
示例12: createMapper
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
/**
* Creates and configures the object mapper to use to map responses to java objects.
* @return Returns an ObjectMapper.
*/
protected ObjectMapper createMapper() {
ObjectMapper retVal = new ObjectMapper();
retVal.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
return retVal;
}
开发者ID:ludokx,项目名称:jelp,代码行数:10,代码来源:DefaultYelpV2Client.java
示例13: _renameUsing
import org.codehaus.jackson.map.PropertyNamingStrategy; //导入依赖的package包/类
protected void _renameUsing(PropertyNamingStrategy paramPropertyNamingStrategy)
{
POJOPropertyBuilder[] arrayOfPOJOPropertyBuilder = (POJOPropertyBuilder[])this._properties.values().toArray(new POJOPropertyBuilder[this._properties.size()]);
this._properties.clear();
int i = arrayOfPOJOPropertyBuilder.length;
int j = 0;
POJOPropertyBuilder localPOJOPropertyBuilder1;
String str1;
String str2;
if (j < i)
{
localPOJOPropertyBuilder1 = arrayOfPOJOPropertyBuilder[j];
str1 = localPOJOPropertyBuilder1.getName();
if (this._forSerialization)
if (localPOJOPropertyBuilder1.hasGetter())
str2 = paramPropertyNamingStrategy.nameForGetterMethod(this._config, localPOJOPropertyBuilder1.getGetter(), str1);
}
while (true)
{
label90: if (!str2.equals(localPOJOPropertyBuilder1.getName()))
localPOJOPropertyBuilder1 = localPOJOPropertyBuilder1.withName(str2);
POJOPropertyBuilder localPOJOPropertyBuilder2 = (POJOPropertyBuilder)this._properties.get(str2);
if (localPOJOPropertyBuilder2 == null)
this._properties.put(str2, localPOJOPropertyBuilder1);
while (true)
{
j++;
break;
if (!localPOJOPropertyBuilder1.hasField())
break label300;
str2 = paramPropertyNamingStrategy.nameForField(this._config, localPOJOPropertyBuilder1.getField(), str1);
break label90;
if (localPOJOPropertyBuilder1.hasSetter())
{
str2 = paramPropertyNamingStrategy.nameForSetterMethod(this._config, localPOJOPropertyBuilder1.getSetter(), str1);
break label90;
}
if (localPOJOPropertyBuilder1.hasConstructorParameter())
{
str2 = paramPropertyNamingStrategy.nameForConstructorParameter(this._config, localPOJOPropertyBuilder1.getConstructorParameter(), str1);
break label90;
}
if (localPOJOPropertyBuilder1.hasField())
{
str2 = paramPropertyNamingStrategy.nameForField(this._config, localPOJOPropertyBuilder1.getField(), str1);
break label90;
}
if (!localPOJOPropertyBuilder1.hasGetter())
break label300;
str2 = paramPropertyNamingStrategy.nameForGetterMethod(this._config, localPOJOPropertyBuilder1.getGetter(), str1);
break label90;
localPOJOPropertyBuilder2.addAll(localPOJOPropertyBuilder1);
}
return;
label300: str2 = str1;
}
}
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:58,代码来源:POJOPropertiesCollector.java
注:本文中的org.codehaus.jackson.map.PropertyNamingStrategy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论