blob: cc00a5c2bb58edcb7ef3377d9f8254c9cd4f030b [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2009, 2018 Stephan Wahlbrink and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.rj.data.impl;
import java.io.IOException;
import org.eclipse.statet.rj.data.RJIO;
import org.eclipse.statet.rj.data.RList;
import org.eclipse.statet.rj.data.RObjectFactory;
import org.eclipse.statet.rj.data.RStore;
public class ROtherImpl extends AbstractRObject
implements ExternalizableRObject {
private String className1;
public ROtherImpl(final String className1) {
if (className1 == null) {
throw new NullPointerException();
}
this.className1= className1;
}
public ROtherImpl(final String className1, final RList attributes) {
if (className1 == null) {
throw new NullPointerException();
}
this.className1= className1;
setAttributes(attributes);
}
public ROtherImpl(final RJIO io, final RObjectFactory factory) throws IOException {
readExternal(io, factory);
}
public void readExternal(final RJIO io, final RObjectFactory factory) throws IOException {
//-- options
final int options= io.readInt();
//-- special attributes
this.className1= io.readString();
//-- attributes
if ((options & RObjectFactory.O_WITH_ATTR) != 0) {
setAttributes(factory.readAttributeList(io));
}
}
@Override
public void writeExternal(final RJIO io, final RObjectFactory factory) throws IOException {
final RList attributes= ((io.flags & RObjectFactory.F_WITH_ATTR) != 0) ? getAttributes() : null;
//-- options
final int options= (attributes != null) ? RObjectFactory.O_WITH_ATTR : 0;
io.writeInt(options);
//-- special attributes
io.writeString(this.className1);
//-- attributes
if (attributes != null) {
factory.writeAttributeList(attributes, io);
}
}
@Override
public byte getRObjectType() {
return TYPE_OTHER;
}
@Override
public String getRClassName() {
return this.className1;
}
@Override
public long getLength() {
return 0;
}
@Override
public RStore<?> getData() {
return null;
}
}