⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 document.java

📁 xwiki 源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public String[] getRecentRevisions(int nb) throws XWikiException {
        return doc.getRecentRevisions(nb, context);
    }

    public List getAttachmentList() {
        List list = doc.getAttachmentList();
        List list2 = new ArrayList();
        for (int i=0;i<list.size();i++) {
            list2.add(new Attachment(this, (XWikiAttachment)list.get(i), context));
        }
        return list2;
    }

    public Vector getComments() {
        return getComments(true);
    }

    public Vector getComments(boolean asc) {
        if (asc)
            return getObjects("XWiki.XWikiComments");
        else {
            Vector list = getObjects("XWiki.XWikiComments");
            if (list==null)
                return list;
            Vector newlist = new Vector();
            for (int i=list.size()-1;i>=0;i--) {
                newlist.add(list.get(i));
            }
            return newlist;
        }
    }


    public String display(String fieldname, Object obj) {
        if (obj==null)
            return "";
        return doc.display(fieldname, obj.getBaseObject(), context);
    }

    public String display(String fieldname, String mode, Object obj) {
        if (obj==null)
            return "";
        return doc.display(fieldname, mode, obj.getBaseObject(), context);
    }

    public String display(String fieldname) {
        return doc.display(fieldname, context);
    }

    public String displayForm(String className,String header, String format) {
        return doc.displayForm(className, header, format, context);
    }

    public String displayForm(String className,String header, String format, boolean linebreak) {
        return doc.displayForm(className, header, format, linebreak, context);
    }

    public String displayForm(String className) {
        return doc.displayForm(className, context);
    }

    public String displayRendered(com.xpn.xwiki.api.PropertyClass pclass, String prefix, Collection object) {
        if ((pclass==null)||(object==null))
            return "";
        return doc.displayRendered(pclass.getBasePropertyClass(), prefix, object.getCollection(), context);
    }

    public String displayView(com.xpn.xwiki.api.PropertyClass pclass, String prefix, Collection object) {
        if ((pclass==null)||(object==null))
            return "";
        return doc.displayView(pclass.getBasePropertyClass(), prefix, object.getCollection(), context);
    }

    public String displayEdit(com.xpn.xwiki.api.PropertyClass pclass, String prefix, Collection object) {
        if ((pclass==null)||(object==null))
            return "";
        return doc.displayEdit(pclass.getBasePropertyClass(), prefix, object.getCollection(), context);
    }

    public String displayHidden(com.xpn.xwiki.api.PropertyClass pclass, String prefix, Collection object) {
        if ((pclass==null)||(object==null))
            return "";
        return doc.displayHidden(pclass.getBasePropertyClass(), prefix, object.getCollection(), context);
    }

    public String displaySearch(com.xpn.xwiki.api.PropertyClass pclass, String prefix, Collection object) {
        if ((pclass==null)||(object==null))
            return "";
        return doc.displaySearch(pclass.getBasePropertyClass(), prefix, object.getCollection(), context);
    }

    public List getIncludedPages() {
        return doc.getIncludedPages(context);
    }

    public List getIncludedMacros() {
        return doc.getIncludedMacros(context);
    }

    public List getLinkedPages() {
        return doc.getLinkedPages(context);
    }

    public Attachment getAttachment(String filename) {
        XWikiAttachment attach = doc.getAttachment(filename);
        if (attach==null)
            return null;
        else
            return new Attachment(this, attach, context);
    }

    public List getContentDiff(Document origdoc, Document newdoc) throws XWikiException, DifferentiationFailedException {
        try {
            if ((origdoc==null)&&(newdoc==null))
                return new ArrayList();
            if (origdoc==null)
                return doc.getContentDiff(new XWikiDocument(newdoc.getWeb(), newdoc.getName()), newdoc.getDoc(), context);
            if (newdoc==null)
                return doc.getContentDiff(origdoc.getDoc(), new XWikiDocument(origdoc.getWeb(), origdoc.getName()), context);

            return doc.getContentDiff(origdoc.getDoc(), newdoc.getDoc(), context);
        } catch (Exception e) {
            java.lang.Object[] args = { origdoc.getFullName(), origdoc.getVersion(), newdoc.getVersion() };
            List list = new ArrayList();
            XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_DIFF, XWikiException.ERROR_XWIKI_DIFF_CONTENT_ERROR,
                    "Error while making content diff of {0} between version {1} and version {2}", e, args);
            String errormsg = Util.getHTMLExceptionMessage(xe, context);
            list.add(errormsg);
            return list;
        }
    }

    public List getXMLDiff(Document origdoc, Document newdoc) throws XWikiException, DifferentiationFailedException {
        try {
            if ((origdoc==null)&&(newdoc==null))
                return new ArrayList();
            if (origdoc==null)
                return doc.getXMLDiff(new XWikiDocument(newdoc.getWeb(), newdoc.getName()), newdoc.getDoc(), context);
            if (newdoc==null)
                return doc.getXMLDiff(origdoc.getDoc(), new XWikiDocument(origdoc.getWeb(), origdoc.getName()), context);

            return doc.getXMLDiff(origdoc.getDoc(), newdoc.getDoc(), context);
        } catch (Exception e) {
            java.lang.Object[] args = { origdoc.getFullName(), origdoc.getVersion(), newdoc.getVersion() };
            List list = new ArrayList();
            XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_DIFF, XWikiException.ERROR_XWIKI_DIFF_XML_ERROR,
                    "Error while making xml diff of {0} between version {1} and version {2}", e, args);
            String errormsg = Util.getHTMLExceptionMessage(xe, context);
            list.add(errormsg);
            return list;
        }
    }

    public List getRenderedContentDiff(Document origdoc, Document newdoc) throws XWikiException, DifferentiationFailedException {
        try {
            if ((origdoc==null)&&(newdoc==null))
                return new ArrayList();
            if (origdoc==null)
                return doc.getRenderedContentDiff(new XWikiDocument(newdoc.getWeb(), newdoc.getName()), newdoc.getDoc(), context);
            if (newdoc==null)
                return doc.getRenderedContentDiff(origdoc.getDoc(), new XWikiDocument(origdoc.getWeb(), origdoc.getName()), context);

            return doc.getRenderedContentDiff(origdoc.getDoc(), newdoc.getDoc(), context);
        } catch (Exception e) {
            java.lang.Object[] args = { origdoc.getFullName(), origdoc.getVersion(), newdoc.getVersion() };
            List list = new ArrayList();
            XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_DIFF, XWikiException.ERROR_XWIKI_DIFF_RENDERED_ERROR,
                    "Error while making rendered diff of {0} between version {1} and version {2}", e, args);
            String errormsg = Util.getHTMLExceptionMessage(xe, context);
            list.add(errormsg);
            return list;
        }
    }

    public List getMetaDataDiff(Document origdoc, Document newdoc) throws XWikiException {
        try {
            if ((origdoc==null)&&(newdoc==null))
                return new ArrayList();
            if (origdoc==null)
                return doc.getMetaDataDiff(new XWikiDocument(newdoc.getWeb(), newdoc.getName()), newdoc.getDoc(), context);
            if (newdoc==null)
                return doc.getMetaDataDiff(origdoc.getDoc(), new XWikiDocument(origdoc.getWeb(), origdoc.getName()), context);

            return doc.getMetaDataDiff(origdoc.getDoc(), newdoc.getDoc(), context);
        } catch (Exception e) {
            java.lang.Object[] args = { origdoc.getFullName(), origdoc.getVersion(), newdoc.getVersion() };
            List list = new ArrayList();
            XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_DIFF, XWikiException.ERROR_XWIKI_DIFF_METADATA_ERROR,
                    "Error while making meta data diff of {0} between version {1} and version {2}", e, args);
            String errormsg = Util.getHTMLExceptionMessage(xe, context);
            list.add(errormsg);
            return list;
        }
    }

    public List getObjectDiff(Document origdoc, Document newdoc) throws XWikiException {
        try {
            if ((origdoc==null)&&(newdoc==null))
                return new ArrayList();
            if (origdoc==null)
                return doc.getObjectDiff(new XWikiDocument(newdoc.getWeb(), newdoc.getName()), newdoc.getDoc(), context);
            if (newdoc==null)
                return doc.getObjectDiff(origdoc.getDoc(), new XWikiDocument(origdoc.getWeb(), origdoc.getName()), context);

            return doc.getObjectDiff(origdoc.getDoc(), newdoc.getDoc(), context);
        } catch (Exception e) {
            java.lang.Object[] args = { origdoc.getFullName(), origdoc.getVersion(), newdoc.getVersion() };
            List list = new ArrayList();
            XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_DIFF, XWikiException.ERROR_XWIKI_DIFF_OBJECT_ERROR,
                    "Error while making meta object diff of {0} between version {1} and version {2}", e, args);
            String errormsg = Util.getHTMLExceptionMessage(xe, context);
            list.add(errormsg);
            return list;
        }
    }

    public List getClassDiff(Document origdoc, Document newdoc) throws XWikiException {
        try {
            if ((origdoc==null)&&(newdoc==null))
                return new ArrayList();
            if (origdoc==null)
                return doc.getClassDiff(new XWikiDocument(newdoc.getWeb(), newdoc.getName()), newdoc.getDoc(), context);
            if (newdoc==null)
                return doc.getClassDiff(origdoc.getDoc(), new XWikiDocument(origdoc.getWeb(), origdoc.getName()), context);

            return doc.getClassDiff(origdoc.getDoc(), newdoc.getDoc(), context);
        } catch (Exception e) {
            java.lang.Object[] args = { origdoc.getFullName(), origdoc.getVersion(), newdoc.getVersion() };
            List list = new ArrayList();
            XWikiException xe = new XWikiException(XWikiException.MODULE_XWIKI_DIFF, XWikiException.ERROR_XWIKI_DIFF_CLASS_ERROR,
                    "Error while making class diff of {0} between version {1} and version {2}", e, args);
            String errormsg = Util.getHTMLExceptionMessage(xe, context);
            list.add(errormsg);
            return list;
        }
    }

    public List getLastChanges() throws XWikiException, DifferentiationFailedException {
        return doc.getLastChanges(context);
    }

    public DocumentStats getCurrentMonthPageStats(String action) {
        return context.getWiki().getStatsService(context).getDocMonthStats(doc.getFullName(), "view", new Date(), context);
    }

    public DocumentStats getCurrentMonthWebStats(String action) {
        return context.getWiki().getStatsService(context).getDocMonthStats(doc.getWeb(), "view", new Date(), context);
    }

    public List getCurrentMonthRefStats() throws XWikiException {
        return context.getWiki().getStatsService(context).getRefMonthStats(doc.getFullName(), new Date(), context);
    }

    public boolean checkAccess(String right) {
        try {
            return context.getWiki().checkAccess(right, doc, context);
        } catch (XWikiException e) {
            return false;
        }
    }

    public boolean hasAccessLevel(String level) {
        try {
            return context.getWiki().getRightService().hasAccessLevel(level, context.getUser(), doc.getFullName(), context);
        } catch (Exception e) {
            return false;
        }
    }

    public boolean hasAccessLevel(String level, String user) {
        try {
            return context.getWiki().getRightService().hasAccessLevel(level, user, doc.getFullName(), context);
        } catch (Exception e) {
            return false;
        }
    }

    public boolean getLocked() {
        try{
            XWikiLock lock = doc.getLock(context);
            if (lock != null && !context.getUser().equals(lock.getUserName()))
                return true;
            else
                return false;
        } catch(Exception e) {
            return false;
        }
    }

    public String getLockingUser() {
        try {
            XWikiLock lock = doc.getLock(context);
            if (lock != null && !context.getUser().equals(lock.getUserName()))
                return lock.getUserName();
            else
                return "";
        } catch (XWikiException e) {
            return "";
        }
    }

    public java.lang.Object get(String classOrFieldName) {
        BaseObject object = doc.getFirstObject(classOrFieldName);
        if (object!=null) {
            return doc.display(classOrFieldName, object, context);
        }
        return doc.getObject(classOrFieldName);
    }


    public String getTextArea() {
        return com.xpn.xwiki.XWiki.getTextArea(doc.getContent(), context);
    }


    /**
     * Returns data needed for a generation of Table of Content for this document.
     * @param init an intial level where the TOC generation should start at
     * @param max maximum level TOC is generated for
     * @param numbered if should generate numbering for headings
     * @return a map where an heading (title) ID is the key and 
     *          value is another map with two keys: text, level and numbering 
     */
    public Map getTOC(int init, int max, boolean numbered) {
        return TOCGenerator.generateTOC(getContent(), init, max, numbered);
    }

    public void saveDocument() throws XWikiException {
        if (hasAccessLevel("edit"))
            context.getWiki().saveDocument(doc, context);
    }

    public com.xpn.xwiki.api.Object addObjectFromRequest() throws XWikiException {
        if (hasAccessLevel("edit"))
            return new com.xpn.xwiki.api.Object(doc.addObjectFromRequest(context), context);
        else
            return null;
    }

    public void insertText(String text, String marker) throws XWikiException {
        if (hasAccessLevel("edit"))
            doc.insertText(text, marker, context);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -