This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 226122
Collapse All | Expand All

(-)a/editor.mimelookup/apichanges.xml (-1 / +19 lines)
Lines 107-113 Link Here
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
108
109
    <changes>
109
    <changes>
110
110
        <change id="MimePath.inherited">
111
            <summary>Access to parent MIME type and all included paths</summary>
112
            <version major="1" minor="30"/>
113
            <date day="21" month="2" year="2013"/>
114
            <author login="sdedic"/>
115
            <compatibility binary="compatible" source="compatible" semantic="compatible" addition="no" deletion="no" modification="no" deprecation="yes"/>
116
            <description>
117
                <p>
118
                    <code>getIncludedPaths</code> can be now used to compute all MimePaths that should
119
                    be considered for the content. In the past, reflection was used to access this functionality.
120
                </p>
121
                <p>
122
                    <code>getInheritedType</code> provides generalized or parent MIME type for the content, 
123
                    which allows to search settings (services) fallbacks.
124
                </p>
125
            </description>
126
            <class package="org.netbeans.api.editor.mimelookup" name="MimePath"/>
127
            <issue number=""/>
128
        </change>
111
        <change id="Class2LayerFolder.deprecated">
129
        <change id="Class2LayerFolder.deprecated">
112
            <summary>Class2LayerFolder Deprecated and not used</summary>
130
            <summary>Class2LayerFolder Deprecated and not used</summary>
113
            <version major="1" minor="20"/>
131
            <version major="1" minor="20"/>
(-)a/editor.mimelookup/manifest.mf (-1 / +1 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.editor.mimelookup/1
2
OpenIDE-Module: org.netbeans.modules.editor.mimelookup/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/mimelookup/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/mimelookup/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.30
4
OpenIDE-Module-Specification-Version: 1.31
5
OpenIDE-Module-Recommends: org.netbeans.spi.editor.mimelookup.MimeDataProvider
5
OpenIDE-Module-Recommends: org.netbeans.spi.editor.mimelookup.MimeDataProvider
6
AutoUpdate-Essential-Module: true
6
AutoUpdate-Essential-Module: true
7
7
(-)a/editor.mimelookup/src/org/netbeans/api/editor/mimelookup/MimePath.java (+74 lines)
Lines 532-537 Link Here
532
        return true;
532
        return true;
533
    }
533
    }
534
    
534
    
535
    /**
536
     * Returns the inherited Mime type.
537
     * For {@link #EMPTY}, returns {@code null}. For most other mime types, returns
538
     * {@code ""}. If the mime type derives from another one, such as text/ant+xml derives
539
     * from xml, the return value will be the base mime type (text/xml in the example case).
540
     * <p/>
541
     * For MimePaths that identified embedded content (more components on the MimePath),
542
     * the method returns the parent MIME of the last MIME type on the path
543
     * 
544
     * @return inherited mime type, or {@code null}, if no parent exists (for {@link #EMPTY})
545
     */
546
    public String getInheritedType() {
547
        if ("".equals(mimeType)) {
548
            return null;
549
        }
550
        MimePath lastType = (size() == 1) ? this : MimePath.parse(mimeType);
551
        List<String> inheritedPaths = lastType.getInheritedPaths(null, null);
552
        if (inheritedPaths.size() > 1) {
553
            return inheritedPaths.get(1);
554
        } else {
555
            return null;
556
        }
557
    }
558
    
559
    
560
    /**
561
     * Returns the included Mime paths.
562
     * For MimePath, which nests several MIME types (i.e. text/php/text/html/text/css), it enumerates
563
     * sub-paths so that a following element represents one level of nesting of the content.
564
     * For the example example, the return would be:
565
     * <ol>
566
     * <li>text/php/text/html/text/css -- the full path
567
     * <li>text/html/text/css -- outer content is removed
568
     * <li>text/css -- the mime type of the identified content itself
569
     * <li> (empty string)
570
     * </ol>
571
     * <p/>
572
     * If a MIME type on the path has a generic MIME type (i.e. text/x-ant+xml 
573
     * has a generic MIME type text/xml), that generic type will be inserted. For example,
574
     * for text/java/text/x-ant+xml/text/javascript, the result will list:
575
     * <ol>
576
     * <li>text/java/text/x-ant+xml/text/javascript, -- the full MimePath
577
     * <li>text/x-ant+xml/text/javascript -- a prefix
578
     * <li>text/xml/text/javascript -- ant+xml is generalized to xml
579
     * <li>text/javascript
580
     * <li>  (empty string)
581
     * </ol>
582
     * For all but {@link #EMPTY} MimePaths, the list contains at least one entry, and the last
583
     * entry is the {@link #EMPTY}. Note also, that the complete MimePath is always returned
584
     * as the 1st member of the list.
585
     * <p/>
586
     * The returned sequence of MimePaths is suitable for searching settings or services
587
     * for the (embedded) content whose type is described by MimePath as it is ordered from the
588
     * most specific to the least specific paths (including generalization) and always contains
589
     * the mime type of the identified contents. The last component ({@link ""}) represents 
590
     * default settings (services).
591
     * <p/>
592
     * Note that for MimePaths created from a mime type (not empty!) string, the 
593
     * <code>getInheritedPaths().get(1)</code> is a parent mime type. Either empty,
594
     * or the generalized MIME.
595
     * <p/>
596
     * The caller should not modify the returned List.
597
     * 
598
     * @return list of inherited Mime paths
599
     */
600
    public List<MimePath> getIncludedPaths() {
601
        List<String> paths = getInheritedPaths(null, null);
602
        List<MimePath> mpaths = new ArrayList<MimePath>(paths.size());
603
        for (String p : paths) {
604
            mpaths.add(MimePath.parse(p));
605
        }
606
        return mpaths;
607
    }
608
    
535
    // XXX: This is currently called from editor/settings/storage (SettingsProvider)
609
    // XXX: This is currently called from editor/settings/storage (SettingsProvider)
536
    // and editor/mimelookup/impl via reflection.
610
    // and editor/mimelookup/impl via reflection.
537
    // We will eventually make it friend API. In the meantime just
611
    // We will eventually make it friend API. In the meantime just

Return to bug 226122