Browse Source

Polishing

pull/868/head
Juergen Hoeller 11 years ago
parent
commit
566ea30167
  1. 2
      spring-core/src/main/java/org/springframework/core/ResolvableType.java
  2. 2
      spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
  3. 8
      spring-core/src/main/java/org/springframework/core/serializer/DefaultSerializer.java
  4. 11
      spring-core/src/main/java/org/springframework/core/serializer/support/SerializingConverter.java

2
spring-core/src/main/java/org/springframework/core/ResolvableType.java

@ -389,7 +389,7 @@ public class ResolvableType implements Serializable {
* implement or extend the specified class. * implement or extend the specified class.
* @param type the required class type * @param type the required class type
* @return a {@link ResolvableType} representing this object as the specified * @return a {@link ResolvableType} representing this object as the specified
* type or {@link #NONE} * type, or {@link #NONE} if not resolvable as that type
* @see #asCollection() * @see #asCollection()
* @see #asMap() * @see #asMap()
* @see #getSuperType() * @see #getSuperType()

2
spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

@ -201,7 +201,7 @@ public class TypeDescriptor implements Serializable {
/** /**
* Cast this {@link TypeDescriptor} to a superclass or implemented interface * Cast this {@link TypeDescriptor} to a superclass or implemented interface
* preserving annotations and nested type context. * preserving annotations and nested type context.
* @param superType the super type to cast to (can be {@code null} * @param superType the super type to cast to (can be {@code null})
* @return a new TypeDescriptor for the up-cast type * @return a new TypeDescriptor for the up-cast type
* @throws IllegalArgumentException if this type is not assignable to the super-type * @throws IllegalArgumentException if this type is not assignable to the super-type
* @since 3.2 * @since 3.2

8
spring-core/src/main/java/org/springframework/core/serializer/DefaultSerializer.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +22,8 @@ import java.io.OutputStream;
import java.io.Serializable; import java.io.Serializable;
/** /**
* Serializer that writes an object to an output stream using Java Serialization. * A {@link Serializer} implementation that writes an object to an output stream
* using Java serialization.
* *
* @author Gary Russell * @author Gary Russell
* @author Mark Fisher * @author Mark Fisher
@ -31,8 +32,9 @@ import java.io.Serializable;
public class DefaultSerializer implements Serializer<Object> { public class DefaultSerializer implements Serializer<Object> {
/** /**
* Writes the source object to an output stream using Java Serialization. * Writes the source object to an output stream using Java serialization.
* The source object must implement {@link Serializable}. * The source object must implement {@link Serializable}.
* @see ObjectOutputStream#writeObject(Object)
*/ */
@Override @Override
public void serialize(Object object, OutputStream outputStream) throws IOException { public void serialize(Object object, OutputStream outputStream) throws IOException {

11
spring-core/src/main/java/org/springframework/core/serializer/support/SerializingConverter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2015 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,8 @@ import org.springframework.core.serializer.Serializer;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* A {@link Converter} that delegates to a {@link org.springframework.core.serializer.Serializer} * A {@link Converter} that delegates to a
* {@link org.springframework.core.serializer.Serializer}
* to convert an object to a byte array. * to convert an object to a byte array.
* *
* @author Gary Russell * @author Gary Russell
@ -37,14 +38,14 @@ public class SerializingConverter implements Converter<Object, byte[]> {
/** /**
* Create a default SerializingConverter that uses standard Java serialization. * Create a default {@code SerializingConverter} that uses standard Java serialization.
*/ */
public SerializingConverter() { public SerializingConverter() {
this.serializer = new DefaultSerializer(); this.serializer = new DefaultSerializer();
} }
/** /**
* Create a SerializingConverter that delegates to the provided {@link Serializer} * Create a {@code SerializingConverter} that delegates to the provided {@link Serializer}.
*/ */
public SerializingConverter(Serializer<Object> serializer) { public SerializingConverter(Serializer<Object> serializer) {
Assert.notNull(serializer, "Serializer must not be null"); Assert.notNull(serializer, "Serializer must not be null");
@ -57,7 +58,7 @@ public class SerializingConverter implements Converter<Object, byte[]> {
*/ */
@Override @Override
public byte[] convert(Object source) { public byte[] convert(Object source) {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(256); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(1024);
try { try {
this.serializer.serialize(source, byteStream); this.serializer.serialize(source, byteStream);
return byteStream.toByteArray(); return byteStream.toByteArray();

Loading…
Cancel
Save