net.sf.mmm.util.io.base.AbstractDetectorStream Maven / Gradle / Ivy
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.util.io.base;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import net.sf.mmm.util.io.api.DetectorStream;
/**
* This is the abstract base implementation of a {@link DetectorStream}.
*
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
* @since 1.1.0
*/
public abstract class AbstractDetectorStream implements DetectorStream {
private final Map mutableMetadata;
private final Map metadata;
private boolean done;
/**
* The constructor.
*/
public AbstractDetectorStream() {
this(new HashMap());
}
/**
* The constructor.
*
* @param mutableMetadata is the initial {@link #getMutableMetadata() mutable metadata}.
*/
public AbstractDetectorStream(Map mutableMetadata) {
super();
this.mutableMetadata = mutableMetadata;
this.metadata = Collections.unmodifiableMap(this.mutableMetadata);
this.done = false;
}
@Override
public Map getMetadata() {
return this.metadata;
}
/**
* This method gets the mutable {@link #getMetadata() Metadata}.
*
* @return the internal {@link #getMetadata() Metadata}-Map that is mutable.
*/
protected Map getMutableMetadata() {
return this.mutableMetadata;
}
/**
* This method sets the {@link #isDone() done} flag.
*/
protected void setDone() {
this.done = true;
}
@Override
public boolean isDone() {
return this.done;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy