OrderedEmfFormatter.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:n4js 作者:
private static void refToStr(EObject obj, EReference ref, String indent, Appendable buf) throws Exception {
    Object o = obj.eGet(ref);
    if (o instanceof EObject) {
        EObject eo = (EObject) o;

        if (eo instanceof ENamedElement)
            buf.append("'").append(((ENamedElement) eo).getName()).append("' ");
        buf.append("ref: ");
        getURI(obj, eo, buf);
        return;
    }
    if (o instanceof Collection<?>) {
        String innerIndent = indent + INDENT;
        buf.append("[");
        int counter = 0;
        Collection<?> coll = (Collection<?>) o;
        for (Iterator<?> i = coll.iterator(); i.hasNext();) {
            Object item = i.next();
            if (counter == 0)
                buf.append('\n');
            buf.append(innerIndent);
            printInt(counter++, coll.size(), buf);
            buf.append(": ");
            getURI(obj, (EObject) item, buf);
            if (i.hasNext())
                buf.append(",\n");
            else
                buf.append('\n').append(indent);
        }
        buf.append("]");
        return;
    }
    buf.append("?????");
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号