com.sun.xml.internal.bind.CycleRecoverable Java Examples

The following examples show how to use com.sun.xml.internal.bind.CycleRecoverable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLSerializer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pushes the object to {@link #cycleDetectionStack} and also
 * detect any cycles.
 *
 * When a cycle is found, this method tries to recover from it.
 *
 * @return
 *      the object that should be marshalled instead of the given <tt>obj</tt>,
 *      or null if the error is found and we need to avoid marshalling this object
 *      to prevent infinite recursion. When this method returns null, the error
 *      has already been reported.
 */
private Object pushObject(Object obj, String fieldName) throws SAXException {
    if(!cycleDetectionStack.push(obj))
        return obj;

    // allow the object to nominate its replacement
    if(obj instanceof CycleRecoverable) {
        obj = ((CycleRecoverable)obj).onCycleDetected(new CycleRecoverable.Context(){
            public Marshaller getMarshaller() {
                return marshaller;
            }
        });
        if(obj!=null) {
            // object nominated its replacement.
            // we still need to make sure that the nominated.
            // this may cause inifinite recursion on its own.
            cycleDetectionStack.pop();
            return pushObject(obj,fieldName);
        } else
            return null;
    }

    // cycle detected and no one is catching the error.
    reportError(new ValidationEventImpl(
        ValidationEvent.ERROR,
        Messages.CYCLE_IN_MARSHALLER.format(cycleDetectionStack.getCycleString()),
        getCurrentLocation(fieldName),
        null));
    return null;
}
 
Example #2
Source File: XMLSerializer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pushes the object to {@link #cycleDetectionStack} and also
 * detect any cycles.
 *
 * When a cycle is found, this method tries to recover from it.
 *
 * @return
 *      the object that should be marshalled instead of the given <tt>obj</tt>,
 *      or null if the error is found and we need to avoid marshalling this object
 *      to prevent infinite recursion. When this method returns null, the error
 *      has already been reported.
 */
private Object pushObject(Object obj, String fieldName) throws SAXException {
    if(!cycleDetectionStack.push(obj))
        return obj;

    // allow the object to nominate its replacement
    if(obj instanceof CycleRecoverable) {
        obj = ((CycleRecoverable)obj).onCycleDetected(new CycleRecoverable.Context(){
            public Marshaller getMarshaller() {
                return marshaller;
            }
        });
        if(obj!=null) {
            // object nominated its replacement.
            // we still need to make sure that the nominated.
            // this may cause inifinite recursion on its own.
            cycleDetectionStack.pop();
            return pushObject(obj,fieldName);
        } else
            return null;
    }

    // cycle detected and no one is catching the error.
    reportError(new ValidationEventImpl(
        ValidationEvent.ERROR,
        Messages.CYCLE_IN_MARSHALLER.format(cycleDetectionStack.getCycleString()),
        getCurrentLocation(fieldName),
        null));
    return null;
}
 
Example #3
Source File: XMLSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pushes the object to {@link #cycleDetectionStack} and also
 * detect any cycles.
 *
 * When a cycle is found, this method tries to recover from it.
 *
 * @return
 *      the object that should be marshalled instead of the given <tt>obj</tt>,
 *      or null if the error is found and we need to avoid marshalling this object
 *      to prevent infinite recursion. When this method returns null, the error
 *      has already been reported.
 */
private Object pushObject(Object obj, String fieldName) throws SAXException {
    if(!cycleDetectionStack.push(obj))
        return obj;

    // allow the object to nominate its replacement
    if(obj instanceof CycleRecoverable) {
        obj = ((CycleRecoverable)obj).onCycleDetected(new CycleRecoverable.Context(){
            public Marshaller getMarshaller() {
                return marshaller;
            }
        });
        if(obj!=null) {
            // object nominated its replacement.
            // we still need to make sure that the nominated.
            // this may cause inifinite recursion on its own.
            cycleDetectionStack.pop();
            return pushObject(obj,fieldName);
        } else
            return null;
    }

    // cycle detected and no one is catching the error.
    reportError(new ValidationEventImpl(
        ValidationEvent.ERROR,
        Messages.CYCLE_IN_MARSHALLER.format(cycleDetectionStack.getCycleString()),
        getCurrentLocation(fieldName),
        null));
    return null;
}
 
Example #4
Source File: XMLSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pushes the object to {@link #cycleDetectionStack} and also
 * detect any cycles.
 *
 * When a cycle is found, this method tries to recover from it.
 *
 * @return
 *      the object that should be marshalled instead of the given <tt>obj</tt>,
 *      or null if the error is found and we need to avoid marshalling this object
 *      to prevent infinite recursion. When this method returns null, the error
 *      has already been reported.
 */
private Object pushObject(Object obj, String fieldName) throws SAXException {
    if(!cycleDetectionStack.push(obj))
        return obj;

    // allow the object to nominate its replacement
    if(obj instanceof CycleRecoverable) {
        obj = ((CycleRecoverable)obj).onCycleDetected(new CycleRecoverable.Context(){
            public Marshaller getMarshaller() {
                return marshaller;
            }
        });
        if(obj!=null) {
            // object nominated its replacement.
            // we still need to make sure that the nominated.
            // this may cause inifinite recursion on its own.
            cycleDetectionStack.pop();
            return pushObject(obj,fieldName);
        } else
            return null;
    }

    // cycle detected and no one is catching the error.
    reportError(new ValidationEventImpl(
        ValidationEvent.ERROR,
        Messages.CYCLE_IN_MARSHALLER.format(cycleDetectionStack.getCycleString()),
        getCurrentLocation(fieldName),
        null));
    return null;
}
 
Example #5
Source File: XMLSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pushes the object to {@link #cycleDetectionStack} and also
 * detect any cycles.
 *
 * When a cycle is found, this method tries to recover from it.
 *
 * @return
 *      the object that should be marshalled instead of the given {@code obj},
 *      or null if the error is found and we need to avoid marshalling this object
 *      to prevent infinite recursion. When this method returns null, the error
 *      has already been reported.
 */
private Object pushObject(Object obj, String fieldName) throws SAXException {
    if(!cycleDetectionStack.push(obj))
        return obj;

    // allow the object to nominate its replacement
    if(obj instanceof CycleRecoverable) {
        obj = ((CycleRecoverable)obj).onCycleDetected(new CycleRecoverable.Context(){
            public Marshaller getMarshaller() {
                return marshaller;
            }
        });
        if(obj!=null) {
            // object nominated its replacement.
            // we still need to make sure that the nominated.
            // this may cause inifinite recursion on its own.
            cycleDetectionStack.pop();
            return pushObject(obj,fieldName);
        } else
            return null;
    }

    // cycle detected and no one is catching the error.
    reportError(new ValidationEventImpl(
        ValidationEvent.ERROR,
        Messages.CYCLE_IN_MARSHALLER.format(cycleDetectionStack.getCycleString()),
        getCurrentLocation(fieldName),
        null));
    return null;
}
 
Example #6
Source File: XMLSerializer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pushes the object to {@link #cycleDetectionStack} and also
 * detect any cycles.
 *
 * When a cycle is found, this method tries to recover from it.
 *
 * @return
 *      the object that should be marshalled instead of the given <tt>obj</tt>,
 *      or null if the error is found and we need to avoid marshalling this object
 *      to prevent infinite recursion. When this method returns null, the error
 *      has already been reported.
 */
private Object pushObject(Object obj, String fieldName) throws SAXException {
    if(!cycleDetectionStack.push(obj))
        return obj;

    // allow the object to nominate its replacement
    if(obj instanceof CycleRecoverable) {
        obj = ((CycleRecoverable)obj).onCycleDetected(new CycleRecoverable.Context(){
            public Marshaller getMarshaller() {
                return marshaller;
            }
        });
        if(obj!=null) {
            // object nominated its replacement.
            // we still need to make sure that the nominated.
            // this may cause inifinite recursion on its own.
            cycleDetectionStack.pop();
            return pushObject(obj,fieldName);
        } else
            return null;
    }

    // cycle detected and no one is catching the error.
    reportError(new ValidationEventImpl(
        ValidationEvent.ERROR,
        Messages.CYCLE_IN_MARSHALLER.format(cycleDetectionStack.getCycleString()),
        getCurrentLocation(fieldName),
        null));
    return null;
}
 
Example #7
Source File: XMLSerializer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pushes the object to {@link #cycleDetectionStack} and also
 * detect any cycles.
 *
 * When a cycle is found, this method tries to recover from it.
 *
 * @return
 *      the object that should be marshalled instead of the given <tt>obj</tt>,
 *      or null if the error is found and we need to avoid marshalling this object
 *      to prevent infinite recursion. When this method returns null, the error
 *      has already been reported.
 */
private Object pushObject(Object obj, String fieldName) throws SAXException {
    if(!cycleDetectionStack.push(obj))
        return obj;

    // allow the object to nominate its replacement
    if(obj instanceof CycleRecoverable) {
        obj = ((CycleRecoverable)obj).onCycleDetected(new CycleRecoverable.Context(){
            public Marshaller getMarshaller() {
                return marshaller;
            }
        });
        if(obj!=null) {
            // object nominated its replacement.
            // we still need to make sure that the nominated.
            // this may cause inifinite recursion on its own.
            cycleDetectionStack.pop();
            return pushObject(obj,fieldName);
        } else
            return null;
    }

    // cycle detected and no one is catching the error.
    reportError(new ValidationEventImpl(
        ValidationEvent.ERROR,
        Messages.CYCLE_IN_MARSHALLER.format(cycleDetectionStack.getCycleString()),
        getCurrentLocation(fieldName),
        null));
    return null;
}
 
Example #8
Source File: XMLSerializer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pushes the object to {@link #cycleDetectionStack} and also
 * detect any cycles.
 *
 * When a cycle is found, this method tries to recover from it.
 *
 * @return
 *      the object that should be marshalled instead of the given <tt>obj</tt>,
 *      or null if the error is found and we need to avoid marshalling this object
 *      to prevent infinite recursion. When this method returns null, the error
 *      has already been reported.
 */
private Object pushObject(Object obj, String fieldName) throws SAXException {
    if(!cycleDetectionStack.push(obj))
        return obj;

    // allow the object to nominate its replacement
    if(obj instanceof CycleRecoverable) {
        obj = ((CycleRecoverable)obj).onCycleDetected(new CycleRecoverable.Context(){
            public Marshaller getMarshaller() {
                return marshaller;
            }
        });
        if(obj!=null) {
            // object nominated its replacement.
            // we still need to make sure that the nominated.
            // this may cause inifinite recursion on its own.
            cycleDetectionStack.pop();
            return pushObject(obj,fieldName);
        } else
            return null;
    }

    // cycle detected and no one is catching the error.
    reportError(new ValidationEventImpl(
        ValidationEvent.ERROR,
        Messages.CYCLE_IN_MARSHALLER.format(cycleDetectionStack.getCycleString()),
        getCurrentLocation(fieldName),
        null));
    return null;
}