當前位置: 首頁>>代碼示例>>Java>>正文


Java GetField類代碼示例

本文整理匯總了Java中java.io.ObjectInputStream.GetField的典型用法代碼示例。如果您正苦於以下問題:Java GetField類的具體用法?Java GetField怎麽用?Java GetField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GetField類屬於java.io.ObjectInputStream包,在下文中一共展示了GetField類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
/**
 * Ensure that previously-serialized instances don't fail due to the member name change.
 */
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException
{
    GetField fields = is.readFields();
    if (fields.defaulted("first"))
    {
        // This is a pre-V3.3
        this.first = (F) fields.get("fFirst", null);
        this.second = (S) fields.get("fSecond", null);
    }
    else
    {
        this.first = (F) fields.get("first", null);
        this.second = (S) fields.get("second", null);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:20,代碼來源:Pair.java

示例2: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
/**
 * readObject is called to restore the state of the URL from the
 * stream.  It reads the components of the URL and finds the local
 * stream handler.
 */
private synchronized void readObject(java.io.ObjectInputStream s)
        throws IOException, ClassNotFoundException {
    GetField gf = s.readFields();
    String protocol = (String)gf.get("protocol", null);
    if (getURLStreamHandler(protocol) == null) {
        throw new IOException("unknown protocol: " + protocol);
    }
    String host = (String)gf.get("host", null);
    int port = gf.get("port", -1);
    String authority = (String)gf.get("authority", null);
    String file = (String)gf.get("file", null);
    String ref = (String)gf.get("ref", null);
    int hashCode = gf.get("hashCode", -1);
    if (authority == null
            && ((host != null && host.length() > 0) || port != -1)) {
        if (host == null)
            host = "";
        authority = (port == -1) ? host : host + ":" + port;
    }
    tempState = new UrlDeserializedState(protocol, host, port, authority,
           file, ref, hashCode);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:28,代碼來源:URL.java

示例3: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
{
	GetField fields = stream.readFields();
	fromVariable = (String) fields.get("fromVariable", null);
	
	// the fields of BaseCommonReturnValue were originally in this class.
	// if deserializing an old object, we need to manually copy the values into the parent class.
	ObjectStreamClass streamClass = fields.getObjectStreamClass();
	if (streamClass.getField("toVariable") != null)
	{
		this.toVariable = (String) fields.get("toVariable", null);
	}
	if (streamClass.getField("calculation") != null)
	{
		this.calculation = (CalculationEnum) fields.get("calculation", null);
	}
	if (streamClass.getField("incrementerFactoryClassName") != null)
	{
		this.incrementerFactoryClassName = (String) fields.get("incrementerFactoryClassName", null);
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:22,代碼來源:BaseReturnValue.java

示例4: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException
{
	setThreadJasperReportsContext();

	GetField fields = in.readFields();
	cachedRenderers = (Map<String, Renderable>) fields.get("cachedRenderers", null);
	cachedTemplates = (Map<String, JRTemplateElement>) fields.get("cachedTemplates", null);
	readOnly = fields.get("readOnly", false);
	// use configured default if serialized by old version
	pageElementSize = fields.get("pageElementSize", JRPropertiesUtil.getInstance(jasperReportsContext).getIntegerProperty(
			JRVirtualPrintPage.PROPERTY_VIRTUAL_PAGE_ELEMENT_SIZE, 0));
	
	setThreadVirtualizer();
	
	initLock();
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:18,代碼來源:JRVirtualizationContext.java

示例5: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
	GetField fields = in.readFields();
	this.PSEUDO_SERIAL_VERSION_UID = fields.get("PSEUDO_SERIAL_VERSION_UID", 0);
	if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
	{
		byte evaluationTime = fields.get("evaluationTime", (byte) 0);
		this.evaluationTimeValue = EvaluationTimeEnum.getByValue(evaluationTime);
	}
	else
	{
		this.evaluationTimeValue = (EvaluationTimeEnum) fields.get("evaluationTimeValue", null);
	}
	this.evaluationGroup = (String) fields.get("evaluationGroup", null);
	this.codeExpression = (JRExpression) fields.get("codeExpression", null);
	
	if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2
			&& this instanceof Barcode4jComponent)
	{
		//up to 6.0.0 this class had several fields that were moved to Barcode4jComponent in 6.0.2.
		//copying the values to the Barcode4jComponent fields.
		Barcode4jComponent barcode4jComponent = (Barcode4jComponent) this;
		barcode4jComponent.copyBarcodeComponentFields(fields);
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:27,代碼來源:BarcodeComponent.java

示例6: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    GetField fields = stream.readFields();

    eventCount = readIntField(fields, "eventCount", 0);
    sessionCount = readIntField(fields, "sessionCount", 0);
    subsessionCount = readIntField(fields, "subsessionCount", -1);
    sessionLength = readLongField(fields, "sessionLength", -1l);
    timeSpent = readLongField(fields, "timeSpent", -1l);
    lastActivity = readLongField(fields, "lastActivity", -1l);
    lastInterval = readLongField(fields, "lastInterval", -1l);

    // new fields
    uuid = readStringField(fields, "uuid", null);
    enabled = readBooleanField(fields, "enabled", true);
    askingAttribution = readBooleanField(fields, "askingAttribution", false);

    // create UUID for migrating devices
    if (uuid == null) {
        uuid = Util.createUuid();
    }
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:22,代碼來源:ActivityState.java

示例7: doReadObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
/**
 * Subclasses should call this method within their
 * readObject(ObjectInputStream) invocations
 *
 * @param stream
 * @throws IOException
 * @throws ClassNotFoundException
 */
protected void doReadObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
    final GetField readFields = stream.readFields();

    for (final String fieldName : getFieldNamesInAdditionToId()) {
        final Object value = readFields.get(fieldName, null);
        setField(fieldName, value);
    }

    // fix issue of deserializing _rowNumber in it's previous int form
    final long rowNumber;
    final ObjectStreamField legacyRowNumberField =
            readFields.getObjectStreamClass().getField(getFieldNameForOldId());
    if (legacyRowNumberField != null) {
        rowNumber = readFields.get(getFieldNameForOldId(), -1);
    } else {
        rowNumber = readFields.get(getFieldNameForNewId(), -1L);
    }

    setField(getFieldNameForNewId(), rowNumber);
}
 
開發者ID:datacleaner,項目名稱:DataCleaner,代碼行數:29,代碼來源:AbstractLegacyAwareInputRow.java

示例8: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
public void readObject(ObjectInputStream stream, Adaptor adaptor) throws IOException, ClassNotFoundException {
    try {
        GetField getField = stream.readFields();

        Field[] fields;
        fields = _clazz.getDeclaredFields();

        deserializeFields(fields, getField);

        fields = ReflectionUtils.getFields(_clazz, Moved.class);
        deserializeFields(fields, getField);

        if (adaptor != null) {
            adaptor.deserialize(getField, _serializable);
        }
    } catch (IOException e) {
        logger.error("Could not deserialize object!", e);
        throw e;
    }
}
 
開發者ID:datacleaner,項目名稱:AnalyzerBeans,代碼行數:21,代碼來源:ReadObjectBuilder.java

示例9: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    ReadObjectBuilder.create(this, SimpleSynonymCatalog.class).readObject(stream, new Adaptor() {
        @Override
        public void deserialize(GetField getField, Serializable serializable) throws IOException {
            // Get the old List<Synonym> field '_synonyms'.
            Object synonyms = getField.get("_synonyms", null);
            if (synonyms instanceof List) {
                try {
                    Field field = SimpleSynonymCatalog.class.getDeclaredField("_synonymMap");
                    field.setAccessible(true);
                    field.set(SimpleSynonymCatalog.this, new HashMap<String, String>());
                } catch (Exception e) {
                    throw new IllegalStateException(e);
                }

                @SuppressWarnings("unchecked")
                List<Synonym> synonymsList = (List<Synonym>) synonyms;
                for (Synonym synonym : synonymsList) {
                    addSynonym(synonym);
                }
            }
        }
    });
}
 
開發者ID:datacleaner,項目名稱:AnalyzerBeans,代碼行數:25,代碼來源:SimpleSynonymCatalog.java

示例10: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
/**
 * Method invoked by the Java serialization framework while deserializing
 * Row instances. Since previous versions of MetaModel did not use a
 * DataSetHeader, but had a reference to a List&lt;SelectItem&gt;, this
 * deserialization is particularly tricky. We check if the items variable is
 * there, and if it is, we convert it to a header instead.
 * 
 * @param stream
 * @throws Exception
 */
private void readObject(ObjectInputStream stream) throws Exception {
    GetField fields = stream.readFields();

    try {
        // backwards compatible deserialization, convert items to header
        Object items = fields.get("_items", null);
        @SuppressWarnings("unchecked")
        List<SelectItem> itemsList = (List<SelectItem>) items;
        SimpleDataSetHeader header = new SimpleDataSetHeader(itemsList);
        Field field = getClass().getDeclaredField("_header");
        field.setAccessible(true);
        field.set(this, header);
    } catch (IllegalArgumentException e) {
        // no backwards compatible deserialization needed.
        setWhileDeserializing(fields, "_header");
    }

    setWhileDeserializing(fields, "_values");
    setWhileDeserializing(fields, "_styles");
}
 
開發者ID:apache,項目名稱:metamodel,代碼行數:31,代碼來源:DefaultRow.java

示例11: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
@SuppressWarnings({ "unchecked", "deprecation" })
private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException
{
    GetField fields = is.readFields();
    if (fields.defaulted("versionsByLabel"))
    {
        // This is a V2.2 class
        // The old 'rootVersion' maps to the current 'rootVersion'
        this.versionsByLabel = (HashMap<String, Version>) fields.get("versions", new HashMap<String, Version>());
        // The old 'versionHistory' maps to the current 'versionHistory'
        this.versionHistory = (HashMap<String, String>) fields.get("versionHistory", new HashMap<String, String>());
        // Need this comparator as versionsByLabel is not a LinkedHashMap in this version 
        this.versionComparatorDesc = new VersionLabelComparator(); 
    }
    else if (fields.defaulted("versionComparatorDesc"))
    {
        // This is a V3.1.0 class
        // The old 'rootVersion' maps to the current 'rootVersion'
        this.versionsByLabel = (HashMap<String, Version>) fields.get("versionsByLabel", new HashMap<String, Version>());
        // The old 'versionHistory' maps to the current 'versionHistory'
        this.versionHistory = (HashMap<String, String>) fields.get("versionHistory", new HashMap<String, String>());
        // Need this comparator as versionsByLabel is not a LinkedHashMap in this version 
        this.versionComparatorDesc = new VersionLabelComparator(); 
    }
    else
    {
        // This is a V4.1.3 (and 4.0.2 HF) class
        // The old 'rootVersion' maps to the current 'rootVersion'
        this.versionsByLabel = (Map<String, Version>) fields.get("versionsByLabel", new LinkedHashMap<String, Version>());
        // The old 'versionHistory' maps to the current 'versionHistory'
        this.versionHistory = (HashMap<String, String>) fields.get("versionHistory", new HashMap<String, String>());
        this.versionComparatorDesc = (Comparator<Version>) fields.get("versionComparatorDesc", null); 
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:35,代碼來源:VersionHistoryImpl.java

示例12: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
private void readObject (ObjectInputStream s) throws
                     IOException, ClassNotFoundException {
    if (getClass().getClassLoader() != null) {
        throw new SecurityException ("invalid address type");
    }
    GetField gf = s.readFields();
    String host = (String)gf.get("hostName", null);
    int address= gf.get("address", 0);
    int family= gf.get("family", 0);
    InetAddressHolder h = new InetAddressHolder(host, address, family);
    UNSAFE.putObject(this, FIELDS_OFFSET, h);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:InetAddress.java

示例13: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
private void readObject(ObjectInputStream s)
    throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = s.readFields();
    @SuppressWarnings("unchecked")
    Hashtable<String,PermissionCollection> permTable =
            (Hashtable<String,PermissionCollection>)
            (fields.get("perms", null));
    if (permTable != null) {
        perms = new ConcurrentHashMap<>(permTable);
    } else {
        perms = new ConcurrentHashMap<>();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:CryptoPermissions.java

示例14: copyBarcodeComponentFields

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
protected final void copyBarcodeComponentFields(GetField fields) throws IOException
{
	int orientation = fields.get("orientation", 0);
	this.orientationValue = OrientationEnum.getByValue(orientation);
	this.patternExpression = (JRExpression) fields.get("patternExpression", null);
	this.moduleWidth = (Double) fields.get("moduleWidth", null);
	String textPosition = (String) fields.get("textPosition", null);
	this.textPositionValue = TextPositionEnum.getByName(textPosition);
	this.quietZone = (Double) fields.get("quietZone", null);
	this.verticalQuietZone = (Double) fields.get("verticalQuietZone", null);
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:12,代碼來源:Barcode4jComponent.java

示例15: readObject

import java.io.ObjectInputStream.GetField; //導入依賴的package包/類
@SuppressWarnings("unchecked") // we have to trust that keys are Ks and values are Vs
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    GetField fields = stream.readFields();
    comparator = (Comparator<? super K>) fields.get("comparator", null);
    if (comparator == null) {
        comparator = (Comparator<? super K>) NATURAL_ORDER;
    }
    int size = stream.readInt();
    for (int i = 0; i < size; i++) {
        putInternal((K) stream.readObject(), (V) stream.readObject());
    }
}
 
開發者ID:jtransc,項目名稱:jtransc,代碼行數:13,代碼來源:TreeMap.java


注:本文中的java.io.ObjectInputStream.GetField類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。