com.univocity.parsers.common.ParsingContextWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of univocity-parsers Show documentation
Show all versions of univocity-parsers Show documentation
univocity's open source parsers for processing different text formats using a consistent API
/*
* Copyright (c) 2015 uniVocity Software Pty Ltd. All rights reserved.
* This file is subject to the terms and conditions defined in file
* 'LICENSE.txt', which is part of this source code package.
*
*/
package com.univocity.parsers.common;
import java.util.*;
/**
* A simple a wrapper for a {@link ParsingContext}.
*
* @author uniVocity Software Pty Ltd - [email protected]
*
*/
public class ParsingContextWrapper extends ContextWrapper implements ParsingContext {
private final ParsingContext parsingContext;
/**
* Wraps a {@link ParsingContext}.
* @param context the parsingContext object to be wrapped.
*/
public ParsingContextWrapper(Context context) {
super(context);
if(context instanceof ParsingContext) {
this.parsingContext = (ParsingContext) context;
} else {
this.parsingContext = NoopParsingContext.instance;
}
}
@Override
public void stop() {
parsingContext.stop();
}
@Override
public boolean isStopped() {
return parsingContext.isStopped();
}
@Override
public long currentLine() {
return parsingContext.currentLine();
}
@Override
public long currentChar() {
return parsingContext.currentChar();
}
@Override
public void skipLines(long lines) {
parsingContext.skipLines(lines);
}
@Override
public String currentParsedContent() {
return parsingContext.currentParsedContent();
}
@Override
public Map comments() {
return parsingContext.comments();
}
@Override
public String lastComment() {
return parsingContext.lastComment();
}
@Override
public String[] parsedHeaders() {
return parsingContext.parsedHeaders();
}
@Override
public char[] lineSeparator() {
return parsingContext.lineSeparator();
}
}