-
Notifications
You must be signed in to change notification settings - Fork 0
/
PxrWriter.java
54 lines (42 loc) · 1.4 KB
/
PxrWriter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.brentcroft.pxr;
import com.brentcroft.pxr.model.PxrProperties;
import com.brentcroft.pxr.model.PxrPropertiesRootTag;
import com.brentcroft.tools.materializer.ContextValue;
import com.brentcroft.tools.materializer.Materializer;
import com.brentcroft.tools.materializer.core.TagHandler;
import lombok.Setter;
import org.xml.sax.InputSource;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@Setter
public class PxrWriter
{
private PxrProperties pxrProperties;
private ContextValue contextValue;
public void parse( InputSource inputSource )
{
final Materializer< PxrProperties > materializer = new Materializer<>(
() -> PxrPropertiesRootTag.ROOT,
() -> pxrProperties
);
materializer.setContextValue( contextValue );
materializer.apply( inputSource );
}
public void parse( InputStream inputStream )
{
parse( new InputSource( inputStream ) );
}
public void parse( byte[] bytes )
{
parse( new ByteArrayInputStream( bytes ) );
}
public TagHandler< PxrProperties > getDefaultHandler()
{
final Materializer< PxrProperties > materializer = new Materializer<>(
() -> PxrPropertiesRootTag.ROOT,
() -> pxrProperties
);
materializer.setContextValue( contextValue );
return materializer.getDefaultHandler();
}
}