blob: 4ecc7187d4dd6611154d1cb41c05d9f0556b2d3d [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2017, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.Map;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.CharOperation;
public class SourceModule extends NamedMember implements AbstractModule {
public SourceModule(JavaElement parent, String name) {
super(parent, name);
}
@Override
public int getFlags() throws JavaModelException {
ModuleDescriptionInfo info = (ModuleDescriptionInfo) getElementInfo();
return info.getModifiers();
}
@Override
public char getHandleMementoDelimiter() {
return JavaElement.JEM_MODULE;
}
@Override
public String[] getCategories() throws JavaModelException {
ModuleDescriptionInfo info = (ModuleDescriptionInfo) getElementInfo();
Map<IJavaElement,String[]> map = info.getCategories();
if (map == null) return CharOperation.NO_STRINGS;
String[] categories = map.get(this);
if (categories == null) return CharOperation.NO_STRINGS;
return categories;
}
@Override
public String toString(String lineDelimiter) {
StringBuffer buffer = new StringBuffer();
try {
toStringContent(buffer, lineDelimiter);
} catch (JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return buffer.toString();
}
}