This commit is contained in:
@@ -16,6 +16,7 @@ import java.net.*;
|
|||||||
import static com.wentch.redkale.convert.ext.InetAddressSimpledCoder.*;
|
import static com.wentch.redkale.convert.ext.InetAddressSimpledCoder.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
import java.util.regex.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -87,6 +88,7 @@ public abstract class Factory<R extends Reader, W extends Writer> {
|
|||||||
this.register(Class.class, TypeSimpledCoder.instance);
|
this.register(Class.class, TypeSimpledCoder.instance);
|
||||||
this.register(InetSocketAddress.class, InetSocketAddressSimpledCoder.instance);
|
this.register(InetSocketAddress.class, InetSocketAddressSimpledCoder.instance);
|
||||||
this.register(InetSocketAddress.class, InetSocketAddressSimpledCoder.instance);
|
this.register(InetSocketAddress.class, InetSocketAddressSimpledCoder.instance);
|
||||||
|
this.register(Pattern.class, PatternSimpledCoder.instance);
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
this.register(boolean[].class, BoolArraySimpledCoder.instance);
|
this.register(boolean[].class, BoolArraySimpledCoder.instance);
|
||||||
this.register(byte[].class, ByteArraySimpledCoder.instance);
|
this.register(byte[].class, ByteArraySimpledCoder.instance);
|
||||||
|
|||||||
38
src/com/wentch/redkale/convert/ext/PatternSimpledCoder.java
Normal file
38
src/com/wentch/redkale/convert/ext/PatternSimpledCoder.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.wentch.redkale.convert.ext;
|
||||||
|
|
||||||
|
import com.wentch.redkale.convert.*;
|
||||||
|
import java.util.regex.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author zhangjx
|
||||||
|
* @param <R>
|
||||||
|
* @param <W>
|
||||||
|
*/
|
||||||
|
public class PatternSimpledCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Pattern> {
|
||||||
|
|
||||||
|
public static final PatternSimpledCoder instance = new PatternSimpledCoder();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void convertTo(W out, Pattern value) {
|
||||||
|
if (value == null) {
|
||||||
|
out.writeNull();
|
||||||
|
} else {
|
||||||
|
out.writeString(value.flags() + "," + value.pattern());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Pattern convertFrom(R in) {
|
||||||
|
String value = in.readString();
|
||||||
|
if (value == null) return null;
|
||||||
|
int pos = value.indexOf(',');
|
||||||
|
return Pattern.compile(value.substring(pos + 1), Integer.parseInt(value.substring(0, pos)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user