Example usage for java.io InvalidObjectException InvalidObjectException

List of usage examples for java.io InvalidObjectException InvalidObjectException

Introduction

In this page you can find the example usage for java.io InvalidObjectException InvalidObjectException.

Prototype

public InvalidObjectException(String reason) 

Source Link

Document

Constructs an InvalidObjectException.

Usage

From source file:org.protempa.PropositionDefinitionCache.java

/**
 * Overrides default de-serialization./*  w  w  w .  j a va 2  s. com*/
 * 
 * @param s
 *            an <code>ObjectInputStream</code> object.
 * @throws IOException
 *             if de-serialization failed.
 * @throws ClassNotFoundException
 *             if de-serialization failed.
 */
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
    initialize();

    Collection<PropositionDefinition> propositionDefinitions = (Collection<PropositionDefinition>) s
            .readObject();
    Collection<AbstractionDefinition> abstractionDefinitions = (Collection<AbstractionDefinition>) s
            .readObject();
    Collection<ValueSet> valueSets = (Collection<ValueSet>) s.readObject();
    Collection<ContextDefinition> contextDefinitions = (Collection<ContextDefinition>) s.readObject();
    Collection<TemporalPropositionDefinition> temporalPropositionDefinitions = (Collection<TemporalPropositionDefinition>) s
            .readObject();

    if (propositionDefinitions != null) {
        for (PropositionDefinition def : propositionDefinitions) {
            if (def == null) {
                throw new InvalidObjectException("Null primitive parameter definition; can't restore");
            }
            try {
                addPropositionDefinition(def);
            } catch (InvalidPropositionIdException ex) {
                String msg = "Could not add de-serialized proposition definition " + def;
                //InvalidObjectException doesn't support nested exceptions.
                ProtempaUtil.logger().log(Level.SEVERE, msg, ex);
                throw new InvalidObjectException(msg);
            }
        }
    } else {
        throw new InvalidObjectException("propositionDefinitions cannot be null");
    }

    if (abstractionDefinitions != null) {
        for (AbstractionDefinition def : abstractionDefinitions) {
            if (def == null) {
                throw new InvalidObjectException("Null abstraction definition; can't restore");
            }
            try {
                addAbstractionDefinition(def);
            } catch (InvalidPropositionIdException ex) {
                String msg = "Could not add de-serialized abstract parameter definition " + def;
                //InvalidObjectException doesn't support nested exceptions.
                ProtempaUtil.logger().log(Level.SEVERE, msg, ex);
                throw new InvalidObjectException(msg);
            }
        }
    } else {
        throw new InvalidObjectException("abstractionDefinitions cannot be null");
    }

    if (valueSets != null) {
        for (ValueSet valueSet : valueSets) {
            if (valueSet == null) {
                throw new InvalidObjectException("Null value set; can't restore");
            }
            try {
                addValueSet(valueSet);
            } catch (InvalidValueSetDefinitionException ex) {
                String msg = "Could not add de-serialized value set " + valueSet;
                //InvalidObjectException doesn't support nested exceptions.
                ProtempaUtil.logger().log(Level.SEVERE, msg, ex);
                throw new InvalidObjectException(msg);
            }
        }
    }

    if (temporalPropositionDefinitions != null) {
        for (ContextDefinition def : contextDefinitions) {
            if (def == null) {
                throw new InvalidObjectException("Null context definition; can't restore");
            }
            try {
                addContextDefinition(def);
            } catch (InvalidPropositionIdException ex) {
                String msg = "Could not add de-serialized context definition " + def;
                //InvalidObjectException doesn't support nested exceptions.
                ProtempaUtil.logger().log(Level.SEVERE, msg, ex);
                throw new InvalidObjectException(msg);
            }
        }
    } else {
        throw new InvalidObjectException("contextDefinitions cannot be null");
    }

    if (temporalPropositionDefinitions != null) {
        for (TemporalPropositionDefinition def : temporalPropositionDefinitions) {
            if (def == null) {
                throw new InvalidObjectException("Null temporalPropositionDefinition; can't restore");
            }
            try {
                addTemporalPropositionDefinition(def);
            } catch (InvalidPropositionIdException ex) {
                String msg = "Could not add de-serialized temporalPropositionDefinition " + def;
                //InvalidObjectException doesn't support nested exceptions.
                ProtempaUtil.logger().log(Level.SEVERE, msg, ex);
                throw new InvalidObjectException(msg);
            }
        }
    } else {
        throw new InvalidObjectException("temporalPropositionDefinitions cannot be null");
    }
}

From source file:com.phoenixst.plexus.util.SynchronizedGraph.java

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();/*w  w w  .  j a va  2s .c  o  m*/
    if (delegate == null) {
        throw new InvalidObjectException("Wrapped Graph is null.");
    }
    if (mutex == null) {
        throw new InvalidObjectException("Mutex is null.");
    }
    initialize();
}

From source file:org.protempa.proposition.UniqueId.java

private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
    if (s.readBoolean()) {
        this.sourceId = DerivedSourceId.getInstance();
    } else {//from  www .  ja  v  a  2 s. c  o  m
        String id = (String) s.readObject();
        if (id == null) {
            throw new InvalidObjectException("Can't restore. Null id");
        }
        this.sourceId = DataSourceBackendId.getInstance(id);
    }
    this.localUniqueId = (LocalUniqueId) s.readObject();
}

From source file:org.lenskit.mf.MFModel.java

private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException {
    featureCount = input.readInt();/*  w  w w .  j  a  v  a  2s .c om*/
    userCount = input.readInt();
    itemCount = input.readInt();

    RealMatrix umat = MatrixUtils.createRealMatrix(userCount, featureCount);
    for (int i = 0; i < userCount; i++) {
        for (int j = 0; j < featureCount; j++) {
            umat.setEntry(i, j, input.readDouble());
        }
    }
    userMatrix = umat;

    RealMatrix imat = MatrixUtils.createRealMatrix(itemCount, featureCount);
    for (int i = 0; i < itemCount; i++) {
        for (int j = 0; j < featureCount; j++) {
            imat.setEntry(i, j, input.readDouble());
        }
    }
    itemMatrix = imat;

    userIndex = (KeyIndex) input.readObject();
    itemIndex = (KeyIndex) input.readObject();

    if (userIndex.size() != userMatrix.getRowDimension()) {
        throw new InvalidObjectException("user matrix and index have different row counts");
    }
    if (itemIndex.size() != itemMatrix.getRowDimension()) {
        throw new InvalidObjectException("item matrix and index have different row counts");
    }
}

From source file:org.grouplens.lenskit.data.dao.packed.BinaryIndexTable.java

private Object readObject(ObjectInputStream in) throws IOException {
    throw new InvalidObjectException("index table must use serial proxy");
}

From source file:org.protempa.backend.dsb.relationaldb.SQLGenLocalUniqueId.java

private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
    this.entitySpecName = (String) s.readObject();
    if (this.entitySpecName == null) {
        throw new InvalidObjectException("name cannot be null. Can't restore");
    }//from www.j av  a2s  .  c  o  m

    // We intern entity spec names elsewhere, so let's do it here too.
    this.entitySpecName = this.entitySpecName.intern();

    int dbIdsLen = s.readInt();
    if (dbIdsLen < 0) {
        throw new InvalidObjectException("dbIds length invalid (" + dbIdsLen + "). Can't restore");
    }
    this.dbIds = new String[dbIdsLen];
    for (int i = 0; i < dbIdsLen; i++) {
        String dbId = (String) s.readObject();
        if (dbId == null) {
            throw new InvalidObjectException("dbIds cannot contain a null value. Can't restore");
        }
        this.dbIds[i] = dbId;
    }
}

From source file:pl.nalazek.githubsearch.data.ResponsePackage.java

private void checkIfTypeCorrect(ResponsePackage responsePackage) throws InvalidObjectException {
    if (!queryType.equals(responsePackage.queryType))
        throw new InvalidObjectException("Cannot combine packages. Query type incompatibility!");
}

From source file:ddf.catalog.data.AttributeImpl.java

private void validateUntampered(int numElements) throws InvalidObjectException {
    // Invariant: When the object was serialized, the integer written to
    // disk matched the number of value objects written to disk.
    if (values.size() != numElements) {
        throw new InvalidObjectException(
                "Corrupt object: written number of values does not match actual number of values.");
    }//from w w w . j av  a 2s. c  o  m
}

From source file:com.bstek.dorado.data.provider.PagingList.java

@Override
public Object writeReplace() throws ObjectStreamException {
    try {/*from   w w w  . j  a  v  a2 s .  c om*/
        List<E> list = new ArrayList<E>();
        for (int i = 1; i <= pageCount; i++) {
            Page<E> page = getPage(pageNo);
            list.addAll(page.getEntities());
        }
        return list;
    } catch (Exception e) {
        logger.error(e, e);
        throw new InvalidObjectException(e.getMessage());
    }
}

From source file:ddf.catalog.data.AttributeImpl.java

private void validateNonEmpty(int numElements) throws InvalidObjectException {
    // Invariant: This implementation does not allow an Attribute object
    // with no values
    if (numElements == 0) {
        throw new InvalidObjectException(
                "Cannot construct " + this.getClass().getName() + " object without any values.");
    }//from w  ww  .  j  a  va  2 s.c om
}