alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (JField.java)

This example Scala source code file (JField.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

datainputstream, io, ioexception, jattribute, jclass, jclass, jfield, jfield, jfieldormethod, jtype, string, string, stringbuffer, stringbuffer

The Scala JField.java source code

/* FJBG -- Fast Java Bytecode Generator
 * Copyright 2002-2011 LAMP/EPFL
 * @author  Michel Schinz
 */

package ch.epfl.lamp.fjbg;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * Java class field.
 *
 * @author Michel Schinz
 * @version 1.0
 */

public class JField extends JFieldOrMethod {

    protected JField(FJBGContext context,
                     JClass owner,
                     int accessFlags,
                     String name,
                     JType type) {
        super(context, owner, accessFlags, name, type);
    }

    protected JField(FJBGContext context,
                     JClass owner,
                     DataInputStream stream)
        throws IOException {
        super(context, owner, stream);
    }

    // Follows javap output format for fields.
    /*@Override*/ public String toString() {
        StringBuffer buf = new StringBuffer(flagsToString());
        buf.append(toExternalName(getType()));
        buf.append(" ");
        buf.append(getName());
        buf.append(";\n");
        java.util.Iterator attrsIt = attributes.iterator();
        while (attrsIt.hasNext()) {
            JAttribute attrs = (JAttribute)attrsIt.next();
            buf.append(attrs);
        }
        return buf.toString();
    }

    private String flagsToString() {
        StringBuffer buf = new StringBuffer();
        if (isPublic()) buf.append("public ");
        else if (isProtected()) buf.append("protected ");
        else if (isPrivate()) buf.append("private ");
        if (isStatic()) buf.append("static ");
        else if (isTransient()) buf.append("transient ");
        else if (isVolatile()) buf.append("volatile ");
        if (isAbstract()) buf.append("abstract ");
        else if (isFinal()) buf.append("final ");
        return buf.toString();
    }
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala JField.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.