
io.github.mmm.marshall.spi.AbstractStructuredStringReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mmm-marshall Show documentation
Show all versions of mmm-marshall Show documentation
API for marshalling and unmarshalling data.
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package io.github.mmm.marshall.spi;
import io.github.mmm.base.number.NumberType;
import io.github.mmm.marshall.StructuredFormat;
/**
* {@link AbstractStructuredReader} that {@link #readValue() reads values} from a textual representation.
*
* @param type of the {@link StructuredNode}.
* @since 1.0.0
*/
public abstract class AbstractStructuredStringReader> extends AbstractStructuredReader {
/**
* The constructor.
*
* @param format the {@link #getFormat() format}.
*/
public AbstractStructuredStringReader(StructuredFormat format) {
super(format);
}
/**
* @see #readValueAsString()
* @return the value as {@link String} but assuring it as number.
*/
protected String readValueAsNumberString() {
return readValueAsString();
}
@Override
protected N readValueAsNumber(NumberType type) {
String value = readValueAsNumberString();
if (value == null) {
return null;
}
try {
return type.parse(value);
} catch (RuntimeException e) {
throw error(value, type.getType(), e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy