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


Java Element.removeContent方法代碼示例

本文整理匯總了Java中org.jdom.Element.removeContent方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.removeContent方法的具體用法?Java Element.removeContent怎麽用?Java Element.removeContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jdom.Element的用法示例。


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

示例1: serialize

import org.jdom.Element; //導入方法依賴的package包/類
@NotNull
private Element serialize() {
  Element el = new Element("taskManager");
  Element taskManagerElement = new Element(StudySerializationUtils.Xml.MAIN_ELEMENT);
  XmlSerializer.serializeInto(this, taskManagerElement);

  if (myCourse instanceof RemoteCourse) {
    try {
      Element course = new Element(REMOTE_COURSE);
      //noinspection RedundantCast
      XmlSerializer.serializeInto((RemoteCourse)myCourse, course);

      final Element xmlCourse = StudySerializationUtils.Xml.getChildWithName(taskManagerElement, StudySerializationUtils.COURSE);
      xmlCourse.removeContent();
      xmlCourse.addContent(course);
    }
    catch (StudySerializationUtils.StudyUnrecognizedFormatException e) {
      LOG.error("Failed to serialize remote course");
    }
  }

  el.addContent(taskManagerElement);
  return el;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:25,代碼來源:StudyTaskManager.java

示例2: updateElement

import org.jdom.Element; //導入方法依賴的package包/類
/**
 * Method updateElement.
 * 
 * @param counter
 * @param shouldExist
 * @param name
 * @param parent
 * @return Element
 */
protected Element updateElement(Counter counter, Element parent, String name, boolean shouldExist)
{
    Element element =  parent.getChild(name, parent.getNamespace());
    if (element != null && shouldExist) {
        counter.increaseCount();
    }
    if (element == null && shouldExist) {
        element = factory.element(name, parent.getNamespace());
        insertAtPreferredLocation(parent, element, counter);
        counter.increaseCount();
    }
    if (!shouldExist && element != null) {
        int index = parent.indexOf(element);
        if (index > 0) {
            Content previous = parent.getContent(index - 1);
            if (previous instanceof Text) {
                Text txt = (Text)previous;
                if (txt.getTextTrim().length() == 0) {
                    parent.removeContent(txt);
                }
            }
        }
        parent.removeContent(element);
    }
    return element;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:NetbeansBuildActionJDOMWriter.java

示例3: writePluginJpf

import org.jdom.Element; //導入方法依賴的package包/類
@SuppressWarnings("nls")
private void writePluginJpf(IProgressMonitor monitor, IProject project) throws CoreException
{
	Document doc = new Document();
	doc.setDocType(new DocType("plugin", "-//JPF//Java Plug-in Manifest 1.0",
		"http://jpf.sourceforge.net/plugin_1_0.dtd"));
	Element rootElem = new Element("plugin");
	doc.setRootElement(rootElem);
	rootElem.setAttribute("id", project.getName());
	rootElem.setAttribute("version", "1");
	Element requires = new Element("requires");
	rootElem.addContent(requires);
	Element runtime = new Element("runtime");
	Element srcLib = new Element("library");
	srcLib.setAttribute("type", "code");
	srcLib.setAttribute("path", "classes/");
	srcLib.setAttribute("id", "classes");
	Element export = new Element("export");
	export.setAttribute("prefix", "*");
	srcLib.addContent(export);
	runtime.addContent(srcLib);
	rootElem.addContent(runtime);
	fFirstPage.customizeManifest(rootElem, project, monitor);
	if( requires.getContentSize() == 0 )
	{
		rootElem.removeContent(requires);
	}

	IFile manifest = JPFProject.getManifest(project);
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	try
	{
		xmlOut.output(doc, baos);
	}
	catch( IOException e )
	{
		throw new RuntimeException(e);
	}
	manifest.create(new ByteArrayInputStream(baos.toByteArray()), true, monitor);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:41,代碼來源:NewPluginWizard.java

示例4: updateElement

import org.jdom.Element; //導入方法依賴的package包/類
/**
 * Method updateElement
 *
 * @param counter
 * @param shouldExist
 * @param name
 * @param parent
 */
protected Element updateElement( Counter counter, Element parent, String name, boolean shouldExist )
{
    Element element = parent.getChild( name, parent.getNamespace() );
    if ( element != null && shouldExist )
    {
        counter.increaseCount();
    }
    if ( element == null && shouldExist )
    {
        element = factory.element( name, parent.getNamespace() );
        insertAtPreferredLocation( parent, element, counter );
        counter.increaseCount();
    }
    if ( !shouldExist && element != null )
    {
        int index = parent.indexOf( element );
        if ( index > 0 )
        {
            Content previous = parent.getContent( index - 1 );
            if ( previous instanceof Text )
            {
                Text txt = (Text) previous;
                if ( txt.getTextTrim().length() == 0 )
                {
                    parent.removeContent( txt );
                }
            }
        }
        parent.removeContent( element );
    }
    return element;
}
 
開發者ID:javiersigler,項目名稱:apache-maven-shade-plugin,代碼行數:41,代碼來源:MavenJDOMWriter.java

示例5: convertToSecondVersion

import org.jdom.Element; //導入方法依賴的package包/類
public static Element convertToSecondVersion(Element element) throws StudyUnrecognizedFormatException {
  final Element oldCourseElement = element.getChild(COURSE_ELEMENT);
  Element state = new Element(MAIN_ELEMENT);

  Element course = addChildWithName(state, COURSE, oldCourseElement.clone());
  course.setName(COURSE_TITLED);

  Element author = getChildWithName(course, AUTHOR);
  String authorString = author.getAttributeValue(VALUE);
  course.removeContent(author);

  String[] names = authorString.split(" ", 2);
  Element authorElement = new Element(AUTHOR_TITLED);
  addChildWithName(authorElement, FIRST_NAME, names[0]);
  addChildWithName(authorElement, SECOND_NAME, names.length == 1 ? "" : names[1]);

  addChildList(course, AUTHORS, Collections.singletonList(authorElement));

  Element courseDirectoryElement = getChildWithName(course, RESOURCE_PATH);
  renameElement(courseDirectoryElement, COURSE_DIRECTORY);

  for (Element lesson : getChildList(course, LESSONS)) {
    incrementIndex(lesson);
    for (Element task : getChildList(lesson, TASK_LIST)) {
      incrementIndex(task);
      Map<String, Element> taskFiles = getChildMap(task, TASK_FILES);
      for (Element taskFile : taskFiles.values()) {
        renameElement(getChildWithName(taskFile, TASK_WINDOWS), ANSWER_PLACEHOLDERS);
        for (Element placeholder : getChildList(taskFile, ANSWER_PLACEHOLDERS)) {
          placeholder.setName(ANSWER_PLACEHOLDER);

          Element initialState = new Element(MY_INITIAL_STATE);
          addChildWithName(placeholder, INITIAL_STATE, initialState);
          addChildWithName(initialState, MY_LINE, getChildWithName(placeholder, MY_INITIAL_LINE).getAttributeValue(VALUE));
          addChildWithName(initialState, MY_START, getChildWithName(placeholder, MY_INITIAL_START).getAttributeValue(VALUE));
          addChildWithName(initialState, MY_LENGTH, getChildWithName(placeholder, MY_INITIAL_LENGTH).getAttributeValue(VALUE));
        }
      }
    }
  }
  element.removeContent();
  element.addContent(state);
  return element;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:45,代碼來源:StudySerializationUtils.java

示例6: convertToFifthVersion

import org.jdom.Element; //導入方法依賴的package包/類
public static Element convertToFifthVersion(Element state) throws StudyUnrecognizedFormatException {
  Element taskManagerElement = state.getChild(MAIN_ELEMENT);
  Element courseElement = getChildWithName(taskManagerElement, COURSE).getChild(COURSE_TITLED);
  final int courseId = getAsInt(courseElement, ID);
  if (courseElement != null && courseId > 0) {
    courseElement.setName(REMOTE_COURSE);
  }
  final Element adaptive = getChildWithName(courseElement, ADAPTIVE);
  for (Element lesson : getChildList(courseElement, LESSONS)) {
    for (Element task : getChildList(lesson, TASK_LIST)) {
      final Element lastSubtaskIndex = getChildWithName(task, LAST_SUBTASK_INDEX, true); //could be broken by 3->4 migration
      final Element adaptiveParams = getChildWithName(task, ADAPTIVE_TASK_PARAMETERS, true);
      Element theoryTask = getChildWithName(task, THEORY_TAG, true);
      if (theoryTask == null && adaptiveParams != null) {
        theoryTask = getChildWithName(adaptiveParams, THEORY_TAG, true);
      }
      final boolean hasAdaptiveParams = adaptiveParams != null && !adaptiveParams.getChildren().isEmpty();
      if (lastSubtaskIndex != null && Integer.valueOf(lastSubtaskIndex.getAttributeValue(VALUE)) != 0) {
        task.setName(TASK_WITH_SUBTASKS);
      }
      else if (theoryTask != null && Boolean.valueOf(theoryTask.getAttributeValue(VALUE))) {
        task.setName(THEORY_TASK);
      }
      else if (hasAdaptiveParams) {
        task.setName(CHOICE_TASK);
        final Element adaptiveParameters = adaptiveParams.getChildren().get(0);
        for (Element element : adaptiveParameters.getChildren()) {
          final Attribute name = element.getAttribute(NAME);
          if (name != null && !THEORY_TAG.equals(name.getValue())) {
            final Content elementCopy = element.clone();
            task.addContent(elementCopy);
          }
        }
      }
      else if (Boolean.valueOf(adaptive.getAttributeValue(VALUE))) {
        task.setName(CODE_TASK);
      }
      else {
        task.setName(PYCHARM_TASK);
      }
      task.removeContent(adaptiveParams);
      task.removeContent(theoryTask);
    }
  }
  return state;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:47,代碼來源:StudySerializationUtils.java


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