java: adds MessagePackObject class 2

This commit is contained in:
frsyuki 2010-07-24 18:20:00 +09:00
parent 1621a68191
commit 02ae247536
8 changed files with 67 additions and 11 deletions

View File

@ -23,7 +23,7 @@ import org.msgpack.*;
class BigIntegerTypeIMPL extends IntegerType {
private BigInteger value;
BigIntegerTypeIMPL(BigInteger vlaue) {
BigIntegerTypeIMPL(BigInteger value) {
this.value = value;
}

View File

@ -28,7 +28,7 @@ public class BooleanType extends MessagePackObject {
@Override
public boolean isBooleanType() {
return false;
return true;
}
@Override

View File

@ -23,7 +23,7 @@ import org.msgpack.*;
class DoubleTypeIMPL extends FloatType {
private double value;
public DoubleTypeIMPL(double vlaue) {
public DoubleTypeIMPL(double value) {
this.value = value;
}

View File

@ -24,5 +24,13 @@ public abstract class FloatType extends MessagePackObject {
public boolean isFloatType() {
return true;
}
public static FloatType create(float value) {
return new FloatTypeIMPL(value);
}
public static FloatType create(double value) {
return new DoubleTypeIMPL(value);
}
}

View File

@ -23,7 +23,7 @@ import org.msgpack.*;
class FloatTypeIMPL extends FloatType {
private float value;
public FloatTypeIMPL(float vlaue) {
public FloatTypeIMPL(float value) {
this.value = value;
}

View File

@ -21,6 +21,11 @@ import java.math.BigInteger;
import org.msgpack.*;
public abstract class IntegerType extends MessagePackObject {
@Override
public boolean isIntegerType() {
return true;
}
public static IntegerType create(byte value) {
return new ShortIntegerTypeIMPL((int)value);
}
@ -40,10 +45,5 @@ public abstract class IntegerType extends MessagePackObject {
public static IntegerType create(BigInteger value) {
return new BigIntegerTypeIMPL(value);
}
@Override
public boolean isIntegerType() {
return true;
}
}

View File

@ -22,7 +22,7 @@ import java.util.Map;
import org.msgpack.*;
public class MapType extends MessagePackObject {
MessagePackObject[] map;
private MessagePackObject[] map;
public MapType(MessagePackObject[] map) {
this.map = map;
@ -30,7 +30,7 @@ public class MapType extends MessagePackObject {
@Override
public boolean isMapType() {
return false;
return true;
}
@Override

View File

@ -0,0 +1,48 @@
//
// MessagePack for Java
//
// Copyright (C) 2009-2010 FURUHASHI Sadayuki
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package org.msgpack.object;
import org.msgpack.*;
class RawType extends MessagePackObject {
private byte[] bytes;
public RawType(byte[] bytes) {
this.bytes = bytes;
}
@Override
public boolean isRawType() {
return true;
}
@Override
public byte[] asByteArray() {
return bytes;
}
@Override
public String asString() {
try {
return new String(bytes, "UTF-8");
} catch (Exception e) {
throw new MessageTypeException("type error");
}
}
}