merobase supports four basic kinds of queries -
To search for a given string in a component's source code, simply enter the string within quotation marks or precede the string with the search constraint content. Thus the query:
"new BufferedReader"
will yield components whose code contains the string "new BufferedReader". String matching is not case sensitive.
To search for components with a particular name, simply type in the corresponding string. Again, matching is not case sensitive. Thus the query:
resourceManager
will return components whose name is, or matches, "resourceManager".
To search for function-oriented components (e.g. functions, procedures, operations, methods, routines...), give the name of the abstraction followed by a comma-separated list of parameter types enclosed in brackets, an optional return type preceded by a colon and a terminating semi-colon. Thus the query:
random(float,float):float;
will search for components which represent a function (or method etc.) named "random" with two input parameters of type "float" and a return value of type "float". The list of parameters may be empty and the return type (with colon) is optional.
To search for components which represent object-oriented abstractions, give the name of the abstraction, followed by a list of function specifications enclosed in brackets. Thus, the query:
Customer ( getAddress():String; setAddress(String):void; )
will search for components named "Customer" that offers an operation (i.e. method or function) named "setAddress" with an in parameter of type String and an operation "getAddress" with an out parameter or return value of type String.
In general, merobase will consider all forms of components that match the query when assembling search results, whatever their type or language. However, it is possible to restrict the scope of a search query using constraints. The constraints supported by merobase are as follows:
The form constraint restricts the basic form of component that will be returned in a search. Two values are currently supported for this constraint: source and binary. source restricts the result to components which are in source code form such as Java ".java" classes while binary returns components which are in compiled form such as .NET assemblies and Java bytecode ".class" classes. For example, the query:
calculator form:binary
returns components called calculator in binary format. If no form constraint is added to a query, all forms of matching component are included in the search results.
The type constraint restricts the components returned in a search to a specific type of program unit. Four values are currently supported for this constraint: class, interface, service and enum. class returns components that are classes, interface returns components that are interfaces, service returns components that are web services and enum returns components that are enumerations. For example, the query:
CurrencyConverter( convert(currency,currency):double; ) type:class
will search for classes called "CurrencyConverter" that have two currencies in parameter and an double out parameter or return value.
The kind constraint restricts the components returned in a search to those that play a specific logical role or represent a specific kind of abstraction. Six values are currently supported for this constraint: ejb, applet, application, midlet, testcase and servlet. ejb returns components which represent EJBs (Enterprise Java Beans), applet returns components which are applets, application delivers results that contain a main method, midlet returns components which constitute midlets, testcase returns components which represent testcases written according to a testing framework such as JUnit or NUnit, and servlet returns components which represent servlets. For example, the query:
Mortgage kind:applet
will return components named "Mortgage" which are applets.
The namespace constraint resticts a search to components within a particular namespace. The name of the namespace is a free text string. For example,
stack namespace:utility
will returns components named Stack in the namespace (or package) "utility". The constraints namespace and package have the same meaning.
The project constraint restricts a search to components within a particular project. The name of the project is a free text string. Thus to constrain a search for example to the Eclipse project use the following constraint:
astparser project:eclipse
The example query above will return AstParser components contained in the Eclipse IDE.
The url constraint restricts a search to components at a particular URL (usually just one component) or to components that contain a given string in the URL where we discovered them. Thus the actual constraint is a free text string and the query:
url:parser
will return components that contain the string parser somewhere in their URL.
While the url constraint takes the whole URL into account, the host constraint restricts a search to components hosted on a particular server. The name of the site is a free test string. Thus, the query
host:dev.java.net
will only return components that are hosted from dev.java.net.
The license constraint restricts a search to components with a specific license. The name of the site is a free test string. Thus, the query:
license:"general public license"
will return components that are under the GPL.
The lictype constraint restricts a search to components whose license provides certain degrees of freedom in how they can be used. The specific name of a license is usually not of interest, but the general degree of freedom that it provides is. For example, a user might wish to avoid licenses with a strong copyleft (such as the GPL). Using the lictype constraint searches can be restricted to components whose license fits into one of five broad groups, with decreasingly stringent requirements for adherence to the copyleft principle:
| Constraint value | Property |
|---|---|
| strong | strong copyleft requirements |
| weak | week copyleft requirements |
| options | certain options allowed |
| privileges | certain privileges allowed |
| without | no copyleft requirements of any kind |
| no | no license at all |
The constraint values are ordered in terms of increasing levels of copyleft requirements, from the strongest, strong, to the weakest, without. A search for a stronger copyleft always includes results that have a weaker copyleft. Thus, the query
lictype:options
will also return results whose license belongs in the privileges or without or no group of licenses. This constraint cannot be combined with NOT (i.e. -lictype).
In combination with the various kinds of constraints, the four basic MQL query types just described allow a large and sophisticated range of searches to be performed. Merobase also support some additional capabilities that provide users with even more ways of finding and accessing components.
It is possible to access and execute a web service with a known URL simply by typing in that URL. Thus, the URL
http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl
will provide direct access to the web service at the specified location.
Merobase also allows function-oriented and object-oriented queries to be defined in the syntax of certain supported programming languages (currently C, C# and Java). Thus, the query
public class ShoppingCart {
public void addItem(Item i, int n) {}
public double total() {}
}
Is equivalent to:
public class ShoppingCart {
addItem(Item, int);
total(): double;
}
The class will not compile, because it does not have the return statements necessary for some of the specified methods. However, it is syntactically correct and contains enough information for the parser to extract the corresponding object abstraction. Any superfluous information in the input code is ignored.
As well as primitive types and class names, merobase allows searches on function-oriented abstractions with parameters of array types. An array type is expressed in a Java/C/C# like language by adding square bracket to a normal type name. Thus the query:
quicksort(int[]):int[];
Merobase supports the standard Boolean operators (AND, OR, NOT or +, -) between text and name based searches and between constraints, but not within programming language or UML like queries. Thus the query
ShoppingCart type:class (lang:java OR lang:cs)
will return components named "ShoppingCart" which are classes and which are written in either in Java or C# .
home · getting started · updates · faq · about · terms of service · contact · downloads · submit