当前位置: 首页>>代码示例>>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;未经允许,请勿转载。