Skip to content

Commit

Permalink
Continuing renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 10, 2016
1 parent 64207f8 commit 50b392e
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 46 deletions.
Expand Up @@ -89,7 +89,7 @@ public PrismParser compat() {

protected <O extends Objectable> PrismObject<O> doParse() throws SchemaException, IOException {
LexicalProcessor lexicalProcessor = getParser();
XNode xnode = lexicalProcessor.parse(source, context);
XNode xnode = lexicalProcessor.read(source, context);
return helpers.xnodeProcessor.parseObject(xnode, context);
}

Expand All @@ -105,7 +105,7 @@ private LexicalProcessor getParser() throws IOException {

protected List<PrismObject<? extends Objectable>> doParseObjects() throws IOException, SchemaException {
LexicalProcessor lexicalProcessor = getParser();
Collection<XNode> xnodes = lexicalProcessor.parseCollection(source, context);
Collection<XNode> xnodes = lexicalProcessor.readCollection(source, context);
List<PrismObject<? extends Objectable>> objects = new ArrayList<>();
for (XNode xnode : xnodes) {
PrismObject<? extends Objectable> object = helpers.xnodeProcessor.parseObject(xnode, context);
Expand All @@ -116,41 +116,41 @@ protected List<PrismObject<? extends Objectable>> doParseObjects() throws IOExce

protected <C extends Containerable> PrismContainer<C> doParseContainer(Class<C> clazz) throws SchemaException, IOException {
LexicalProcessor lexicalProcessor = getParser();
XNode xnode = lexicalProcessor.parse(source, context);
XNode xnode = lexicalProcessor.read(source, context);
return helpers.xnodeProcessor.parseContainer(xnode, clazz, context);
}

protected <C extends Containerable> PrismContainer<C> doParseContainer(PrismContainerDefinition<C> definition) throws SchemaException, IOException {
LexicalProcessor lexicalProcessor = getParser();
XNode xnode = lexicalProcessor.parse(source, context);
XNode xnode = lexicalProcessor.read(source, context);
return helpers.xnodeProcessor.parseContainer(xnode, definition, context);
}

protected <T> T doParseAtomicValue(QName typeName) throws IOException, SchemaException {
LexicalProcessor lexicalProcessor = getParser();
XNode xnode = lexicalProcessor.parse(source, context);
XNode xnode = lexicalProcessor.read(source, context);
return helpers.xnodeProcessor.parseAtomicValue(xnode, typeName, context);
}

protected Object doParseAnyData() throws IOException, SchemaException {
LexicalProcessor lexicalProcessor = getParser();
XNode xnode = lexicalProcessor.parse(source, context);
XNode xnode = lexicalProcessor.read(source, context);
return helpers.xnodeProcessor.parseAnyData(xnode, context);
}

protected <T> T doParseAnyValue() throws IOException, SchemaException {
LexicalProcessor lexicalProcessor = getParser();
XNode xnode = lexicalProcessor.parse(source, context);
XNode xnode = lexicalProcessor.read(source, context);
return helpers.xnodeProcessor.parseAnyValue(xnode, context);
}

protected <T> JAXBElement<T> doParseAnyValueAsJAXBElement() throws IOException, SchemaException {
LexicalProcessor lexicalProcessor = getParser();
XNode xnode = lexicalProcessor.parse(source, context);
XNode xnode = lexicalProcessor.read(source, context);
return helpers.xnodeProcessor.parseAnyValueAsJAXBElement(xnode, context);
}

protected XNode doParseToXNode() throws IOException, SchemaException {
return getParser().parse(source, context);
return getParser().read(source, context);
}
}
Expand Up @@ -19,6 +19,6 @@ public SerializerStringTarget(@NotNull LexicalHelpers lexicalHelpers, @NotNull S

@Override
public String serialize(RootXNode xroot, SerializationContext context) throws SchemaException {
return lexicalHelpers.lexicalProcessorRegistry.parserFor(language).serializeToString(xroot, context);
return lexicalHelpers.lexicalProcessorRegistry.parserFor(language).write(xroot, context);
}
}
Expand Up @@ -34,16 +34,16 @@
*/
public interface LexicalProcessor {

XNode parse(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException;
XNode read(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException;

Collection<XNode> parseCollection(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException;
Collection<XNode> readCollection(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException;

boolean canParse(File file) throws IOException;
boolean canRead(File file) throws IOException;

boolean canParse(String dataString);
boolean canRead(String dataString);

String serializeToString(XNode xnode, QName rootElementName, SerializationContext serializationContext) throws SchemaException;
String write(XNode xnode, QName rootElementName, SerializationContext serializationContext) throws SchemaException;

String serializeToString(RootXNode xnode, SerializationContext serializationContext) throws SchemaException;
String write(RootXNode xnode, SerializationContext serializationContext) throws SchemaException;

}
Expand Up @@ -55,7 +55,7 @@ public LexicalProcessorRegistry(SchemaRegistry schemaRegistry) {
public LexicalProcessor findParser(File file) throws IOException {
for (Map.Entry<String,LexicalProcessor> entry: parserMap.entrySet()) {
LexicalProcessor aLexicalProcessor = entry.getValue();
if (aLexicalProcessor.canParse(file)) {
if (aLexicalProcessor.canRead(file)) {
return aLexicalProcessor;
}
}
Expand All @@ -66,7 +66,7 @@ public LexicalProcessor findParser(File file) throws IOException {
public LexicalProcessor findParser(String data){
for (Map.Entry<String,LexicalProcessor> entry: parserMap.entrySet()) {
LexicalProcessor aLexicalProcessor = entry.getValue();
if (aLexicalProcessor.canParse(data)) {
if (aLexicalProcessor.canRead(data)) {
return aLexicalProcessor;
}
}
Expand Down
Expand Up @@ -64,11 +64,11 @@ public DomLexicalProcessor(SchemaRegistry schemaRegistry) {

@Deprecated
public XNode parse(File file, ParsingContext parsingContext) throws SchemaException, IOException {
return parse(new ParserFileSource(file), parsingContext);
return read(new ParserFileSource(file), parsingContext);
}

@Override
public XNode parse(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException {
public XNode read(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException {
if (source instanceof ParserElementSource) {
return parse(((ParserElementSource) source).getElement());
}
Expand All @@ -85,7 +85,7 @@ public XNode parse(ParserSource source, ParsingContext parsingContext) throws Sc
}

@Override
public Collection<XNode> parseCollection(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException {
public Collection<XNode> readCollection(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException {
InputStream is = source.getInputStream();
try {
Document document = DOMUtil.parse(is);
Expand Down Expand Up @@ -391,15 +391,15 @@ private SchemaXNode parseSchemaElement(Element schemaElement) {
}

@Override
public boolean canParse(File file) throws IOException {
public boolean canRead(File file) throws IOException {
if (file == null) {
return false;
}
return file.getName().endsWith(".xml");
}

@Override
public boolean canParse(String dataString) {
public boolean canRead(String dataString) {
if (dataString == null) {
return false;
}
Expand All @@ -415,15 +415,15 @@ public boolean canParse(String dataString) {
}

@Override
public String serializeToString(XNode xnode, QName rootElementName, SerializationContext serializationContext) throws SchemaException {
public String write(XNode xnode, QName rootElementName, SerializationContext serializationContext) throws SchemaException {
DomLexicalWriter serializer = new DomLexicalWriter(this, schemaRegistry);
RootXNode xroot = LexicalUtils.createRootXNode(xnode, rootElementName);
Element element = serializer.serialize(xroot);
return DOMUtil.serializeDOMToString(element);
}

@Override
public String serializeToString(RootXNode xnode, SerializationContext serializationContext) throws SchemaException {
public String write(RootXNode xnode, SerializationContext serializationContext) throws SchemaException {
DomLexicalWriter serializer = new DomLexicalWriter(this, schemaRegistry);
Element element = serializer.serialize(xnode);
return DOMUtil.serializeDOMToString(element);
Expand Down
Expand Up @@ -66,7 +66,7 @@ public abstract class AbstractJsonLexicalProcessor implements LexicalProcessor {
//region Parsing implementation

@Override
public RootXNode parse(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException {
public RootXNode read(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException {
InputStream is = source.getInputStream();
try {
JsonParser parser = createJacksonParser(is);
Expand All @@ -79,7 +79,7 @@ public RootXNode parse(ParserSource source, ParsingContext parsingContext) throw
}

@Override
public Collection<XNode> parseCollection(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException {
public Collection<XNode> readCollection(ParserSource source, ParsingContext parsingContext) throws SchemaException, IOException {
throw new UnsupportedOperationException("Parse objects not supported for json and yaml."); // why?
}

Expand Down Expand Up @@ -431,16 +431,16 @@ private JsonSerializationContext(@NotNull JsonGenerator generator, @Nullable Ser
}
}
@Override
public String serializeToString(XNode xnode, QName rootElementName, SerializationContext serializationContext) throws SchemaException {
return serializeToString(LexicalUtils.createRootXNode(xnode, rootElementName), serializationContext);
public String write(XNode xnode, QName rootElementName, SerializationContext serializationContext) throws SchemaException {
return write(LexicalUtils.createRootXNode(xnode, rootElementName), serializationContext);
}

protected abstract JsonGenerator createJacksonGenerator(StringWriter out) throws SchemaException;

protected abstract void writeExplicitType(QName explicitType, JsonGenerator generator) throws IOException;

@Override
public String serializeToString(RootXNode root, SerializationContext prismSerializationContext) throws SchemaException {
public String write(RootXNode root, SerializationContext prismSerializationContext) throws SchemaException {
StringWriter out = new StringWriter();
try ( JsonGenerator generator = createJacksonGenerator(out) ) {
JsonSerializationContext ctx = new JsonSerializationContext(generator, prismSerializationContext);
Expand Down
Expand Up @@ -42,15 +42,15 @@
public class JsonLexicalProcessor extends AbstractJsonLexicalProcessor {

@Override
public boolean canParse(File file) throws IOException {
public boolean canRead(File file) throws IOException {
if (file == null) {
return false;
}
return file.getName().endsWith(".json");
}

@Override
public boolean canParse(String dataString) {
public boolean canRead(String dataString) {
if (dataString == null) {
return false;
}
Expand Down
Expand Up @@ -58,15 +58,15 @@ public class YamlLexicalProcessor extends AbstractJsonLexicalProcessor {
//------------------------END OF METHODS FOR SERIALIZATION -------------------------------

@Override
public boolean canParse(File file) throws IOException {
public boolean canRead(File file) throws IOException {
if (file == null) {
return false;
}
return file.getName().endsWith(".yaml");
}

@Override
public boolean canParse(String dataString) {
public boolean canRead(String dataString) {
if (dataString == null) {
return false;
}
Expand Down
Expand Up @@ -158,7 +158,7 @@ public <T> T unmarshall(MapXNode xnode, Class<T> beanClass, ParsingContext pc) t
} else {
Map.Entry<QName,XNode> entry = xnode.entrySet().iterator().next();
DomLexicalProcessor domParser = prismContext.getParserDom();
String value = domParser.serializeToString(entry.getValue(), entry.getKey(), null);
String value = domParser.write(entry.getValue(), entry.getKey(), null);
return (T) new XmlAsStringType(value);
}
}
Expand Down
Expand Up @@ -60,12 +60,12 @@ public void testHandlingInvalidChars() throws Exception {

// THEN

String ok = prismContext.getParserDom().serializeToString(valOkNode, new QName("ok"), null);
String ok = prismContext.getParserDom().write(valOkNode, new QName("ok"), null);
System.out.println("correct value serialized to: " + ok);
assertEquals("Wrong serialization", "<ok>abcdef</ok>", ok.trim()); // todo make this less brittle with regards to serialization style

try {
String wrong = prismContext.getParserDom().serializeToString(valWrongNode, new QName("wrong"), null);
String wrong = prismContext.getParserDom().write(valWrongNode, new QName("wrong"), null);
System.out.println("wrong value serialized to: " + wrong);
assert false : "Wrong value serialization had to fail but it didn't!";
} catch (RuntimeException e) {
Expand Down
Expand Up @@ -97,7 +97,7 @@ public void testParseUserToPrism() throws Exception {
XNodeProcessor processor = new XNodeProcessor(prismContext);

// WHEN (parse to xnode)
XNode xnode = lexicalProcessor.parse(getFileSource(USER_JACK_FILE_BASENAME), ParsingContext.createDefault());
XNode xnode = lexicalProcessor.read(getFileSource(USER_JACK_FILE_BASENAME), ParsingContext.createDefault());
System.out.println("XNode after parsing:");
System.out.println(xnode.debugDump());

Expand Down Expand Up @@ -129,7 +129,7 @@ public void testParseUserRoundTrip() throws Exception {
XNodeProcessor processor = new XNodeProcessor(prismContext);

// WHEN (parse)
XNode xnode = lexicalProcessor.parse(getFileSource(USER_JACK_FILE_BASENAME), ParsingContext.createDefault());
XNode xnode = lexicalProcessor.read(getFileSource(USER_JACK_FILE_BASENAME), ParsingContext.createDefault());
System.out.println("\nParsed xnode:");
System.out.println(xnode.debugDump());
PrismObject<UserType> user = processor.parseObject(xnode, ParsingContext.createDefault());
Expand All @@ -142,7 +142,7 @@ public void testParseUserRoundTrip() throws Exception {

// WHEN (re-serialize to XNode)
XNode serializedXNode = processor.serializeObject(user, true);
String serializedString = lexicalProcessor.serializeToString(serializedXNode, new QName(NS_FOO, "user"), null);
String serializedString = lexicalProcessor.write(serializedXNode, new QName(NS_FOO, "user"), null);

// THEN
System.out.println("\nXNode after re-serialization:");
Expand Down Expand Up @@ -175,7 +175,7 @@ public void testParseUserRoundTrip() throws Exception {
validateUserSchema(serializedString, prismContext);

// WHEN (re-parse)
XNode reparsedXnode = lexicalProcessor.parse(new ParserStringSource(serializedString), ParsingContext.createDefault());
XNode reparsedXnode = lexicalProcessor.read(new ParserStringSource(serializedString), ParsingContext.createDefault());
PrismObject<UserType> reparsedUser = processor.parseObject(reparsedXnode, ParsingContext.createDefault());

// THEN
Expand Down Expand Up @@ -213,7 +213,7 @@ public void testParseResourceRumToPrism() throws Exception {
XNodeProcessor processor = new XNodeProcessor(prismContext);

// WHEN (parse to xnode)
XNode xnode = lexicalProcessor.parse(getFileSource(RESOURCE_RUM_FILE_BASENAME), ParsingContext.createDefault());
XNode xnode = lexicalProcessor.read(getFileSource(RESOURCE_RUM_FILE_BASENAME), ParsingContext.createDefault());
System.out.println("XNode after parsing:");
System.out.println(xnode.debugDump());

Expand All @@ -239,7 +239,7 @@ public void testParseResourceRoundTrip() throws Exception {
XNodeProcessor processor = new XNodeProcessor(prismContext);

// WHEN (parse)
XNode xnode = lexicalProcessor.parse(getFileSource(RESOURCE_RUM_FILE_BASENAME), ParsingContext.createDefault());
XNode xnode = lexicalProcessor.read(getFileSource(RESOURCE_RUM_FILE_BASENAME), ParsingContext.createDefault());
PrismObject<ResourceType> resource = processor.parseObject(xnode, ParsingContext.createDefault());

// THEN
Expand All @@ -250,7 +250,7 @@ public void testParseResourceRoundTrip() throws Exception {

// WHEN (re-serialize to XNode)
XNode serializedXNode = processor.serializeObject(resource, true);
String serializedString = lexicalProcessor.serializeToString(serializedXNode, new QName(NS_FOO, "resource"), null);
String serializedString = lexicalProcessor.write(serializedXNode, new QName(NS_FOO, "resource"), null);

// THEN
System.out.println("\nXNode after re-serialization:");
Expand Down Expand Up @@ -284,7 +284,7 @@ public void testParseResourceRoundTrip() throws Exception {
validateResourceSchema(serializedString, prismContext);

// WHEN (re-parse)
XNode reparsedXnode = lexicalProcessor.parse(new ParserStringSource(serializedString), ParsingContext.createDefault());
XNode reparsedXnode = lexicalProcessor.read(new ParserStringSource(serializedString), ParsingContext.createDefault());
PrismObject<ResourceType> reparsedResource = processor.parseObject(reparsedXnode, ParsingContext.createDefault());

// THEN
Expand Down Expand Up @@ -391,7 +391,7 @@ public void testParseEventHandler() throws Exception {
XNodeProcessor processor = new XNodeProcessor(prismContext);

// WHEN (parse to xnode)
RootXNode xnode = (RootXNode) lexicalProcessor.parse(getFileSource(EVENT_HANDLER_FILE_BASENAME), ParsingContext.createDefault());
RootXNode xnode = (RootXNode) lexicalProcessor.read(getFileSource(EVENT_HANDLER_FILE_BASENAME), ParsingContext.createDefault());
System.out.println("XNode after parsing:");
System.out.println(xnode.debugDump());

Expand Down

0 comments on commit 50b392e

Please sign in to comment.