All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codetaco.funnel.columns.HeaderHelper Maven / Gradle / Ivy

There is a newer version: 3.0.5
Show newest version
package com.codetaco.funnel.columns;

import java.util.Arrays;

import com.codetaco.algebrain.Equ;
import com.codetaco.funnel.orderby.KeyContext;
import com.codetaco.funnel.orderby.KeyPart;
import com.codetaco.funnel.parameters.FunnelContext;

/**
 * 

* HeaderHelper class. *

* * @author Chris DeGreef [email protected] */ public class HeaderHelper extends ColumnHelper { // final private static Logger logger = // LoggerFactory.getLogger(HeaderHelper.class); boolean waitingForInput = true; byte[] originalHeaderRow; /** *

* Constructor for HeaderHelper. *

*/ public HeaderHelper() { super(); } /** *

* Constructor for HeaderHelper. *

* * @param maxsize a int. */ public HeaderHelper(final int maxsize) { super(maxsize); } /** {@inheritDoc} */ @Override public KeyContext extract( final FunnelContext funnelContext, final byte[] data, final long recordNumber, final int dataLength, final Equ... equations) throws Exception { originalHeaderRow = Arrays.copyOf(data, dataLength); /* * Add some more equations just for headerIn fields. */ Equ[] cachedEquations; int ceSize = equations.length; ceSize += funnelContext.formatOutHelper.getReferencesToAllOutputFormatEquations(funnelContext).length; cachedEquations = new Equ[ceSize]; int ce = 0; for (final Equ equ : equations) cachedEquations[ce++] = equ; for (final Equ equ : funnelContext.formatOutHelper.getReferencesToAllOutputFormatEquations(funnelContext)) cachedEquations[ce++] = equ; return super.extract(funnelContext, data, recordNumber, dataLength, cachedEquations); } /** *

* getContents. *

* * @param headerCol a {@link com.codetaco.funnel.orderby.KeyPart} object. * @return an array of byte. * @throws java.lang.Exception if any. */ public byte[] getContents(final KeyPart headerCol) throws Exception { headerCol.parseObjectFromRawData(originalHeaderRow); return headerCol.getContentsAsByteArray(); } /** *

* isWaitingForInput. *

* * @return a boolean. */ public boolean isWaitingForInput() { if (waitingForInput) { waitingForInput = false; // if (columns != null && columns.size() > 0) return true; } return false; } /** *

* Setter for the field waitingForInput. *

* * @param shouldReadHeader a boolean. */ public void setWaitingForInput(final boolean shouldReadHeader) { waitingForInput = shouldReadHeader; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy