Package org.wikipediacleaner.api.data

Examples of org.wikipediacleaner.api.data.Namespace


            title = title.substring(0, title.length() - 1 - todoSubpage.length());
          }
          int colonIndex = title.indexOf(':');
          if (colonIndex >= 0) {
            for (Integer namespace : configuration.getEncyclopedicTalkNamespaces()) {
              Namespace namespaceTalk = wikiConfiguration.getNamespace(namespace);
              if ((namespaceTalk != null) &&
                  (namespaceTalk.isPossibleName(title.substring(0, colonIndex)))) {
                String tmpTitle = title.substring(colonIndex + 1);
                if (namespace != Namespace.MAIN_TALK) {
                  tmpTitle = wikiConfiguration.getPageTitle(namespace - 1, tmpTitle);
                }
                if ((start.length() == 0) || (start.compareTo(tmpTitle) < 0)) {
View Full Code Here


    }
    Configuration config = Configuration.getConfiguration();
    String signature = config.getString(null, ConfigurationValueString.SIGNATURE);

    // Retrieve user talk page name
    Namespace userTalkNS = wiki.getWikiConfiguration().getNamespace(Namespace.USER_TALK);
    String userTalk = userTalkNS.getTitle() + ":" + user;
    Page userTalkPage = DataManager.getPage(analysis.getWikipedia(), userTalk, null, null, null);

    // Add message
    try {
      if (globalTitle != null) {
View Full Code Here

  private String translateCategories(
      String text, boolean translate) throws APIException {
    if (!translate) {
      return text;
    }
    Namespace categoryNamespace = getWikipedia().getWikiConfiguration().getNamespace(Namespace.CATEGORY);
    if (categoryNamespace == null) {
      return text;
    }
    PageAnalysis analysis = page.getAnalysis(text, true);
    Collection<PageElementCategory> categories = analysis.getCategories();
    Map<String, String> interwikis = new HashMap<String, String>();
    StringBuilder newText = new StringBuilder();
    int lastPosition = 0;
    for (PageElementCategory category : categories) {
      String categoryName = category.getName();
      String fullCategoryName = categoryNamespace.getCanonicalTitle() + ":" + categoryName;
      setText(GT._("Retrieving interwiki for {0}", fullCategoryName));
      String translated = null;
      if (!interwikis.containsKey(categoryName)) {
        translated = getLanguageLink(fullCategoryName);
        interwikis.put(categoryName, translated);
View Full Code Here

      boolean translateName,
      boolean translateWithoutParams) throws APIException {
    if (!translateName) {
      return text;
    }
    Namespace templateNamespace = getWikipedia().getWikiConfiguration().getNamespace(Namespace.TEMPLATE);
    if (templateNamespace == null) {
      return text;
    }
    PageAnalysis analysis = page.getAnalysis(text, true);
    Collection<PageElementTemplate> templates = analysis.getTemplates();
    Map<String, String> interwikis = new HashMap<String, String>();
    StringBuilder newText = new StringBuilder();
    int lastPosition = 0;
    for (PageElementTemplate template : templates) {
      String templateName = template.getTemplateName();
      String fullTemplateName = templateNamespace.getCanonicalTitle() + ":" + templateName;
      setText(GT._("Retrieving interwiki for {0}", fullTemplateName));
      String translated = null;
      if (!interwikis.containsKey(templateName)) {
        translated = getLanguageLink(fullTemplateName);
        interwikis.put(templateName, translated);
View Full Code Here

  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
    try {
      Namespace categoryNamespace = toWikipedia.getWikiConfiguration().getNamespace(Namespace.CATEGORY);
      String categoryName = PageElementCategory.DEFAULT_NAME;
      if (categoryNamespace != null) {
        if (!PageElementCategory.DEFAULT_NAME.equals(
            categoryNamespace.getCanonicalTitle())) {
          categoryName = categoryNamespace.getCanonicalTitle();
        } else {
          for (String alias : categoryNamespace.getAliases()) {
            if (!PageElementCategory.DEFAULT_NAME.equals(alias)) {
              categoryName = alias;
              break;
            }
          }
View Full Code Here

      return false;
    }

    // Retrieve informations
    WikiConfiguration config = analysis.getWikiConfiguration();
    Namespace templateNamespace = config.getNamespace(Namespace.TEMPLATE);

    // Check every template to if template name contains template namespace
    Collection<PageElementTemplate> templates = analysis.getTemplates();
    if ((templates == null) || (templates.isEmpty())) {
      return false;
    }
    boolean result = false;
    for (PageElementTemplate template : templates) {
      String templateName = template.getTemplateName();
      int colonIndex = templateName.indexOf(':');
      String namespace = (colonIndex > 0) ? templateName.substring(0, colonIndex) : null;
      if ((colonIndex > 0) &&
          (templateNamespace.isPossibleName(namespace))) {

        // Test for special situations (functions)
        MagicWord magicWord = null;
        if (templateName.length() > colonIndex + 1) {
          String afterColon = templateName.substring(colonIndex + 1);
View Full Code Here

        (analysis.getPage().getTemplates() == null)) {
      return false;
    }

    // Analyze each template
    Namespace templateNS = analysis.getWikiConfiguration().getNamespace(Namespace.TEMPLATE);
    List<PageElementTemplate> templates = analysis.getTemplates();
    boolean result = false;
    for (PageElementTemplate template : templates) {
      String templateName = templateNS.getTitle() + ":" + template.getTemplateName();
      boolean missing = false;
      for (Page templatePage : analysis.getPage().getTemplates()) {
        if (Page.areSameTitle(templateName, templatePage.getTitle())) {
          if (Boolean.FALSE.equals(templatePage.isExisting())) {
            missing = true;
View Full Code Here

            if (title.endsWith("/" + todoSubpage)) {
              title = title.substring(0, title.length() - 1 - todoSubpage.length());
            }
            Integer namespace = warningPage.getNamespace();
            if (namespace != null) {
              Namespace namespaceTalk = wikiConfiguration.getNamespace(namespace.intValue());
              if (namespaceTalk != null) {
                int colonIndex = title.indexOf(':');
                if (colonIndex >= 0) {
                  title = title.substring(colonIndex + 1);
                }
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.data.Namespace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.