Example usage for java.lang ClassNotFoundException toString

List of usage examples for java.lang ClassNotFoundException toString

Introduction

In this page you can find the example usage for java.lang ClassNotFoundException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.apache.openjpa.jdbc.meta.ReverseMappingTool.java

/**
 * Generate a new class with the given name. If a non-null parent class
 * is given, it will be set as the superclass.
 *//*from  w  ww.  ja v  a2 s  . c om*/
public Class generateClass(String name, Class parent) {
    BCClass bc = _project.loadClass(name, null);
    if (parent != null)
        bc.setSuperclass(parent);
    bc.addDefaultConstructor();

    try {
        return Class.forName(name, false, _loader);
    } catch (ClassNotFoundException cnfe) {
        throw new InternalException(cnfe.toString(), cnfe);
    }
}

From source file:net.sf.jasperreports.engine.design.JRVerifier.java

protected void verifyFormatFactoryClass() {
    String formatFactoryClassName = jasperDesign.getFormatFactoryClass();
    if (formatFactoryClassName != null) {
        try {/*w w w.ja va  2  s . c o  m*/
            Class<?> formatFactoryClass = JRClassLoader.loadClassForName(formatFactoryClassName);
            if (!FormatFactory.class.isAssignableFrom(formatFactoryClass)) {
                addBrokenRule("The report format factory class is not compatible with "
                        + FormatFactory.class.getName(), jasperDesign);
            }
        } catch (ClassNotFoundException e) {
            addBrokenRule(e.toString(), jasperDesign);
        }
    }
}

From source file:com.streamsets.pipeline.stage.origin.jdbc.cdc.oracle.OracleCDCSource.java

@Override
public List<ConfigIssue> init() {
    List<ConfigIssue> issues = super.init();
    errorRecordHandler = new DefaultErrorRecordHandler(getContext());
    useLocalBuffering = !getContext().isPreview() && configBean.bufferLocally;
    if (!hikariConfigBean.driverClassName.isEmpty()) {
        try {//w ww.jav  a  2s . co m
            Class.forName(hikariConfigBean.driverClassName);
        } catch (ClassNotFoundException e) {
            LOG.error("Hikari Driver class not found.", e);
            issues.add(getContext().createConfigIssue(Groups.LEGACY.name(), DRIVER_CLASSNAME,
                    JdbcErrors.JDBC_28, e.toString()));
        }
    }
    issues = hikariConfigBean.validateConfigs(getContext(), issues);
    if (connection == null) { // For tests, we set a mock connection
        try {
            dataSource = jdbcUtil.createDataSourceForRead(hikariConfigBean);
            connection = dataSource.getConnection();
            connection.setAutoCommit(false);
        } catch (StageException | SQLException e) {
            LOG.error("Error while connecting to DB", e);
            issues.add(
                    getContext().createConfigIssue(Groups.JDBC.name(), CONNECTION_STR, JDBC_00, e.toString()));
            return issues;
        }
    }

    recordQueue = new LinkedBlockingQueue<>(2 * configBean.baseConfigBean.maxBatchSize);
    String container = configBean.pdb;

    List<SchemaAndTable> schemasAndTables;

    try {
        initializeStatements();
        alterSession();
    } catch (SQLException ex) {
        LOG.error("Error while creating statement", ex);
        issues.add(getContext().createConfigIssue(Groups.JDBC.name(), CONNECTION_STR, JDBC_00,
                hikariConfigBean.getConnectionString()));
    }
    zoneId = ZoneId.of(configBean.dbTimeZone);
    dateTimeColumnHandler = new DateTimeColumnHandler(zoneId);
    String commitScnField;
    BigDecimal scn = null;
    try {
        scn = getEndingSCN();
        switch (configBean.startValue) {
        case SCN:
            if (new BigDecimal(configBean.startSCN).compareTo(scn) > 0) {
                issues.add(getContext().createConfigIssue(CDC.name(), "oracleCDCConfigBean.startSCN", JDBC_47,
                        scn.toPlainString()));
            }
            break;
        case LATEST:
            // If LATEST is used, use now() as the startDate and proceed as if a startDate was specified
            configBean.startDate = nowAtDBTz().format(dateTimeColumnHandler.dateFormatter);
            // fall-through
        case DATE:
            try {
                LocalDateTime startDate = dateTimeColumnHandler.getDate(configBean.startDate);
                if (startDate.isAfter(nowAtDBTz())) {
                    issues.add(getContext().createConfigIssue(CDC.name(), "oracleCDCConfigBean.startDate",
                            JDBC_48));
                }
            } catch (DateTimeParseException ex) {
                LOG.error("Invalid date", ex);
                issues.add(
                        getContext().createConfigIssue(CDC.name(), "oracleCDCConfigBean.startDate", JDBC_49));
            }
            break;
        default:
            throw new IllegalStateException("Unknown start value!");
        }
    } catch (SQLException ex) {
        LOG.error("Error while getting SCN", ex);
        issues.add(getContext().createConfigIssue(CREDENTIALS.name(), USERNAME, JDBC_42));
    }

    try (Statement reusedStatement = connection.createStatement()) {
        int majorVersion = getDBVersion(issues);
        // If version is 12+, then the check for table presence must be done in an alternate container!
        if (majorVersion == -1) {
            return issues;
        }
        if (majorVersion >= 12) {
            if (!StringUtils.isEmpty(container)) {
                String switchToPdb = "ALTER SESSION SET CONTAINER = " + configBean.pdb;
                try {
                    reusedStatement.execute(switchToPdb);
                } catch (SQLException ex) {
                    LOG.error("Error while switching to container: " + container, ex);
                    issues.add(getContext().createConfigIssue(Groups.CREDENTIALS.name(), USERNAME, JDBC_40,
                            container));
                    return issues;
                }
                containerized = true;
            }
        }

        schemasAndTables = new ArrayList<>();
        for (SchemaTableConfigBean tables : configBean.baseConfigBean.schemaTableConfigs) {

            tables.schema = configBean.baseConfigBean.caseSensitive ? tables.schema
                    : tables.schema.toUpperCase();
            tables.table = configBean.baseConfigBean.caseSensitive ? tables.table : tables.table.toUpperCase();
            if (tables.excludePattern != null) {
                tables.excludePattern = configBean.baseConfigBean.caseSensitive ? tables.excludePattern
                        : tables.excludePattern.toUpperCase();
            }
            Pattern p = StringUtils.isEmpty(tables.excludePattern) ? null
                    : Pattern.compile(tables.excludePattern);

            try (ResultSet rs = jdbcUtil.getTableAndViewMetadata(connection, tables.schema, tables.table)) {
                while (rs.next()) {
                    String schemaName = rs.getString(TABLE_METADATA_TABLE_SCHEMA_CONSTANT);
                    String tableName = rs.getString(TABLE_METADATA_TABLE_NAME_CONSTANT);
                    if (p == null || !p.matcher(tableName).matches()) {
                        schemaName = schemaName.trim();
                        tableName = tableName.trim();
                        schemasAndTables.add(new SchemaAndTable(schemaName, tableName));
                    }
                }
            }
        }

        validateTablePresence(reusedStatement, schemasAndTables, issues);
        if (!issues.isEmpty()) {
            return issues;
        }
        for (SchemaAndTable schemaAndTable : schemasAndTables) {
            try {
                tableSchemas.put(schemaAndTable, getTableSchema(schemaAndTable));
                if (scn != null) {
                    tableSchemaLastUpdate.put(schemaAndTable, scn);
                }
            } catch (SQLException ex) {
                LOG.error("Error while switching to container: " + container, ex);
                issues.add(getContext().createConfigIssue(Groups.CREDENTIALS.name(), USERNAME, JDBC_50));
            }
        }
        container = CDB_ROOT;
        if (majorVersion >= 12) {
            try {
                switchContainer.execute();
                LOG.info("Switched to CDB$ROOT to start LogMiner.");
            } catch (SQLException ex) {
                // Fatal only if we switched to a PDB earlier
                if (containerized) {
                    LOG.error("Error while switching to container: " + container, ex);
                    issues.add(getContext().createConfigIssue(Groups.CREDENTIALS.name(), USERNAME, JDBC_40,
                            container));
                    return issues;
                }
                // Log it anyway
                LOG.info("Switching containers failed, ignoring since there was no PDB switch", ex);
            }
        }
        commitScnField = majorVersion >= 11 ? "COMMIT_SCN" : "CSCN";
    } catch (SQLException ex) {
        LOG.error("Error while creating statement", ex);
        issues.add(getContext().createConfigIssue(Groups.JDBC.name(), CONNECTION_STR, JDBC_00,
                hikariConfigBean.getConnectionString()));
        return issues;
    }

    final String ddlTracking = shouldTrackDDL ? " + DBMS_LOGMNR.DDL_DICT_TRACKING" : "";

    final String readCommitted = useLocalBuffering ? "" : "+ DBMS_LOGMNR.COMMITTED_DATA_ONLY";

    this.logMinerProcedure = "BEGIN" + " DBMS_LOGMNR.START_LOGMNR(" + " {}," + " {},"
            + " OPTIONS => DBMS_LOGMNR." + configBean.dictionary.name()
            + "          + DBMS_LOGMNR.CONTINUOUS_MINE" + readCommitted
            + "          + DBMS_LOGMNR.NO_SQL_DELIMITER" + ddlTracking + ");" + " END;";

    final String base = "SELECT SCN, USERNAME, OPERATION_CODE, TIMESTAMP, SQL_REDO, TABLE_NAME, "
            + commitScnField
            + ", SEQUENCE#, CSF, XIDUSN, XIDSLT, XIDSQN, RS_ID, SSN, SEG_OWNER, ROLLBACK, ROW_ID "
            + " FROM V$LOGMNR_CONTENTS" + " WHERE ";

    final String tableCondition = getListOfSchemasAndTables(schemasAndTables);

    final String commitRollbackCondition = Utils.format("OPERATION_CODE = {} OR OPERATION_CODE = {}",
            COMMIT_CODE, ROLLBACK_CODE);

    final String operationsCondition = "OPERATION_CODE IN (" + getSupportedOperations() + ")";

    final String restartNonBufferCondition = Utils.format("((" + commitScnField + " = ? AND SEQUENCE# > ?) OR "
            + commitScnField + "  > ?)" + (shouldTrackDDL ? " OR (OPERATION_CODE = {} AND SCN > ?)" : ""),
            DDL_CODE);

    if (useLocalBuffering) {
        selectString = String.format("%s ((%s AND (%s)) OR (%s))", base, tableCondition, operationsCondition,
                commitRollbackCondition);
    } else {
        selectString = base + " (" + tableCondition + " AND (" + operationsCondition + "))" + "AND ("
                + restartNonBufferCondition + ")";
    }

    try {
        initializeLogMnrStatements();
    } catch (SQLException ex) {
        LOG.error("Error while creating statement", ex);
        issues.add(getContext().createConfigIssue(Groups.JDBC.name(), CONNECTION_STR, JDBC_00,
                hikariConfigBean.getConnectionString()));
    }

    if (configBean.dictionary == DictionaryValues.DICT_FROM_REDO_LOGS) {
        try {
            startLogMnrForRedoDict();
        } catch (Exception ex) {
            LOG.warn("Error while attempting to start LogMiner to load dictionary", ex);
            issues.add(getContext().createConfigIssue(Groups.CDC.name(), "oracleCDCConfigBean.dictionary",
                    JDBC_44, ex));
        }
    }

    if (useLocalBuffering && configBean.bufferLocation == BufferingValues.ON_DISK) {
        File tmpDir = new File(System.getProperty("java.io.tmpdir"));
        String relativePath = getContext().getSdcId() + "/" + getContext().getPipelineId() + "/"
                + getContext().getStageInfo().getInstanceName();
        this.txnBufferLocation = new File(tmpDir, relativePath);

        try {
            if (txnBufferLocation.exists()) {
                FileUtils.deleteDirectory(txnBufferLocation);
                LOG.info("Deleted " + txnBufferLocation.toString());
            }
            Files.createDirectories(txnBufferLocation.toPath());
            LOG.info("Created " + txnBufferLocation.toString());
        } catch (IOException ex) {
            Throwables.propagate(ex);
        }
    }

    if (configBean.bufferLocally) {
        if (configBean.parseQuery) {
            parsingExecutor = Executors.newFixedThreadPool(configBean.parseThreadPoolSize,
                    new ThreadFactoryBuilder().setNameFormat("Oracle CDC Origin Parse Thread - %d").build());
        } else {
            parsingExecutor = Executors.newSingleThreadExecutor(
                    new ThreadFactoryBuilder().setNameFormat("Oracle CDC Origin Parse Thread - %d").build());
        }
    }

    if (configBean.txnWindow >= configBean.logminerWindow) {
        issues.add(getContext().createConfigIssue(Groups.CDC.name(), "oracleCDCConfigBean.logminerWindow",
                JDBC_81));
    }
    version = useLocalBuffering ? VERSION_UNCOMMITTED : VERSION_STR;
    delay = getContext().createGauge("Read Lag (seconds)");
    return issues;
}

From source file:org.pentaho.di.core.database.DatabaseMeta.java

public String testConnection() {

    StringBuffer report = new StringBuffer();

    // If the plug-in needs to provide connection information, we ask the DatabaseInterface...
    ///*from   www .  j  a v  a  2s .  c o m*/
    try {
        DatabaseFactoryInterface factory = getDatabaseFactory();
        return factory.getConnectionTestReport(this);
    } catch (ClassNotFoundException e) {
        report.append(
                BaseMessages.getString(PKG, "BaseDatabaseMeta.TestConnectionReportNotImplemented.Message"))
                .append(Const.CR); // $NON-NLS-1
        report.append(BaseMessages.getString(PKG, "DatabaseMeta.report.ConnectionError", getName()) //$NON-NLS-1$
                + e.toString() + Const.CR);
        report.append(Const.getStackTracker(e) + Const.CR);
    } catch (Exception e) {
        report.append(BaseMessages.getString(PKG, "DatabaseMeta.report.ConnectionError", getName()) //$NON-NLS-1$
                + e.toString() + Const.CR);
        report.append(Const.getStackTracker(e) + Const.CR);
    }
    return report.toString();
}

From source file:com.netscape.ca.CertificateAuthority.java

private void initCRLPublisher() throws EBaseException {
    // instantiate CRL publisher
    if (!isHostAuthority()) {
        mByName = hostCA.mByName;/*  ww  w  .ja  v a2  s . c o  m*/
        mCRLPublisher = hostCA.mCRLPublisher;
        return;
    }

    mByName = mConfig.getBoolean("byName", true);
    IConfigStore cpStore = mConfig.getSubStore("crlPublisher");
    if (cpStore != null && cpStore.size() > 0) {
        String publisherClass = cpStore.getString("class");

        if (publisherClass != null) {
            try {
                @SuppressWarnings("unchecked")
                Class<ICRLPublisher> pc = (Class<ICRLPublisher>) Class.forName(publisherClass);

                mCRLPublisher = pc.newInstance();
                mCRLPublisher.init(this, cpStore);
            } catch (ClassNotFoundException ee) {
                log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_CA_CA_NO_PUBLISHER", ee.toString()));
            } catch (IllegalAccessException ee) {
                log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_CA_CA_NO_PUBLISHER", ee.toString()));
            } catch (InstantiationException ee) {
                log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_CA_CA_NO_PUBLISHER", ee.toString()));
            }
        }
    }
}

From source file:com.netscape.ca.CertificateAuthority.java

/**
 * initialize CRL/*from w w  w .  j  a  va 2s .  co  m*/
 */
@SuppressWarnings("unchecked")
private void initCRL() throws EBaseException {
    if (!isHostAuthority()) {
        mCRLIssuePoints = hostCA.mCRLIssuePoints;
        mMasterCRLIssuePoint = hostCA.mMasterCRLIssuePoint;
        return;
    }
    IConfigStore crlConfig = mConfig.getSubStore(PROP_CRL_SUBSTORE);

    if ((crlConfig == null) || (crlConfig.size() <= 0)) {
        log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_CA_CA_NO_MASTER_CRL"));
        //throw new ECAException(CAResources.NO_CONFIG_FOR_MASTER_CRL);
        return;
    }
    Enumeration<String> issuePointIdEnum = crlConfig.getSubStoreNames();

    if (issuePointIdEnum == null || !issuePointIdEnum.hasMoreElements()) {
        log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_CA_CA_NO_MASTER_CRL_SUBSTORE"));
        //throw new ECAException(CAResources.NO_CONFIG_FOR_MASTER_CRL);
        return;
    }

    // a Master/full crl must exist.
    CRLIssuingPoint masterCRLIssuePoint = null;

    while (issuePointIdEnum.hasMoreElements()) {
        String issuePointId = issuePointIdEnum.nextElement();

        logger.debug("initializing crl issue point " + issuePointId);
        IConfigStore issuePointConfig = null;
        String issuePointClassName = null;
        Class<CRLIssuingPoint> issuePointClass = null;
        CRLIssuingPoint issuePoint = null;

        try {
            issuePointConfig = crlConfig.getSubStore(issuePointId);
            issuePointClassName = issuePointConfig.getString(PROP_CLASS);
            issuePointClass = (Class<CRLIssuingPoint>) Class.forName(issuePointClassName);
            issuePoint = issuePointClass.newInstance();
            issuePoint.init(this, issuePointId, issuePointConfig);
            mCRLIssuePoints.put(issuePointId, issuePoint);

            if (masterCRLIssuePoint == null && issuePointId.equals(PROP_MASTER_CRL))
                masterCRLIssuePoint = issuePoint;

        } catch (ClassNotFoundException e) {
            throw new ECAException(
                    CMS.getUserMessage("CMS_CA_CRL_ISSUING_POINT_INIT_FAILED", issuePointId, e.toString()));
        } catch (InstantiationException e) {
            throw new ECAException(
                    CMS.getUserMessage("CMS_CA_CRL_ISSUING_POINT_INIT_FAILED", issuePointId, e.toString()));
        } catch (IllegalAccessException e) {
            throw new ECAException(
                    CMS.getUserMessage("CMS_CA_CRL_ISSUING_POINT_INIT_FAILED", issuePointId, e.toString()));
        }
    }

    mMasterCRLIssuePoint = masterCRLIssuePoint;

    /*
     if (mMasterCRLIssuePoint == null) {
     log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_CA_CA_NO_FULL_CRL", PROP_MASTER_CRL));
     throw new ECAException(CAResources.NO_CONFIG_FOR_MASTER_CRL);
     }
     */
    log(ILogger.LL_INFO, "CRL Issuing Points inited");
}

From source file:cai.flow.packets.V9_Packet.java

/**
 * UDPflowsVector/*  w  w w  .j a  va  2  s.c o m*/
 *
 * @param RouterIP
 * @param buf
 * @param len
 * @throws DoneException
 */
@SuppressWarnings("unchecked")
public V9_Packet(String RouterIP, byte[] buf, int len) throws DoneException {
    if (Params.DEBUG) {
        // 
        //            File tmpFile = new File("D:\\Dev\\netflow\\jnca\\savePacketT_211.98.0.147_256.cache.tmp");
        File tmpFile = new File("D:\\Dev\\netflow\\jnca\\savePacketT_211.98.0.147_256.cache.tmp");
        if (tmpFile.exists()) {
            try {
                ObjectInputStream fIn = new ObjectInputStream(new FileInputStream(tmpFile));
                System.out.println("Directly read from " + fIn);
                try {
                    buf = (byte[]) fIn.readObject();
                    len = ((Integer) fIn.readObject()).intValue();
                } catch (ClassNotFoundException e) {
                    e.printStackTrace();
                }
                fIn.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            try {
                ObjectOutputStream fOut;
                fOut = new ObjectOutputStream(new FileOutputStream(tmpFile));
                fOut.writeObject(buf);
                fOut.writeObject(new Integer(len));
                fOut.flush();
                fOut.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
        // 
    }
    if (len < V9_Header_Size) {
        throw new DoneException("    * incomplete header *");
    }

    this.routerIP = RouterIP;
    count = Util.to_number(buf, 2, 2); // (template data flowset

    SysUptime = Util.to_number(buf, 4, 4);
    Variation vrat = Variation.getInstance();
    vrat.setVary(Util.convertIPS2Long(RouterIP), SysUptime);
    unix_secs = Util.to_number(buf, 8, 4);
    packageSequence = Util.to_number(buf, 12, 4);
    sourceId = Util.to_number(buf, 16, 4);

    flows = new Vector((int) count * 30); // Let's first make some space
    optionFlows = new Vector();
    // t
    long flowsetLength = 0l;
    // flowset
    for (int flowsetCounter = 0, packetOffset = V9_Header_Size; flowsetCounter < count
            && packetOffset < len; flowsetCounter++, packetOffset += flowsetLength) {
        // flowset
        long flowsetId = Util.to_number(buf, packetOffset, 2);
        flowsetLength = Util.to_number(buf, packetOffset + 2, 2);
        if (flowsetLength == 0) {
            throw new DoneException("there is a flowset len=0packet invalid");
        }
        if (flowsetId == 0) {
            // template flowsettemplateiddata flowset
            // template flowset
            int thisTemplateOffset = packetOffset + 4;
            do {
                // template
                long templateId = Util.to_number(buf, thisTemplateOffset, 2);
                long fieldCount = Util.to_number(buf, thisTemplateOffset + 2, 2);
                if (TemplateManager.getTemplateManager().getTemplate(this.routerIP, (int) templateId) == null
                        || Params.v9TemplateOverwrite) {
                    try {
                        TemplateManager.getTemplateManager().acceptTemplate(this.routerIP, buf,
                                thisTemplateOffset);
                    } catch (Exception e) {
                        if (Params.DEBUG) {
                            e.printStackTrace();
                        }
                        if ((e.toString() != null) && (!e.toString().equals(""))) {
                            if (e.toString().startsWith("savePacket")) {
                                try {
                                    ObjectOutputStream fOut;
                                    fOut = new ObjectOutputStream(
                                            new FileOutputStream("./" + e.toString() + ".cache.tmp"));
                                    fOut.writeObject(buf);
                                    fOut.writeObject(new Integer(len));
                                    fOut.flush();
                                    fOut.close();
                                    System.err.println("Saved ");
                                } catch (FileNotFoundException e2) {
                                    e2.printStackTrace();
                                } catch (IOException e1) {
                                    e1.printStackTrace();
                                }
                            } else {
                                System.err.println("An Error without save:" + e.toString());
                            }
                        }
                    }

                }
                thisTemplateOffset += fieldCount * 4 + 4; //
            } while (thisTemplateOffset - packetOffset < flowsetLength);
        } else if (flowsetId == 1) { // options flowset
            continue;
            //                int thisOptionTemplateOffset = packetOffset + 4;
            //                // bypass flowsetID and flowset length
            //                do {
            //                    // template
            //                    long optionTemplateId = Util.to_number(buf,
            //                            thisOptionTemplateOffset, 2);
            //                    long scopeLen = Util.to_number(buf,
            //                            thisOptionTemplateOffset + 2, 2);
            //                    long optionLen = Util.to_number(buf,
            //                            thisOptionTemplateOffset + 4, 2);
            //                    if (OptionTemplateManager.getOptionTemplateManager()
            //                        .getOptionTemplate(this.routerIP,
            //                                           (int) optionTemplateId) == null
            //                        || Params.v9TemplateOverwrite) {
            //                        OptionTemplateManager.getOptionTemplateManager()
            //                                .acceptOptionTemplate(this.routerIP, buf,
            //                                thisOptionTemplateOffset);
            //                    }
            //                    thisOptionTemplateOffset += scopeLen + optionLen + 6;
            //                } while (thisOptionTemplateOffset -
            //                         packetOffset < flowsetLength);
        } else if (flowsetId > 255) {
            // data flowset
            // templateId==flowsetId
            Template tOfData = TemplateManager.getTemplateManager().getTemplate(this.routerIP, (int) flowsetId); // flowsetId==templateId
            if (tOfData != null) {
                int dataRecordLen = tOfData.getTypeOffset(-1); // 
                // packetOffset+4 flowsetId  length
                for (int idx = 0, p = packetOffset + 4; (p - packetOffset + dataRecordLen) < flowsetLength; //consider padding
                        idx++, p += dataRecordLen) { //+5 makes OK
                    // IP?v9v5
                    V5_Flow f;
                    try {
                        f = new V5_Flow(RouterIP, buf, p, tOfData);
                        flows.add(f);
                    } catch (DoneException e) {
                        if (Params.DEBUG) {
                            e.printStackTrace();
                        }
                        if ((e.toString() != null) && (!e.toString().equals(""))) {
                            if (e.toString().startsWith("savePacket")) {
                                try {
                                    ObjectOutputStream fOut;
                                    fOut = new ObjectOutputStream(
                                            new FileOutputStream("./" + e.toString() + ".cache.tmp"));
                                    fOut.writeObject(buf);
                                    fOut.writeObject(new Integer(len));
                                    fOut.flush();
                                    fOut.close();
                                    System.err.println("Saved ");
                                } catch (FileNotFoundException e2) {
                                    e2.printStackTrace();
                                } catch (IOException e1) {
                                    e1.printStackTrace();
                                }
                            } else {
                                System.err.println(e.toString());
                            }
                        }
                    }
                }
            } else { //options packet, should refer to option template, not in use now
                continue;
                //                    OptionTemplate otOfData = OptionTemplateManager
                //                                              .getOptionTemplateManager().
                //                                              getOptionTemplate(
                //                            this.routerIP, (int) flowsetId);
                //                    if (otOfData != null) {
                //                        int dataRecordLen = otOfData.getTypeOffset( -1); // 
                //                        // packetOffset+4 flowsetId  length
                //                        for (int idx = 0, p = packetOffset + 4; p
                //                                              - packetOffset < flowsetLength;
                //                                              idx++, p += dataRecordLen) {
                //                            OptionFlow of;
                //                            try {
                //                                of = new OptionFlow(RouterIP, buf, p, otOfData);
                ////                                optionFlows.add(of); // Vector
                //                            } catch (DoneException e) {
                //                                if (Params.DEBUG) {
                //                                    e.printStackTrace();
                //                                }
                //                                System.err.println(e.toString());
                //                            }
                //                        }
                //                    } else {
                //                        System.err.println(this.routerIP + "" + flowsetId
                //                                           + "template");
                //                    }
            }
        }
    }
}